diff --git a/simulator/rdtemp/cli.ino b/simulator/rdtemp/cli.ino index 0925139..44670cf 100644 --- a/simulator/rdtemp/cli.ino +++ b/simulator/rdtemp/cli.ino @@ -7,7 +7,7 @@ #include #include -#define DEBUG 1 +#define DEBUG 0 /* -------------------------------------------------- */ /* some interesting macros */ #define prt(a) Serial.print(a) @@ -70,13 +70,23 @@ prtln(""); static void clihelp() { prtln("x\texit cli"); - prtln("I\tinit storage"); + prtln("I\tinit storage"); /* dangerous !!! */ + prtln("s d N\tset delay"); + prtln("s l N\tset lo temp"); + prtln("s h N\tset hi temp"); prtln("d\tdisplay config"); prtln("r\tread config"); prtln("w\twrite config"); - prtln("H\thexdump config"); + prtln("h\thexdump config"); } /* --------------------------------------------------------------- */ +void setvalue(char *cmdline) +{ +hexdump(cmdline, 10); + +} +/* --------------------------------------------------------------- */ + void phytocli(void) { char flag_exit = 0; @@ -99,11 +109,11 @@ do { switch(key) { case 'x': flag_exit=1; break; case '?': clihelp(); break; - case 'I': init_storage(); break; + case 'I': init_storage(¶metres); 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, + case 'h': hexdump((unsigned char *)¶metres, sizeof(Global)); break; default: prtln("gni ?"); break; diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index d9196c9..f3ce364 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -11,6 +11,9 @@ typedef struct { unsigned short magic; char tag[4]; short delai; + short temp_maxi; + short temp_mini; + short control; } Global; Global parametres; @@ -20,17 +23,14 @@ void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); - Serial.print("\n"); - - phytocli(); /* XXX */ - + Serial.print("\n"); /* XXX */ /* changing the voltage reference of the ADC * greatly increase the prcision on the limited * range of our temperatures. */ analogReference(INTERNAL1V1); // Pour Arduino Mega2560 - Serial.print("\n\n"); + Serial.print("\n"); delay(1000); Serial.print("M running now\n"); diff --git a/simulator/rdtemp/storage.ino b/simulator/rdtemp/storage.ino index c964f49..a9ba793 100644 --- a/simulator/rdtemp/storage.ino +++ b/simulator/rdtemp/storage.ino @@ -1,40 +1,45 @@ /* --------------------------------------------------------------- */ #include /* --------------------------------------------------------------- */ -short init_storage(void) +short init_storage(Global *what) { short foo; -Serial.println(__func__); - Serial.print("eeprom length: "); Serial.println(EEPROM.length()); Serial.print("global length: "); Serial.println(sizeof(Global)); +memset(what, 0, sizeof(Global)); +what->magic = 0xfde9; +EEPROM.put(0, *what); + +return 0; } /* --------------------------------------------------------------- */ short read_config(short num, Global *where) { +unsigned short magic; + #if DEBUG prtln(">>> read config"); #endif - - - - -return -1; +magic = 0; +prt("magic is "); prtln(magic); +EEPROM.get(0, magic); +prt("magic is "); prtln(magic); +if (0xfde9 != magic) return -1; +EEPROM.get(0, *where); +return -2; } /* --------------------------------------------------------------- */ short write_config(short num, Global *from) { -#if DEBUG -prtln(">>> write config"); -#endif - from->magic = 0xfde9; memcpy(from->tag, "aaaa", 4); + + return -1; } /* --------------------------------------------------------------- */ @@ -53,6 +58,8 @@ for (foo=0; foo<4; foo++) { } prtln(""); prt("Delay : "); prtln(what->delai); +prt("Temp mini : "); prtln(what->temp_mini); +prt("Temp maxi : "); prtln(what->temp_maxi); return -1; }