parameters validation function

This commit is contained in:
phyto 2019-05-16 18:17:22 +02:00
parent 8e39f86901
commit 9cdd17310d

View File

@ -9,7 +9,25 @@
#define DEBUG 0 #define DEBUG 0
/* -------------------------------------------------- */ /* -------------------------------------------------- */
short validate_config(Global *param)
{
short delta;
if (param->magic != 0xfde9) {
prtln("bad magic");
return 1;
}
if (param->delai < 100) {
prtln("delay too short");
return 2;
}
delta = param->temp_maxi - param->temp_mini;
if (delta < 20) {
prt(delta); prtln(" bad delta");
return 3;
}
return 0;
}
/* -------------------------------------------------- */ /* -------------------------------------------------- */
char waitkey(char echo) char waitkey(char echo)
{ {
@ -73,6 +91,7 @@ static void clihelp()
prtln("s h N\tset hi temp"); prtln("s h N\tset hi temp");
prtln("d\tdisplay config"); prtln("d\tdisplay config");
prtln("r\tread config"); prtln("r\tread config");
prtln("v\tvalidate config");
prtln("w\twrite config"); prtln("w\twrite config");
prtln("T\ttest relay"); prtln("T\ttest relay");
prtln("+/-\tcontrole frigo"); prtln("+/-\tcontrole frigo");
@ -172,6 +191,7 @@ do {
case 's': setvalue(line, &parametres); break; case 's': setvalue(line, &parametres); break;
case 'T': test_relais(5); break; case 'T': test_relais(5); break;
case 'v': validate_config(&parametres); break;
case '+': controle_frigo(1); break; case '+': controle_frigo(1); break;
case '-': controle_frigo(0); break; case '-': controle_frigo(0); break;