MIGRATION

Sun, 07 Apr 2024 20:26:37 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Apr 2024 20:26:37 +0200
changeset 666
48cc8868f9f4
parent 664
8adbc76fd122
child 668
4df4c8b17733
permissions
-rw-r--r--

Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.

644
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 Migration from wiringPi to PIGPIO.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 ==================================
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 WiringPi is unmaintained and replaced by pigpio. This will need large parts
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 of thermferm to be rewritten. It is also a good moment to replace the current
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 server protocol with json data and start sending data chaanges over
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 websockets.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 Some parts of the code can make use of direct kernel support, since kernel 4
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 there are lots of new modules. Fact is that thermferm is started in 2014,
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 that is 10 years ago.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 The current devices model is not very practical. We need to separate the parts
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 that don't need gpio out of it. All one-wire devices need their own driver
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 thread.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 Current threads.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 ----------------
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 These are the current running threads.
663
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
22 1. my_one_wire_loop.
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
23 2. my_devices_loop.
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
24 3. my_server_loop.
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
25 4. my_panel_loop.
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
26 5. my_simulator_loop (if enabled).
644
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 Steps to do.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 ------------
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 Try to read all temperature sensors at once. The kernel supports this now.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 The devices thread needs to use the collected temperatures.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 Read all ds2413 devices from sys/bus/w1. If output bits are set different
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 then send output values.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 Add pigpio library and make it testable by the configure script.
07cc86900473 Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
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: 644
diff changeset
41
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: 644
diff changeset
42 Flow 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: 644
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: 644
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: 644
diff changeset
45 States:
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: 644
diff changeset
46 1. Init state.
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: 644
diff changeset
47 2. Check for exit.
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: 644
diff changeset
48 Scan for devices. Add to one-wire 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: 644
diff changeset
49 3. Check for exit.
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: 644
diff changeset
50 Read all DS2413 devices programmed as input.
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: 644
diff changeset
51 4. Check for exit.
663
fa39f9c0e219 Updated MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents: 654
diff changeset
52 Read one temperture sensor from list and update.
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: 644
diff changeset
53 5. Check for exit.
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: 644
diff changeset
54 Check for missing devices not in one wire table.
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: 644
diff changeset
55 Goto 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: 644
diff changeset
56 6. Exit state.
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: 644
diff changeset
57
664
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
58
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
59
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
60 Flow thermferm.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
61 ---------------
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
62
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
63 Before:
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
64 Initialize all units.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
65 Publish DBirth
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
66 Publish Startup
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
67
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
68 States (nested):
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
69
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
70 1. Init.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
71 2. Check shutdown.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
72 Check run_pause.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
73 Wait for new minute.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
74 3. Update clock on display.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
75 Show room temp/humidity.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
76 4. If THB changed or 5 minutes passed publish NData.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
77 5. For units loop.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
78
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
79 1. Init.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
80 2. If air address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
81 3. If beer address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
82 4. If chiller address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
83 5. If door address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
84 6. If PSU address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
85 7. If unit->mode == UNITMODE_PROFILE
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
86 8. If unit->mode == UNITMODE_NONE
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
87 9. Usage counters
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
88 10. If light address
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
89 11. if ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_PROFILE)) // Temp control active
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
90 12. Update the LCD
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
91 13. Set unit->mqtt_flag |= MQTT_FLAG_DATA after 60 seconds
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
92 14. Publish what is needed.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
93 15. Handle alarms.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
94 16. End.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
95
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
96 6. Show LCD buffer.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
97 7. 60 seconds reset and actions.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
98 8. Keyboard check.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
99 9. Delay 100 mSec and goto 2.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
100 10. Done.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
101
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
102 After:
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
103 Stop all units.
8adbc76fd122 Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents: 663
diff changeset
104

mercurial