--- a/brewco/devices.c Fri Nov 27 22:00:23 2015 +0100 +++ b/brewco/devices.c Fri Nov 27 22:56:00 2015 +0100 @@ -32,8 +32,8 @@ #ifdef USE_SIMULATOR -/*extern*/ int SIM_hlt_temp = 0; -/*extern*/ int SIM_mlt_temp = 0; +extern int SIM_hlt_value; +extern int SIM_mlt_value; #endif @@ -215,9 +215,9 @@ } device->value = value; if (strcmp((char *)"SimHLTheater", device->address) == 0) - SIM_hlt_temp = value; + SIM_hlt_value = value; if (strcmp((char *)"SimMLTheater", device->address) == 0) - SIM_mlt_temp = value; + SIM_mlt_value = value; } } #endif @@ -565,14 +565,13 @@ #endif { devices_list *device; -#ifdef USE_SIMULATOR - simulator_list *simulator; -#endif char *addr = NULL, line[60], *p = NULL; FILE *fp; int temp, rc; syslog(LOG_NOTICE, "Thread my_devices_loop started"); + if (debug) + fprintf(stdout, "Thread my_devices_loop started\n"); #ifdef HAVE_WIRINGPI_H if ((rc = piHiPri(10))) @@ -759,16 +758,15 @@ #ifdef HAVE_WIRINGPI_H piLock(LOCK_DEVICES); #endif - if (Config.simulators) { - simulator = Config.simulators; + if (Config.simulator) { if (device->subdevice == 0) { - device->value = (int)(simulator->room_temperature * 1000); + device->value = (int)(Config.simulator->room_temperature * 1000); device->timestamp = time(NULL); } else if (device->subdevice == 1) { - device->value = (int)(simulator->hlt_temperature * 1000); + device->value = (int)(Config.simulator->hlt_temperature * 1000); device->timestamp = time(NULL); } else if (device->subdevice == 2) { - device->value = (int)(simulator->mlt_temperature * 1000); + device->value = (int)(Config.simulator->mlt_temperature * 1000); device->timestamp = time(NULL); } } @@ -786,6 +784,9 @@ */ usleep(10000); } + + if (my_shutdown) + break; /* * Delay a bit after all devices */ @@ -793,6 +794,8 @@ } syslog(LOG_NOTICE, "Thread my_devices_loop stopped"); + if (debug) + fprintf(stdout, "Thread my_devices_loop stopped\n"); return 0; }