Browse Source

parameters validation function

phyto 6 months ago
parent
commit
9cdd17310d
1 changed files with 21 additions and 1 deletions
  1. 21
    1
      simulator/rdtemp/cli.ino

+ 21
- 1
simulator/rdtemp/cli.ino View File

@@ -9,7 +9,25 @@
9 9
 
10 10
 #define DEBUG 0
11 11
 /* -------------------------------------------------- */
12
-
12
+short validate_config(Global *param)
13
+{
14
+short delta;
15
+  
16
+if (param->magic != 0xfde9) {
17
+  prtln("bad magic");
18
+  return 1;
19
+  }
20
+if (param->delai < 100) {
21
+  prtln("delay too short");
22
+  return 2;
23
+  }
24
+delta = param->temp_maxi - param->temp_mini;
25
+if (delta < 20) {
26
+  prt(delta); prtln(" bad delta");
27
+  return 3;
28
+  }
29
+return 0;
30
+}
13 31
 /* -------------------------------------------------- */
14 32
 char waitkey(char echo)
15 33
 {
@@ -73,6 +91,7 @@ static void clihelp()
73 91
  prtln("s h N\tset hi temp");
74 92
  prtln("d\tdisplay config");
75 93
  prtln("r\tread config");
94
+ prtln("v\tvalidate config");
76 95
  prtln("w\twrite config");
77 96
  prtln("T\ttest relay");
78 97
  prtln("+/-\tcontrole frigo");
@@ -172,6 +191,7 @@ do  {
172 191
     case 's':  setvalue(line, &parametres);            break;
173 192
     case 'T':  test_relais(5);                         break; 
174 193
 
194
+    case 'v':   validate_config(&parametres);          break;
175 195
     case '+':   controle_frigo(1);                     break;
176 196
     case '-':   controle_frigo(0);                     break;
177 197
        

Loading…
Cancel
Save