Wed, 03 Apr 2024 12:14:45 +0200
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.
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 State table macro's |
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 | |
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 | #ifndef 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
|
6 | #define 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
|
7 | |
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 | #define SM_DECL(proc,name) \ |
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 | int proc(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
|
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 | int sm_success=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
|
12 | char *sm_name=name; |
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 | |
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 | #define SM_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:
diff
changeset
|
15 | enum { |
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 | |
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 | #define SM_NAMES \ |
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 | } sm_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:
diff
changeset
|
19 | char * sm_sname[] = { |
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 | |
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
|
21 | #define 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
|
22 | }; |
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 | |
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 | #define SM_START(x) \ |
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 | sm_state=x;\ |
655
780cc08df263
State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
26 | if (debug)\ |
780cc08df263
State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
27 | syslog(LOG_NOTICE, "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \ |
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
|
28 | while (!sm_success) switch (sm_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:
diff
changeset
|
29 | {\ |
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 | default: syslog(LOG_WARNING, "Statemachine %s error: state=%d",sm_name,sm_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:
diff
changeset
|
31 | sm_success=-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
|
32 | |
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
|
33 | #define SM_STATE(x) \ |
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 | 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
|
35 | case x: |
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 | |
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
|
37 | #define 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
|
38 | }\ |
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 | #define 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
|
41 | return (sm_success != 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
|
42 | } |
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 | #define SM_PROCEED(x) \ |
655
780cc08df263
State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
45 | if (x != sm_state && debug) {\ |
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
|
46 | syslog(LOG_NOTICE, "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\ |
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
|
47 | }\ |
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
|
48 | sm_state=x; 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
|
49 | |
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
|
50 | #define SM_SUCCESS \ |
655
780cc08df263
State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
51 | if (debug)\ |
780cc08df263
State machine logging only when debug is active.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
52 | syslog(LOG_NOTICE, "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\ |
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
|
53 | sm_success=1; 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
|
54 | |
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
|
55 | #define 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
|
56 | syslog(LOG_WARNING, "SM (%s): %s => Error", sm_name, sm_sname[sm_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:
diff
changeset
|
57 | sm_success=-1; 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
|
58 | |
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
|
59 | #endif |