Files
Codesys-Library-Atom-Modbus/docs/WORKER-ABI.md
T
2026-10-06 23:50:07 -06:00

38 lines
2.2 KiB
Markdown

# Worker ABI and lifecycle
The 16-argument atMbCall_cext ABI and its signature are retained. Calls are serialized
by the lifecycle mutex and priority-inheritance engine mutex. The worker accesses
fixed C contexts only. Calls may wait briefly for the engine mutex; no claim of
hard real-time maximum latency is made for OS/serial-driver operations.
New commands:
| Command | Purpose | Parameters / result |
|---|---|---|
| 12 | Client transaction timing | Normal handle; status[21] duration ms, [22] successful-read age ms (saturated UDINT); other client status fields retained |
| 40 | Configure/start global worker | startAddress=CPU+1 (0 inherited mask), connectTimeoutMs=interval 1..20, responseTimeoutMs=watchdog 100..60000 |
| 41 | Worker capabilities/status | No start side effect; available even before worker starts |
Worker status words: [0] capability 0x00040000; [1] running; [2] pthread error;
[3] configured CPU+1, 0 inherited mask; [4] interval ms; [5] watchdog ms;
[6:7] cycle counter low/high; [8:9] monotonic heartbeat low/high. Remaining words zero.
Error 260 reports worker initialization or CPU-affinity failure. Invalid settings
return 1. Invalid settings do not change current affinity/timing.
Client command 5 and server command 34 now refresh the context's scan lease and
snapshot state; they do not perform socket reads/writes. All deadline times are
sourced from CLOCK_MONOTONIC; the ABI nowMs argument is retained but ignored.
Command 6 rejects a new transaction until completion is acknowledged with command
10. Completion data cannot be overwritten by another request before acknowledgment.
Worker shutdown sets a stop flag, releases the mutex, joins the thread, then
closes contexts. Generation-tagged handles prevent access to released slots.
Watchdog expiry closes transport while preserving the slot and terminal result;
refresh resumes it. No worker thread is restarted repeatedly on link failure;
existing TCP/RTU state machines retry within it.
Socket progress is nonblocking. Socket close/configuration calls may also occur
synchronously for explicit close/reconfigure commands. These and serial ioctls are
OS calls, so target execution-time measurement remains necessary. The worker uses
normal SCHED_OTHER, not a high-priority busy loop.