33 |
33 |
34 //static int getstr(char **); |
34 //static int getstr(char **); |
35 static int getw1(char **); |
35 static int getw1(char **); |
36 #ifdef HAVE_WIRINGPI_H |
36 #ifdef HAVE_WIRINGPI_H |
37 static int getint(char **); |
37 static int getint(char **); |
38 static int getrcs(char **); |
|
39 #endif |
38 #endif |
40 static int getuch(char **); |
39 static int getuch(char **); |
41 static int getfloat(char **); |
40 static int getfloat(char **); |
42 //static int getbyt(char **); |
41 //static int getbyt(char **); |
43 //static int gethex(char **); |
42 //static int gethex(char **); |
51 key_list keytab[] = { |
50 key_list keytab[] = { |
52 {(char *)"w1therm", getw1, (char **)&Config.w1therms}, |
51 {(char *)"w1therm", getw1, (char **)&Config.w1therms}, |
53 #ifdef HAVE_WIRINGPI_H |
52 #ifdef HAVE_WIRINGPI_H |
54 {(char *)"lcd_cols", getint, (char **)&Config.lcd_cols}, |
53 {(char *)"lcd_cols", getint, (char **)&Config.lcd_cols}, |
55 {(char *)"lcd_rows", getint, (char **)&Config.lcd_rows}, |
54 {(char *)"lcd_rows", getint, (char **)&Config.lcd_rows}, |
56 {(char *)"tx433", getint, (char **)&Config.tx433}, |
|
57 {(char *)"rcswitch", getrcs, (char **)&Config.rcswitch}, |
|
58 #endif |
55 #endif |
59 {(char *)"cs_mode", getuch, (char **)&Config.cs_mode}, |
56 {(char *)"cs_mode", getuch, (char **)&Config.cs_mode}, |
60 {(char *)"cs_beerSet", getfloat, (char **)&Config.cs_beerSet}, |
57 {(char *)"cs_beerSet", getfloat, (char **)&Config.cs_beerSet}, |
61 {(char *)"cs_fridgeSet", getfloat, (char **)&Config.cs_fridgeSet}, |
58 {(char *)"cs_fridgeSet", getfloat, (char **)&Config.cs_fridgeSet}, |
62 {(char *)"cs_heatEstimator", getfloat, (char **)&Config.cs_heatEstimator}, |
59 {(char *)"cs_heatEstimator", getfloat, (char **)&Config.cs_heatEstimator}, |
96 Config.my_port = 6554; |
90 Config.my_port = 6554; |
97 |
91 |
98 #ifdef HAVE_WIRINGPI_H |
92 #ifdef HAVE_WIRINGPI_H |
99 Config.lcd_cols = 16; |
93 Config.lcd_cols = 16; |
100 Config.lcd_rows = 2; |
94 Config.lcd_rows = 2; |
101 Config.tx433 = -1; |
|
102 |
|
103 for (tmp2 = Config.rcswitch; tmp2; tmp2 = old2) { |
|
104 old2 = tmp2->next; |
|
105 if (tmp2->address) |
|
106 free(tmp2->address); |
|
107 tmp2->address = NULL; |
|
108 if (tmp2->alias) |
|
109 free(tmp2->alias); |
|
110 tmp2->alias = NULL; |
|
111 free(tmp2); |
|
112 } |
|
113 Config.rcswitch = NULL; |
|
114 #endif |
95 #endif |
115 |
96 |
116 defaultControlSettings(); |
97 defaultControlSettings(); |
117 defaultControlConstants(); |
98 defaultControlConstants(); |
118 } |
99 } |
386 return 0; |
367 return 0; |
387 } |
368 } |
388 |
369 |
389 |
370 |
390 |
371 |
391 #ifdef HAVE_WIRINGPI_H |
|
392 static int getrcs(char **dest) |
|
393 { |
|
394 char *p, *q = NULL, *r = NULL; |
|
395 rc_switch **tmpm; |
|
396 |
|
397 for (p = v; *p && !isspace(*p); p++); |
|
398 if (*p) |
|
399 *p++ = '\0'; |
|
400 while (*p && isspace(*p)) |
|
401 p++; |
|
402 if (*p == '\0') { |
|
403 syslog(LOG_NOTICE, "rdconfig: %s(%d): less then two tokens", mypath, linecnt); |
|
404 return 1; |
|
405 } |
|
406 |
|
407 for (q = p; *q && !isspace(*q); q++); |
|
408 if (*q && isspace(*q)) { |
|
409 if (*q) |
|
410 *q++ = '\0'; |
|
411 while (*q && isspace(*q)) |
|
412 q++; |
|
413 |
|
414 for (r = q; *r && !isspace(*r); r++); |
|
415 if (*r) |
|
416 *r++ = '\0'; |
|
417 if (debug) |
|
418 syslog(LOG_NOTICE, "rdconfig: getrcs: %s(%d): %s %s", mypath, linecnt, v, p); |
|
419 } |
|
420 |
|
421 for (tmpm = (rc_switch**)dest; *tmpm; tmpm=&((*tmpm)->next)); |
|
422 (*tmpm) = (rc_switch *) xmalloc(sizeof(rc_switch)); |
|
423 (*tmpm)->next = NULL; |
|
424 (*tmpm)->address = xstrcpy(v); |
|
425 (*tmpm)->alias = xstrcpy(p); |
|
426 |
|
427 return 0; |
|
428 } |
|
429 #endif |
|
430 |
|
431 |
|
432 |
|
433 static int getuch(char **dest) |
372 static int getuch(char **dest) |
434 { |
373 { |
435 if (debug) |
374 if (debug) |
436 syslog(LOG_NOTICE, "rdconfig: getuch: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v)); |
375 syslog(LOG_NOTICE, "rdconfig: getuch: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v)); |
437 |
376 |