Threaded version 0.7

This commit is contained in:
2026-10-06 23:50:02 -06:00
parent fe5dcbe715
commit 490c9bdc5b
21 changed files with 891 additions and 1010 deletions
+34 -51
View File
@@ -1,60 +1,43 @@
# Atom Modbus Library (`atMb`)
# atMb 0.6 — threaded communication and client statistics
CODESYS library with a native C engine for Modbus TCP client, RTU client and TCP
slave operation. Public namespace: `atMb`. No ModbusFB dependency is required.
This update moves TCP/RTU transaction progress and TCP server I/O into one shared
C worker thread. The worker also handles connection recovery between PLC scans.
The IEC task still selects/submits the next client request and exchanges slave
memory. One C worker serves the fixed pools; it is not a separate thread per device.
## Use the library
Start with [upgrade/build instructions](docs/BUILD-AND-USAGE.md), then read the
[user guide](docs/USER-GUIDE.md) and [API reference](docs/API-REFERENCE.md).
Open `library/CmpAtomModbus.library` in CODESYS, or install it using Library
Repository and reference it from your application. Keep its project title and
external C interface settings intact. The development target is Raspberry Pi
64 SL (ARM64), using CODESYS 3.5 SP22; runtime/target compatibility must be checked
when changing platforms. Read [the user guide](docs/USER-GUIDE.md) for examples
and [the API reference](docs/API-REFERENCE.md) for members and methods.
## Required upgrade
## Repository contents
Rebuild the C component as **0.4.0.0**, import `library/atMb-Threaded.export` into
a fresh CODESYS library project and embed the new `.so` for the device target.
The external function signature is unchanged, but new commands are required.
The new IEC wrapper checks capability version and rejects an older component.
This package contains updated source/export, not an IDE-compiled updated `.library`
or rebuilt ARM binaries. The previous files are retained under `backup/` only.
| Path | Purpose |
|---|---|
| `library/CmpAtomModbus.library` | Working CODESYS library file; edit IEC code here |
| `component-source/src/` | C protocol, client, serial and server implementation |
| `component-source/component/` | Active component frame, ABI interface and makefile |
| `component-source/tests/` | Host protocol and bridge tests |
| `ExtensionSDK/` | Supplied SDK required for component builds |
| `artifacts/arm64/libCmpAtomModbus.so` | Supplied ARM64 native binary |
| `docs/BUILD-AND-USAGE.md` | Native build and deployment instructions |
| `docs/USER-GUIDE.md` | Calling patterns, configuration and diagnostics |
| `docs/API-REFERENCE.md` | Detailed IEC reference based on the last working export |
| `docs/CLEANUP.md` | Removed files, preservation checks and update workflow |
| `docs/VALIDATION.md` | Validation scope |
| `SHA256SUMS.txt` | Current working-file snapshot checksums, excluding Git metadata |
## Changes
## Build on the Pi
- Worker defaults: 1 ms sleep, normal OS scheduling, 2 s per-context scan watchdog.
- Optional `atMb.Worker` FB sets CPU affinity, sleep interval and watchdog.
- Completion and read data stay latched until acknowledged; failed writes are not
replayed by the worker. IEC cyclic retries remain configurable via write holds.
- Server dirty tracking preserves remote writes until the PLC pulls them.
- Public diagnostics now use `out_errorCode` and `out_lastErrorCode`.
- `client.stats` aggregates every registered request's counters and timings.
- Both TCP and RTU clients show `OK:<successes>/Er:<errors>` like requests.
- Accurate worker transaction durations; timeout counts classify actual timeouts.
Run from the repository root:
## Files
```sh
sudo apt install build-essential m4 dos2unix python3
make -C component-source/component SDKDIR="$(realpath ExtensionSDK)" clean
make -C component-source/component SDKDIR="$(realpath ExtensionSDK)" all
make -C component-source test
```
- `component-source/`: protocol implementation, worker, component frame and tests.
- `ExtensionSDK/`: required SDK headers/macros/build support.
- `library/atMb-Threaded.export`: importable IEC source; no old embedded binary.
- `library/atMb-Threaded-Review.st`: readable export source.
- `docs/`: usage, ABI/worker notes, migration, validation and reference.
- `backup/`: original library/export/binaries for rollback, not the new release.
Native output: `component-source/component/out/libCmpAtomModbus.so`.
See the build guide before updating the embedded component. An ARM64 binary
cannot run on ARM32 or x86-64; build for each architecture and verify the SDK/runtime
combination. The supplied binary has not been proven byte-equivalent to this source.
## Update and review
Edit the IEC library in CODESYS. After significant IEC changes, export the current
objects and update the API reference against that export. Binary `.library` files
cannot be reviewed as ordinary text diffs. This snapshot intentionally contains no
old migration exports or generators that overwrite current IDE changes.
This ZIP retains the existing Git history and remote metadata. Cleanup changes
are uncommitted and unstaged. Review locally with `git status` and `git diff`,
then stage/commit when ready. No push is performed by this package.
Online-change qualification remains future work. Keep all native calls owned by
one IEC task. No new license is assigned to the supplied SDK/source files.
Host tests run with `make -C component-source test`. Physical PLC/RTU testing and
CODESYS IDE compilation remain required. Online-change qualification is future work;
use a full download for this structural update. Git changes are not committed/pushed.