Tue, 07 May 2024 14:11:31 +0200
Save one devices loop when handling a 2413 device.
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 |
668
4df4c8b17733
Upgraded MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents:
664
diff
changeset
|
6 | server protocol with json data and start sending data changes over |
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
|
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 |
668
4df4c8b17733
Upgraded MIGRATION document.
Michiel Broek <mbroek@mbse.eu>
parents:
664
diff
changeset
|
15 | thread. Is done. |
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
|
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 | 22 | 1. my_one_wire_loop. |
23 | 2. my_devices_loop. | |
24 | 3. my_server_loop. | |
25 | 4. my_panel_loop. | |
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 | |
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:
725
diff
changeset
|
29 | After one day: |
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:
725
diff
changeset
|
30 | |
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:
725
diff
changeset
|
31 | root 9795 1 9795 3 7 May04 ? 00:29:27 /usr/bin/thermferm Total |
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:
725
diff
changeset
|
32 | root 9795 1 9796 0 7 May04 ? 00:00:09 /usr/bin/thermferm mqtt ? |
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:
725
diff
changeset
|
33 | root 9795 1 9797 0 7 May04 ? 00:00:01 /usr/bin/thermferm Websocket |
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:
725
diff
changeset
|
34 | root 9795 1 9798 2 7 May04 ? 00:19:09 /usr/bin/thermferm my_one_wire_loop |
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:
725
diff
changeset
|
35 | root 9795 1 9799 0 7 May04 ? 00:04:43 /usr/bin/thermferm my_devices_loop started |
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:
725
diff
changeset
|
36 | root 9795 1 9800 0 7 May04 ? 00:00:00 /usr/bin/thermferm my_server_loop |
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:
725
diff
changeset
|
37 | root 9795 1 9801 0 7 May04 ? 00:04:45 /usr/bin/thermferm my_panel_loop |
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:
725
diff
changeset
|
38 | |
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
|
39 | |
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 | 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
|
41 | ------------ |
07cc86900473
Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
07cc86900473
Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | 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
|
44 | 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
|
45 | 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
|
46 | 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
|
47 | |
07cc86900473
Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | |
07cc86900473
Added MIGRATION document. Trying to drop usleep() call to replace by nanosleep(). Some code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | 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
|
50 | |
725 | 51 | To see each thread usage: ps -eLf | grep thermferm |
664
8adbc76fd122
Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents:
663
diff
changeset
|
52 | |
8adbc76fd122
Version 0.9.17a3. Prepare for thermferm state tables.
Michiel Broek <mbroek@mbse.eu>
parents:
663
diff
changeset
|
53 |