thermferm/thermferm.c

changeset 43
24e731bb2e08
parent 41
f534ace74eea
child 44
f37d73940699
equal deleted inserted replaced
42:01b96a24ae7c 43:24e731bb2e08
22 22
23 #include "../lib/mbselib.h" 23 #include "../lib/mbselib.h"
24 #include "thermferm.h" 24 #include "thermferm.h"
25 #include "mosquitto.h" 25 #include "mosquitto.h"
26 #include "sensors.h" 26 #include "sensors.h"
27 #include "server.h"
27 28
28 #ifdef HAVE_WIRINGPI_H 29 #ifdef HAVE_WIRINGPI_H
29 30
30 31
31 int tempA = 80; 32 int tempA = 80;
33 int coolerA = 0; 34 int coolerA = 0;
34 int coolerB = 0; 35 int coolerB = 0;
35 36
36 bool my_shutdown = false; 37 bool my_shutdown = false;
37 static pid_t pgrp, mypid; 38 static pid_t pgrp, mypid;
39 int clients = 0;
38 40
39 extern bool debug; 41 extern bool debug;
40 extern sys_config Config; 42 extern sys_config Config;
41 extern int lcdHandle; 43 extern int lcdHandle;
42 extern unsigned char lcdbuf[MAX_LCDS][20][4]; 44 extern unsigned char lcdbuf[MAX_LCDS][20][4];
150 if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) 152 if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP))
151 signal(i, (void (*))die); 153 signal(i, (void (*))die);
152 } 154 }
153 155
154 if (wiringPiSetup () ) 156 if (wiringPiSetup () )
157 return 1;
158
159 if (server_init() )
155 return 1; 160 return 1;
156 161
157 if ((rc = initLCD (16, 2))) { 162 if ((rc = initLCD (16, 2))) {
158 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); 163 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc);
159 return 1; 164 return 1;
256 if (rc) { 261 if (rc) {
257 fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc); 262 fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc);
258 syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc); 263 syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc);
259 } 264 }
260 265
266 rc = piThreadCreate(my_server_loop);
267 if (rc) {
268 fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc);
269 syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc);
270 }
271
261 snprintf(buf, 1023, "tempA,coolerA,tempB,coolerB"); 272 snprintf(buf, 1023, "tempA,coolerA,tempB,coolerB");
262 logger((char *)"thermferm.log", (char *)"thermferm", buf); 273 logger((char *)"thermferm.log", (char *)"thermferm", buf);
263 274
264 do { 275 do {
265 lcdupdate = FALSE; 276 lcdupdate = FALSE;

mercurial