thermferm/thermferm.c

changeset 74
879bd09e2b96
parent 72
f7cb53c50ee1
child 75
4b976601737d
equal deleted inserted replaced
73:4a28de5b9b47 74:879bd09e2b96
38 #ifdef HAVE_WIRINGPI_H 38 #ifdef HAVE_WIRINGPI_H
39 extern int lcdHandle; 39 extern int lcdHandle;
40 extern unsigned char lcdbuf[MAX_LCDS][20][4]; 40 extern unsigned char lcdbuf[MAX_LCDS][20][4];
41 #endif 41 #endif
42 int lcdupdate; 42 int lcdupdate;
43 43 #ifndef HAVE_WIRINGPI_H
44 pthread_t threads[2];
45 #endif
44 46
45 int server(void); 47 int server(void);
46 void help(void); 48 void help(void);
47 void die(int); 49 void die(int);
48 #ifdef HAVE_WIRINGPI_H 50 #ifdef HAVE_WIRINGPI_H
225 int server(void) 227 int server(void)
226 { 228 {
227 char buf[1024]; 229 char buf[1024];
228 time_t now, last = (time_t)0; 230 time_t now, last = (time_t)0;
229 w1_therm *tmp1; 231 w1_therm *tmp1;
230 #ifdef HAVE_WIRINGPI_H 232 int rc, run = 1, temp;
231 int rc; 233 #ifndef HAVE_WIRINGPI_H
232 #endif 234 long t = 0;
233 int run = 1, temp; 235 #endif
234 236
235 if (lockprog((char *)"thermferm")) { 237 if (lockprog((char *)"thermferm")) {
236 syslog(LOG_NOTICE, "Can't lock"); 238 syslog(LOG_NOTICE, "Can't lock");
237 return 1; 239 return 1;
238 } 240 }
239 241
240 #ifdef HAVE_WIRINGPI_H 242 #ifdef HAVE_WIRINGPI_H
241 rc = piThreadCreate(my_sensors_loop); 243 rc = piThreadCreate(my_sensors_loop);
244 #else
245 rc = pthread_create(&threads[0], NULL, my_sensors_loop, (void *)t );
246 #endif
242 if (rc) { 247 if (rc) {
243 fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc); 248 fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc);
244 syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc); 249 syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc);
245 } 250 }
246 251
252 #ifdef HAVE_WIRINGPI_H
247 rc = piThreadCreate(my_server_loop); 253 rc = piThreadCreate(my_server_loop);
254 #else
255 rc = pthread_create(&threads[1], NULL, my_server_loop, (void *)t );
256 #endif
248 if (rc) { 257 if (rc) {
249 fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc); 258 fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc);
250 syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc); 259 syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc);
251 } 260 }
252 #endif
253 261
254 snprintf(buf, 1023, "tempA,tempB"); 262 snprintf(buf, 1023, "tempA,tempB");
255 logger((char *)"thermferm.log", (char *)"thermferm", buf); 263 logger((char *)"thermferm.log", (char *)"thermferm", buf);
256 264
257 do { 265 do {

mercurial