# HG changeset patch # User Michiel Broek # Date 1403634067 -7200 # Node ID 879bd09e2b9644d0d34220e2e2f53781c25fd892 # Parent 4a28de5b9b47f9093bd6ee8e579be59e77d47b52 Reinstalled threads diff -r 4a28de5b9b47 -r 879bd09e2b96 thermferm/sensors.c --- a/thermferm/sensors.c Mon Jun 23 22:50:29 2014 +0200 +++ b/thermferm/sensors.c Tue Jun 24 20:21:07 2014 +0200 @@ -31,7 +31,7 @@ #ifdef HAVE_WIRINGPI_H PI_THREAD (my_sensors_loop) #else -int my_sensors_loop(void) +void *my_sensors_loop(void *threadid) #endif { w1_therm *tmp1, *old1; diff -r 4a28de5b9b47 -r 879bd09e2b96 thermferm/server.c --- a/thermferm/server.c Mon Jun 23 22:50:29 2014 +0200 +++ b/thermferm/server.c Tue Jun 24 20:21:07 2014 +0200 @@ -315,7 +315,7 @@ #ifdef HAVE_WIRINGPI_H PI_THREAD (my_server_loop) #else -int my_server_loop(void) +void *my_server_loop(void *threadid) #endif { socklen_t addrlen; diff -r 4a28de5b9b47 -r 879bd09e2b96 thermferm/thermferm.c --- a/thermferm/thermferm.c Mon Jun 23 22:50:29 2014 +0200 +++ b/thermferm/thermferm.c Tue Jun 24 20:21:07 2014 +0200 @@ -40,7 +40,9 @@ extern unsigned char lcdbuf[MAX_LCDS][20][4]; #endif int lcdupdate; - +#ifndef HAVE_WIRINGPI_H +pthread_t threads[2]; +#endif int server(void); void help(void); @@ -227,10 +229,10 @@ char buf[1024]; time_t now, last = (time_t)0; w1_therm *tmp1; -#ifdef HAVE_WIRINGPI_H - int rc; + int rc, run = 1, temp; +#ifndef HAVE_WIRINGPI_H + long t = 0; #endif - int run = 1, temp; if (lockprog((char *)"thermferm")) { syslog(LOG_NOTICE, "Can't lock"); @@ -239,17 +241,23 @@ #ifdef HAVE_WIRINGPI_H rc = piThreadCreate(my_sensors_loop); +#else + rc = pthread_create(&threads[0], NULL, my_sensors_loop, (void *)t ); +#endif if (rc) { fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc); syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc); } +#ifdef HAVE_WIRINGPI_H rc = piThreadCreate(my_server_loop); +#else + rc = pthread_create(&threads[1], NULL, my_server_loop, (void *)t ); +#endif if (rc) { fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc); syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc); } -#endif snprintf(buf, 1023, "tempA,tempB"); logger((char *)"thermferm.log", (char *)"thermferm", buf); diff -r 4a28de5b9b47 -r 879bd09e2b96 thermferm/thermferm.h --- a/thermferm/thermferm.h Mon Jun 23 22:50:29 2014 +0200 +++ b/thermferm/thermferm.h Tue Jun 24 20:21:07 2014 +0200 @@ -29,13 +29,13 @@ #include #include #include +#ifndef HAVE_WIRINGPI_H +#include +#endif #include #include -/* mosquitto */ -// # include - #ifdef HAVE_WIRINGPI_H /* wiringPi */ #include @@ -180,7 +180,7 @@ #ifdef HAVE_WIRINGPI_H PI_THREAD (my_sensors_loop); #else -int my_sensors_loop(void); +void *my_sensors_loop(void *); #endif /* server.c */ @@ -189,7 +189,7 @@ #ifdef HAVE_WIRINGPI_H PI_THREAD (my_server_loop); #else -int my_server_loop(void); +void *my_server_loop(void *); #endif