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 { |