183 if ((rc = initLCD (16, 2))) { |
183 if ((rc = initLCD (16, 2))) { |
184 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
184 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
185 return 1; |
185 return 1; |
186 } |
186 } |
187 |
187 |
188 // defaultControlsettings(); |
|
189 // defaultControlConstants(); |
|
190 // defaultControlVariables(); |
|
191 |
|
192 lcdPosition(lcdHandle, 0, 0); |
188 lcdPosition(lcdHandle, 0, 0); |
193 sprintf(buf, " Thermferm"); |
189 sprintf(buf, " Thermferm"); |
194 mb_lcdPuts(lcdHandle, buf); |
190 mb_lcdPuts(lcdHandle, buf); |
195 lcdPosition(lcdHandle, 0, 1); |
191 lcdPosition(lcdHandle, 0, 1); |
196 sprintf(buf, " Version %s", VERSION); |
192 sprintf(buf, " Version %s", VERSION); |
228 syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); |
224 syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); |
229 syslog(LOG_NOTICE, "Finished, rc=1"); |
225 syslog(LOG_NOTICE, "Finished, rc=1"); |
230 stopLCD(); |
226 stopLCD(); |
231 exit(1); |
227 exit(1); |
232 case 0: /* |
228 case 0: /* |
233 * Setup shared memory for the parent process |
|
234 */ |
|
235 // syslog(LOG_NOTICE, "size %d", sizeof(struct _beer)); |
|
236 // if ((shmid = shmget(key, sizeof(struct _beer) + 16, IPC_CREAT | 0666)) < 0) { |
|
237 // syslog(LOG_NOTICE, "shmget: %s", strerror(errno)); |
|
238 // exit(1); |
|
239 // } |
|
240 // beer = shmat(shmid, (void *)0, 0); |
|
241 // if (beer == (void *)(-1)) { |
|
242 // syslog(LOG_NOTICE, "shmat: %s", strerror(errno)); |
|
243 // } |
|
244 |
|
245 /* |
|
246 * Run the daemon |
229 * Run the daemon |
247 */ |
230 */ |
248 fclose(stdin); |
231 fclose(stdin); |
249 if (open("/dev/null", O_RDONLY) != 0) { |
232 if (open("/dev/null", O_RDONLY) != 0) { |
250 syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed"); |
233 syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed"); |
325 coolerA = 1; |
308 coolerA = 1; |
326 syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
309 syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
327 sendRCswitch(tmp2->address, 1); |
310 sendRCswitch(tmp2->address, 1); |
328 lcdupdate = TRUE; |
311 lcdupdate = TRUE; |
329 } |
312 } |
|
313 if (tmp1->update) { |
|
314 tmp1->update = FALSE; |
|
315 lcdupdate = TRUE; |
|
316 } |
330 old1 = tmp1->next; |
317 old1 = tmp1->next; |
331 tmp1 = old1; |
318 tmp1 = old1; |
332 old2 = tmp2->next; |
319 old2 = tmp2->next; |
333 tmp2 = old2; |
320 tmp2 = old2; |
334 if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) { |
321 if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) { |
339 } |
326 } |
340 if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) { |
327 if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) { |
341 coolerB = 1; |
328 coolerB = 1; |
342 syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
329 syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
343 sendRCswitch(tmp2->address, 1); |
330 sendRCswitch(tmp2->address, 1); |
|
331 lcdupdate = TRUE; |
|
332 } |
|
333 if (tmp1->update) { |
|
334 tmp1->update = FALSE; |
344 lcdupdate = TRUE; |
335 lcdupdate = TRUE; |
345 } |
336 } |
346 |
337 |
347 if (run && lcdupdate) { |
338 if (run && lcdupdate) { |
348 lcdPosition(lcdHandle, 0, 0); |
339 lcdPosition(lcdHandle, 0, 0); |