thermferm/one-wire.c

Sun, 05 May 2024 17:24:54 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 05 May 2024 17:24:54 +0200
changeset 730
6eba006ed8f5
parent 728
da038d0bed04
permissions
-rw-r--r--

Much faster shutdown of the websocket service.

654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * @brief One-wire devices
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Copyright (C) 2024
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This is free software; you can redistribute it and/or modify it
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * under the terms of the GNU General Public License as published by the
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * Free Software Foundation; either version 2, or (at your option) any
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * later version.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * mbsePi-apps is distributed in the hope that it will be useful, but
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * General Public License for more details.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with MBSE BBS; see the file COPYING. If not, write to the Free
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
655
780cc08df263 State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
21 extern int debug;
780cc08df263 State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
22
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 #include "thermferm.h"
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include "statetbl.h"
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include "one-wire.h"
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
26 #include "devices.h"
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
27 #include "delay.h"
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
28 #include "websocket.h"
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
29 #include "futil.h"
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 #include "xutil.h"
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
32 #define W1_TEMP_RESOLUTION 12
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
33
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 extern sys_config Config;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 extern pthread_mutex_t mutexes[5];
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
37 extern const char DEVPRESENT[4][6];
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
38
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 int my_one_wire_state = 0;
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
41 int my_one_wire_shutdown = 0;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 w1_list *w1_devices = NULL;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 static int one_wire(void);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
47
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
48 /*
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
49 * Return json data for one device.
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
50 */
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
51 char *one_wire_json(w1_list *dev_w1)
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
52 {
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
53 char *payload;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
54 char vbuf[64];
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
55
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
56 payload = xstrcpy((char *)"{\"address\":\"");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
57 payload = xstrcat(payload, dev_w1->address);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
58 payload = xstrcat(payload, (char *)"\",\"family\":\"");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
59 payload = xstrcat(payload, dev_w1->family);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
60 payload = xstrcat(payload, (char *)"\",\"present\":\"");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
61 payload = xstrcat(payload, (char *)DEVPRESENT[dev_w1->present]);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
62 payload = xstrcat(payload, (char *)"\",\"value\":");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
63 snprintf(vbuf, 63, "%d", dev_w1->value);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
64 payload = xstrcat(payload, vbuf);
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
65 payload = xstrcat(payload, (char *)",\"resolution\":");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
66 snprintf(vbuf, 63, "%d", dev_w1->resolution);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
67 payload = xstrcat(payload, vbuf);
694
0f1ef5e6418e Version 0.9.19a3. Fixed segfault in onewire temperature measurement. Fixed json error in onewire device.
Michiel Broek <mbroek@mbse.eu>
parents: 693
diff changeset
68 payload = xstrcat(payload, (char *)",\"timestamp\":");
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
69 snprintf(vbuf, 63, "%ld", (long)dev_w1->timestamp);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
70 payload = xstrcat(payload, vbuf);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
71 payload = xstrcat(payload, (char *)"}");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
72
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
73 return payload;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
74 }
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
75
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
76
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
77 void one_wire_ws(void)
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
78 {
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
79 bool comma = false;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
80 char *payload = NULL, *payloadu = NULL;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
81 w1_list *dev_w1;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
82
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
83 payload = xstrcpy((char *)"{\"type\":\"onewire\",\"metric\":[");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
84 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
85 if (comma)
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
86 payload = xstrcat(payload, (char *)",");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
87 payloadu = one_wire_json(dev_w1);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
88 payload = xstrcat(payload, payloadu);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
89 comma = true;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
90 free(payloadu);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
91 payloadu = NULL;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
92 }
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
93 payload = xstrcat(payload, (char *)"]}");
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
94 ws_broadcast(payload);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
95 free(payload);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
96 payload = NULL;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
97 }
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
98
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
99
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
100
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 void *my_one_wire_loop(void *threadid)
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 {
724
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
103 pid_t pid = gettid();
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
104
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 my_one_wire_state = 1;
724
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
106 syslog(LOG_NOTICE, "Thread my_one_wire_loop started, pid=%d", pid);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 /*
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 * Run the state machine
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 one_wire();
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 /*
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 * Remove the dynamic tables.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 syslog(LOG_NOTICE, "Thread my_one_wire_loop stopped");
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 my_one_wire_state = 0;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 return 0;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 SM_DECL(one_wire,(char *)"one-wire")
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 SM_STATES
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
127 ScanNew,
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
128 ScanDel,
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
129 Read2413,
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
130 ReadTemp,
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
131 Missing,
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
132 Websocket
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 SM_NAMES
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
134 (char *)"ScanNew",
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
135 (char *)"ScanDel",
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
136 (char *)"Read2413",
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
137 (char *)"ReadTemp",
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
138 (char *)"Missing",
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
139 (char *)"Websocket"
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 SM_EDECL
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
142 int found, i, rc, value, conv_time;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 FILE *fp;
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
144 devices_list *device;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 w1_list *dev_w1, *n_w1, *cur_w1 = NULL;
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
146 char buffer[25], w1type[10], *devfile = NULL;
662
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
147 uint8_t state, output, newval;
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
148 bool changed;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
150 SM_START(ScanNew)
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
152 SM_STATE(ScanNew)
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
154 if (my_one_wire_shutdown) {
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 SM_SUCCESS;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
158 changed = false;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 /*
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 * Scan for current one-wire devices.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 fp = fopen("/sys/devices/w1_bus_master1/w1_master_slaves", "r");
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 if (fp == NULL) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 syslog(LOG_NOTICE, "No w1_bus_master: %s", strerror(errno));
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 SM_ERROR;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 while ((fgets(buffer, 25, fp))) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 buffer[strlen(buffer)-1] = '\0';
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 strncpy(w1type, buffer, 2);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 w1type[2] = '\0';
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 /*
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 * Check if device is known and already detected.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 if ((strcmp(w1type, (char *)"3a") == 0) || (strcmp(w1type, (char *)"10") == 0) ||
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 (strcmp(w1type, (char *)"22") == 0) || (strcmp(w1type, (char *)"28") == 0) ||
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 (strcmp(w1type, (char *)"3b") == 0) || (strcmp(w1type, (char *)"42") == 0)) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 found = FALSE;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 if (strcmp(dev_w1->address, buffer) == 0) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 found = TRUE;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 if (dev_w1->present != DEVPRESENT_YES) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 syslog(LOG_NOTICE, "One-wire device %s is back", buffer);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 pthread_mutex_lock(&mutexes[LOCK_ONE_WIRE]);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 dev_w1->present = DEVPRESENT_YES;
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
186 dev_w1->resolution = 0; /* Might be wrong, so reset */
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
187 dev_w1->timestamp = time(NULL);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 pthread_mutex_unlock(&mutexes[LOCK_ONE_WIRE]);
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
189 changed = true;
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 712
diff changeset
190 device_present(dev_w1->address, DEVPRESENT_YES);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 break;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 if (found == FALSE) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 syslog(LOG_NOTICE, "One-wire device %s add new", buffer);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 n_w1 = (w1_list *)malloc(sizeof(w1_list));
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 n_w1->next = NULL;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 n_w1->address = xstrcpy(buffer);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 strncpy(n_w1->family, buffer, 2);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 n_w1->family[2] = '\0';
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 n_w1->present = DEVPRESENT_YES;
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
203 n_w1->value = (strcmp(w1type, (char *)"3a") == 0) ? 3:-1;
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
204 n_w1->resolution = 0;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 n_w1->timestamp = time(NULL);
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
206 changed = true;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 pthread_mutex_lock(&mutexes[LOCK_ONE_WIRE]);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 if (w1_devices == NULL) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 w1_devices = n_w1;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 cur_w1 = w1_devices; /* Point to first device */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 } else {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 if (dev_w1->next == NULL) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 dev_w1->next = n_w1;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 break;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 pthread_mutex_unlock(&mutexes[LOCK_ONE_WIRE]);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 }
670
6c62e99ade00 Stop logging ghost one-wire devices.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
222 } else if (strcmp(w1type, (char *)"00")) {
692
6d97eb820cc1 Fixed two compiler warnings on arm platform
Michiel Broek <mbroek@mbse.eu>
parents: 690
diff changeset
223 syslog(LOG_NOTICE, "One-wire device %ld %s unknown", (long)strlen(buffer), buffer);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 fclose(fp);
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
227 SM_PROCEED(ScanDel);
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
228
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
229 SM_STATE(ScanDel)
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
230
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
231 if (my_one_wire_shutdown) {
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
232 SM_SUCCESS;
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
233 }
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
234
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
235 /*
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
236 * Scan from the linked list if all devices are still present.
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
237 */
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
238 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
239 devfile = xstrcpy((char *)"/sys/bus/w1/devices/");
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
240 devfile = xstrcat(devfile, dev_w1->address);
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
241 devfile = xstrcat(devfile, (char *)"/uevent");
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
242 if (file_exist(devfile, R_OK) && (dev_w1->present == DEVPRESENT_YES)) {
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
243 /*
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
244 * Gone missing
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
245 */
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
246 syslog(LOG_NOTICE, "One-wire device %s is missing", dev_w1->address);
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
247 pthread_mutex_lock(&mutexes[LOCK_ONE_WIRE]);
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
248 dev_w1->present = DEVPRESENT_NO;
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
249 dev_w1->timestamp = time(NULL);
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
250 pthread_mutex_unlock(&mutexes[LOCK_ONE_WIRE]);
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
251 changed = true;
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 712
diff changeset
252 device_present(dev_w1->address, DEVPRESENT_NO);
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
253 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
254 free(devfile);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
255 devfile = NULL;
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
256 }
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
257
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
258 mDelay(40);
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
259 SM_PROCEED(Read2413);
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
260
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
261 SM_STATE(Read2413)
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
262
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
263 if (my_one_wire_shutdown) {
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
264 SM_SUCCESS;
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
265 }
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
266
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
267 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
268 if (strcmp(dev_w1->family, "3a") == 0) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
269 for (i = 0; i < 2; i++) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
270 for (device = Config.devices; device; device = device->next) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
271 if ((strcmp(dev_w1->address, device->address) == 0) && (device->subdevice == i) && (device->direction == DEVDIR_IN_BIN)) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
272 /*
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
273 * First make sure that this device is configured as input
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
274 * to drive the output high. Fix if programmed as output.
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
275 */
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
276 if ((rc = read_w1(device->address, (char *)"state")) >= 0) {
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
277 state = (unsigned int)rc;
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
278 output = ((state & 0x02) >> 1) + ((state & 0x08) >> 2); /* Both latch states */
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
279 if ((i == 0) && ((state & 0x02) == 0)) { /* Fix A side */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
280 syslog(LOG_NOTICE, "One-wire device %s-%d out %02x -> %02x", dev_w1->address, i, output, output | 0x01);
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
281 output |= 0x01;
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
282 write_w1(device->address, (char *)"output", output);
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
283 mDelay(10);
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
284 if ((rc = read_w1(device->address, (char *)"state")) >= 0) /* Read PIO again */
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
285 state = (unsigned int)rc;
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
286 }
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
287 if ((i == 1) && ((state & 0x08) == 0)) { /* Fix B side */
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
288 syslog(LOG_NOTICE, "One-wire device %s-%d out %02x -> %02x", dev_w1->address, i, output, output | 0x02);
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
289 output |= 0x02;
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
290 write_w1(device->address, (char *)"output", output);
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
291 mDelay(10);
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
292 if ((rc = read_w1(device->address, (char *)"state")) >= 0) /* Read PIO again */
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
293 state = (unsigned int)rc;
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
294 }
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
295
662
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
296 newval = ((state & 0x04) >> 1) + (state & 0x01);
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
297 if (newval != dev_w1->value) {
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
298 syslog(LOG_NOTICE, "One-wire device %s-%d in %02x value %d => %d", dev_w1->address, i, state, dev_w1->value, newval);
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
299 dev_w1->value = newval;
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
300 dev_w1->timestamp = time(NULL);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
301 changed = true;
662
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
302 }
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
303
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
304 // pthread_mutex_lock(&mutexes[LOCK_DEVICES]);
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
305 /*
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
306 * Read PIOA or PIOB pin state bits
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
307 */
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
308 if (device->subdevice == 0)
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
309 device->value = (state & 0x01) ? 0 : 1;
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
310 else if (device->subdevice == 1)
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
311 device->value = (state & 0x04) ? 0 : 1;
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
312 device->timestamp = time(NULL);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
313 // pthread_mutex_unlock(&mutexes[LOCK_DEVICES]);
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
314 }
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
315 mDelay(20);
671
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
316 } else if ((strcmp(dev_w1->address, device->address) == 0) && (device->subdevice == i) && (device->direction == DEVDIR_OUT_BIN)) {
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
317 /*
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
318 * Sync output state
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
319 */
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
320 if ((rc = read_w1(device->address, (char *)"state")) >= 0) {
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
321 state = (unsigned int)rc;
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
322 newval = output = (state & 0x01) + ((state & 0x04) >> 1);
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
323
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
324 if (device->subdevice == 0) {
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
325 newval = (newval & 0xfe);
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
326 newval |= (device->value) ? 0x00 : 0x01;
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
327 } else if (device->subdevice == 1) {
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
328 newval = (newval & 0xfd);
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
329 newval |= (device->value) ? 0x00 : 0x02;
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
330 }
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
331
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
332 if (output != newval) {
674
6cabc02f4c8d Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 672
diff changeset
333 if ((write_w1(dev_w1->address, (char *)"output", newval)) == 0) {
671
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
334 syslog(LOG_NOTICE, "One-wire device %s-%d out %02x -> %02x", dev_w1->address, i, output, newval);
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
335 dev_w1->value = newval;
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
336 dev_w1->timestamp = time(NULL);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
337 changed = true;
671
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
338 }
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
339 }
b2e2cbb13cb3 Finished one-wire ds2413 output
Michiel Broek <mbroek@mbse.eu>
parents: 670
diff changeset
340 }
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
341 }
657
38162f374842 Read ds2413 moved to one-wire thread. Only reprogram if it is an input and programmed as output.
Michiel Broek <mbroek@mbse.eu>
parents: 656
diff changeset
342 } /* for (device = Config.devices; ... */
656
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
343 }
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
344 }
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
345 }
ca47c742a25d One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents: 655
diff changeset
346
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
347 mDelay(40);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
348 SM_PROCEED(ReadTemp);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
350 SM_STATE(ReadTemp)
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
352 if (my_one_wire_shutdown) {
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 SM_SUCCESS;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 /*
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 * cur_w1 points to the next not handled device.
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 */
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 if (cur_w1 != NULL) {
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360
690
3a5b019e9acc Better handling of a removed DS18B20 temperature sensor.
Michiel Broek <mbroek@mbse.eu>
parents: 674
diff changeset
361 if (((strcmp(cur_w1->family, (char *)"10") == 0) || (strcmp(cur_w1->family, (char *)"22") == 0) || (strcmp(cur_w1->family, (char *)"28") == 0) ||
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
362 (strcmp(cur_w1->family, (char *)"3b") == 0) || (strcmp(cur_w1->family, (char *)"42") == 0)) && (cur_w1->present == DEVPRESENT_YES)) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
363
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
364 /*
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
365 * Check and correct resolution. Only do this for new sensors
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
366 * or known sensors that are plugged in again.
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
367 */
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
368 if (cur_w1->resolution != W1_TEMP_RESOLUTION) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
369 devfile = xstrcpy((char *)"/sys/bus/w1/devices/");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
370 devfile = xstrcat(devfile, cur_w1->address);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
371 devfile = xstrcat(devfile, (char *)"/resolution");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
372 if ((fp = fopen(devfile, "r+"))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
373 if ((fgets(buffer, 25, fp))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
374 sscanf(buffer, "%d", &value);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
375 /* If device is removed, value is negative (errno?) */
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
376 if ((value > 0) && (value != W1_TEMP_RESOLUTION)) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
377 syslog(LOG_NOTICE, "One-wire device %s set resolution from %d to %d", cur_w1->address, value, W1_TEMP_RESOLUTION);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
378 fseek(fp, 0L, SEEK_SET);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
379 sprintf(buffer, "%d", W1_TEMP_RESOLUTION);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
380 fputs(buffer, fp);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
381 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
382 cur_w1->resolution = W1_TEMP_RESOLUTION;
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
383 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
384 fclose(fp);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
385 } else {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
386 syslog(LOG_NOTICE, "One-wire device %s open: %s", cur_w1->address, strerror(errno));
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
387 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
388 free(devfile);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
389 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
390
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
391 /*
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
392 * Set conversion wait time. Skip this??
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
393 */
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
394 conv_time = 760;
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
395 devfile = xstrcpy((char *)"/sys/bus/w1/devices/");
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
396 devfile = xstrcat(devfile, cur_w1->address);
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
397 devfile = xstrcat(devfile, (char *)"/conv_time");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
398 if ((fp = fopen(devfile, "r"))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
399 if ((fgets(buffer, 25, fp))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
400 sscanf(buffer, "%d", &conv_time);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
401 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
402 fclose(fp);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
403 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
404 free(devfile);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
405
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
406 /*
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
407 * Read temperature for one sensor.
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
408 * Bulk read does not work for unknown reason.
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
409 * It may be because there are also DS2413 devices.
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
410 */
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
411 devfile = xstrcpy((char *)"/sys/bus/w1/devices/");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
412 devfile = xstrcat(devfile, cur_w1->address);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
413 devfile = xstrcat(devfile, (char *)"/temperature");
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
414 if ((fp = fopen(devfile, "r"))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
415 mDelay(conv_time);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
416 if ((fgets(buffer, 25, fp))) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
417 sscanf(buffer, "%d", &value);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
418 if (cur_w1->value != value) {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
419 cur_w1->timestamp = time(NULL);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
420 changed = true;
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
421 if (debug)
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
422 syslog(LOG_NOTICE, "One-wire device %s temperature read %d => %d", cur_w1->address, cur_w1->value, value);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
423 }
728
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
424 cur_w1->value = value; /* devices.c will pick this up */
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
425 } else {
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
426 syslog(LOG_NOTICE, "One-wire device %s temperature read error", cur_w1->address);
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
427 }
da038d0bed04 Version 0.9.20a1. Analyse threads cpu usage. One-wire added a resolution flag to prevent continuous resolution checks, now only for new sensors and replugged known sensors. Added two 40 sSec delays in the state machine. In the panel thread moved a few locks so these expensive calls are called only when needed.
Michiel Broek <mbroek@mbse.eu>
parents: 724
diff changeset
428 fclose(fp);
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
429 } else {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
430 syslog(LOG_NOTICE, "One-wire device %s open: %s", cur_w1->address, strerror(errno));
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
431 }
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
432 free(devfile);
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
433 devfile = NULL;
690
3a5b019e9acc Better handling of a removed DS18B20 temperature sensor.
Michiel Broek <mbroek@mbse.eu>
parents: 674
diff changeset
434 } /* if temperature sensor and present */
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
436 for (;;) {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
437 if (cur_w1->next != NULL) {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
438 cur_w1 = cur_w1->next;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
439 } else {
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
440 cur_w1 = w1_devices;
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
441 }
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
442 if ((strcmp(cur_w1->family, (char *)"10") == 0) || (strcmp(cur_w1->family, (char *)"22") == 0) || (strcmp(cur_w1->family, (char *)"28") == 0) ||
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
443 (strcmp(cur_w1->family, (char *)"3b") == 0) || (strcmp(cur_w1->family, (char *)"42") == 0))
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
444 break;
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 } else {
662
56c72393ca26 One-wire tread more relaxed logging.
Michiel Broek <mbroek@mbse.eu>
parents: 661
diff changeset
448 mDelay(750);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 SM_PROCEED(Missing);
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 SM_STATE(Missing)
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454
660
a28ef4d9afa4 Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents: 659
diff changeset
455 if (my_one_wire_shutdown) {
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 SM_SUCCESS;
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 }
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458
693
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
459 SM_PROCEED(Websocket);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
460
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
461 SM_STATE(Websocket)
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
462
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
463 for (i = 0; i < 10; i++) {
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
464 if (my_one_wire_shutdown) {
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
465 SM_SUCCESS;
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
466 }
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
467
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
468 mDelay(100);
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
469 if (changed && i == 5)
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
470 one_wire_ws();
3518c07737d8 Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents: 692
diff changeset
471 }
659
bfab45f4d5cd Added state to scan vanished one-wire devices. Update devices if a one-wire device returns on the bus.
Michiel Broek <mbroek@mbse.eu>
parents: 657
diff changeset
472 SM_PROCEED(ScanNew);
654
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 SM_END
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 SM_RETURN
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476
e981d0185485 Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477

mercurial