diff --git a/simulator/rdtemp/cli.ino b/simulator/rdtemp/cli.ino index 7ee04f0..0925139 100644 --- a/simulator/rdtemp/cli.ino +++ b/simulator/rdtemp/cli.ino @@ -70,7 +70,11 @@ prtln(""); static void clihelp() { prtln("x\texit cli"); - prtln("I\tinit storage"); + prtln("I\tinit storage"); + prtln("d\tdisplay config"); + prtln("r\tread config"); + prtln("w\twrite config"); + prtln("H\thexdump config"); } /* --------------------------------------------------------------- */ void phytocli(void) @@ -87,15 +91,22 @@ prtln("entering cli, '?' to help, 'x' to quit."); do { prt(" + "); ret = readline(line,TLINE); -#if DEBUG +#if DEBUG > 1 hexdump((unsigned char *)line, ret); #endif key = *(sptr = strtok(line, " ")); switch(key) { - case 'x': flag_exit=1; break; - case '?': clihelp(); break; - case 'I': init_storage(); break; + case 'x': flag_exit=1; break; + case '?': clihelp(); break; + case 'I': init_storage(); break; + case 'd': display_config(¶metres); break; + case 'r': read_config(0, ¶metres); break; + case 'w': write_config(0, ¶metres); break; + case 'H': hexdump((unsigned char *)¶metres, + sizeof(Global)); break; + + default: prtln("gni ?"); break; } } while (!flag_exit); diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index 6016949..d9196c9 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -7,6 +7,14 @@ #define NBVAL 4 #define DELAI 1000 +typedef struct { + unsigned short magic; + char tag[4]; + short delai; + } Global; + +Global parametres; + /* -------------------------------------------------- */ void setup() { Serial.begin(9600); diff --git a/simulator/rdtemp/storage.ino b/simulator/rdtemp/storage.ino index 4a4e604..c964f49 100644 --- a/simulator/rdtemp/storage.ino +++ b/simulator/rdtemp/storage.ino @@ -1,14 +1,59 @@ /* --------------------------------------------------------------- */ #include /* --------------------------------------------------------------- */ -int init_storage(void) +short init_storage(void) { +short foo; + Serial.println(__func__); Serial.print("eeprom length: "); Serial.println(EEPROM.length()); - +Serial.print("global length: "); +Serial.println(sizeof(Global)); } /* --------------------------------------------------------------- */ +short read_config(short num, Global *where) +{ +#if DEBUG +prtln(">>> read config"); +#endif + + + + +return -1; +} +/* --------------------------------------------------------------- */ +short write_config(short num, Global *from) +{ +#if DEBUG +prtln(">>> write config"); +#endif + +from->magic = 0xfde9; +memcpy(from->tag, "aaaa", 4); + +return -1; +} +/* --------------------------------------------------------------- */ +short display_config(Global *what) +{ +char foo, c; +#if DEBUG +prtln(">>> display config"); +#endif + +prt("Magic : "); prtln(what->magic); +prt("Id : "); +for (foo=0; foo<4; foo++) { + if (isprint(c=what->tag[foo])) prt(c); + else prt('?'); + } +prtln(""); +prt("Delay : "); prtln(what->delai); + +return -1; +} /* --------------------------------------------------------------- */