Tags: wlcrs/tmodbus
Tags
Add on_connection_lost callback to detect socket drops immediately (#42) Expose an on_connection_lost callback so consumers can react the moment a socket drops, rather than waiting for the next request to fail. This mirrors pymodbus's trace_connect(False), firing straight from the asyncio protocol's connection_lost. - Add the callback attribute and a safe-invocation helper on AsyncBaseTransport (errors raised by the callback are logged, never break transport teardown). - Wire it into every base transport's _on_connection_lost (TCP, RTU, ASCII, RTU-over-TCP). - Forward it through AsyncSmartTransport to the base transport. Unlike on_reconnected, it works even when auto_reconnect is disabled. - Thread it through the create_async_* client factory helpers. Claude-Session: https://claude.ai/code/session_01XUgJ5AXGqf5orSNUXtYigk Co-authored-by: Claude <[email protected]>
Fix register offset tracking in OrderAwareStruct for sub-register fie… …lds (#4) When a register is built from fields smaller than a register (for example two int8 values packed as ">bbI"), OrderAwareStruct advanced its write position by the last field's length instead of the accumulated register length. With word or byte reordering enabled, this spliced the following multi-register value at the wrong offset, producing corrupted bytes on the wire. Pack and unpack apply the same transform, so round-trips still succeeded and hid the issue, but the data sent to a device was wrong. Advance by the accumulated register length, and add regression tests for formats that build a register from multiple sub-register tokens.
PreviousNext