diff --git a/.gitignore b/.gitignore index c41f84f..41bac6b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ fake-values essai serial/t core/t +core/*.a doc/*.toc doc/*.log diff --git a/BUILD.txt b/BUILD.txt index fb24a49..cb4ef81 100644 --- a/BUILD.txt +++ b/BUILD.txt @@ -11,6 +11,7 @@ First step, build some parts of the core library : Then you must have datas for working on. One source of datas is the four values who came from the Arduino over serial line. +At this time, you must look at the configuration file. $ cd serial $ make t diff --git a/core/config.h b/core/config.h index 4c3b105..1e3d063 100644 --- a/core/config.h +++ b/core/config.h @@ -8,7 +8,7 @@ typedef struct { int valid; - + char *input_device; } Configuration; diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 2b79cff..8020bcb 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -1,10 +1,9 @@ - +# # experimental config file +# - -input_device s /def/ttyACM0 - - +input_device s /dev/ttyACM0 +input_speed s 9600 diff --git a/core/parseconf.c b/core/parseconf.c index 56af341..1bf1b99 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -10,13 +10,14 @@ extern int verbosity; extern Configuration config; -#define CMP(a) (!strcmp(cptr, a)) +#define CMP(a) (!strcmp(keyptr, a)) /* ---------------------------------------------------------------- */ int parse_config(char *fname, int flags) { FILE *fp; -char line[SZ_STRINGS+1], *cptr; +char line[SZ_STRINGS+1], + *keyptr, *typeptr, *cptr; int numligne; #if DEBUG_LEVEL @@ -49,23 +50,35 @@ while (fgets(line, SZ_STRINGS, fp)) } /* seek for the first token in this line */ - if (NULL==(cptr = strtok(line, " \t"))) { + if (NULL==(keyptr = strtok(line, " \t"))) { /* Got an empty line */ continue; } - /* skip comments */ - if ('#'==*cptr) continue; - - if(verbosity) fprintf(stderr, "[%s]\n", cptr); + if ('#'==*keyptr) continue; + /* seek for the type field */ + if (NULL==(typeptr = strtok(NULL, " \t"))) { + /* we can(t get a type flag ? wtf ? */ + fprintf(stderr, "ERROR line %d : no type\n", numligne); + continue; + } + if(verbosity) + fprintf(stderr, "[%s] type %s\n", keyptr, typeptr); + if CMP("abort") { + fprintf(stderr, "abort in config file\n"); + } + if (CMP("input_device")) { + config.input_device = strdup(strtok(NULL, " \t")); + continue; + } } fclose(fp); -return -1; +return 0; } /* ---------------------------------------------------------------- */ int show_config(char *title) @@ -75,7 +88,8 @@ if (verbosity) { printf("********** %s **********\n", title); } -printf("valid %d\n", config.valid); +printf("valid : %d\n", config.valid); +printf("input device : %s\n", config.input_device); puts(""); return 0; diff --git a/core/t.c b/core/t.c index 835fa58..059efa1 100644 --- a/core/t.c +++ b/core/t.c @@ -42,7 +42,7 @@ while ((opt = getopt(argc, argv, "v")) != -1) { } -foo = parse_config(conffile, 1); +foo = parse_config(conffile, 0); fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); show_config("foo");