un squelette de gestion de param's
This commit is contained in:
parent
a4104e21f7
commit
0a83be585a
@ -71,6 +71,10 @@ static void clihelp()
|
||||
{
|
||||
prtln("x\texit cli");
|
||||
prtln("I\tinit storage");
|
||||
prtln("d\tdisplay config");
|
||||
prtln("r\tread config");
|
||||
prtln("w\twrite config");
|
||||
prtln("H\thexdump config");
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
void phytocli(void)
|
||||
@ -87,7 +91,7 @@ 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, " "));
|
||||
@ -96,6 +100,13 @@ do {
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -1,14 +1,59 @@
|
||||
/* --------------------------------------------------------------- */
|
||||
#include <EEPROM.h>
|
||||
/* --------------------------------------------------------------- */
|
||||
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;
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user