thermferm/rdconfig.c

changeset 645
49eb753a958b
parent 615
33a5b63e86d7
child 666
48cc8868f9f4
equal deleted inserted replaced
644:07cc86900473 645:49eb753a958b
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014-2022 2 * Copyright (C) 2014-2024
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the mbsePi-apps 6 * This file is part of the mbsePi-apps
7 * 7 *
24 #include "thermferm.h" 24 #include "thermferm.h"
25 #include "pid.h" 25 #include "pid.h"
26 #include "futil.h" 26 #include "futil.h"
27 #include "xutil.h" 27 #include "xutil.h"
28 28
29 int debug = FALSE; 29 int debug = FALSE;
30 sys_config Config; /* System configuration */ 30 sys_config Config; /* System configuration */
31 extern pthread_mutex_t mutexes[5];
31 32
32 #define MY_ENCODING "utf-8" 33 #define MY_ENCODING "utf-8"
33 34
34 const char TEMPSTATE[3][8] = { "OK", "MISSING", "ERROR" }; 35 const char TEMPSTATE[3][8] = { "OK", "MISSING", "ERROR" };
35 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }; 36 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" };
399 xmlTextWriterEndElement(writer); // close FERMENTERS 400 xmlTextWriterEndElement(writer); // close FERMENTERS
400 } 401 }
401 402
402 if (Config.devices) { 403 if (Config.devices) {
403 xmlTextWriterStartElement(writer, BAD_CAST "DEVICES"); 404 xmlTextWriterStartElement(writer, BAD_CAST "DEVICES");
404 #ifdef HAVE_WIRINGPI_H 405 pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
405 piLock(LOCK_DEVICES);
406 #endif
407 for (device = Config.devices; device; device = device->next) { 406 for (device = Config.devices; device; device = device->next) {
408 xmlTextWriterStartElement(writer, BAD_CAST "DEVICE"); 407 xmlTextWriterStartElement(writer, BAD_CAST "DEVICE");
409 xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid); 408 xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid);
410 xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type]); 409 xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type]);
411 xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction]); 410 xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction]);
419 xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse); 418 xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse);
420 xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment); 419 xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment);
421 xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp); 420 xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp);
422 xmlTextWriterEndElement(writer); // close DEVICE 421 xmlTextWriterEndElement(writer); // close DEVICE
423 } 422 }
424 #ifdef HAVE_WIRINGPI_H 423 pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
425 piUnlock(LOCK_DEVICES);
426 #endif
427 xmlTextWriterEndElement(writer); // close DEVICES 424 xmlTextWriterEndElement(writer); // close DEVICES
428 } 425 }
429 426
430 #ifdef USE_SIMULATOR 427 #ifdef USE_SIMULATOR
431 if (Config.simulators) { 428 if (Config.simulators) {

mercurial