Skip to main content

moat-lib-modbus

% start synopsis % start main

A sans-IO Modbus protocol core implementing the minimal subset used by moat.modbus: PDU encoding/decoding for function codes 1, 2, 3, 4, 5, 6, 15, 16, plus TCP (MBAP) and RTU framers with a client/server role flag, and an RTU-only monitor role for passive bus sniffing.

Stdlib only -- no pymodbus, no anyio.

% end synopsis

Design

The library is strictly sans-IO: it never opens a socket, touches a serial port, sleeps, waits, or spawns a task. Every component is a pure transform -- bytes in -> messages/PDUs out, messages in -> bytes out. The only mutable state permitted is a framer's internal byte accumulator. All real I/O stays in moat.modbus.

Role flag

The same function-code byte decodes to a request on a server and a response on a client. The role is therefore a constructor flag on the framer itself: FramerTCP(role) / FramerRTU(role) where role is True / "server" (decode incoming bytes as requests), False / "client" (decode as responses), or -- for RTU only -- "monitor" (passive bus sniffer; see below).

Monitor mode (RTU only)

FramerRTU("monitor") taps a live master/slave RTU line without participating in it. Sending is prohibited (buildFrame raises ModbusIOError). Frames are decoded as an alternating request/response sequence starting with a request; each decoded frame flips the expectation (queryable via expecting_request). Since the framer is sans-IO it cannot time the inter-frame gap, so the caller calls resetFrame() on an inter-frame timeout, which clears the accumulator and returns the framer to expecting a request -- covering both torn partial frames and silent slaves. Monitor mode is RTU-only; FramerTCP("monitor") is rejected.

% end main

Metadata

Release files for moat-lib-modbus 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-lib-modbus 0.0.2
File Size Uploaded
moat_lib_modbus-0.0.2.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-lib-modbus 0.0.2
File Interpreter ABI Platform
moat_lib_modbus-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / moat_lib_modbus-0.0.2.tar.gz

Download URL moat_lib_modbus-0.0.2.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
93ecac0db5dfcc9ad3d7dcddcfd50446d8a8589399389ca8fec81b4006d7af69
BLAKE2b-256 checksum
How to use checksums
b5cae4fb7d3ae7fb175e1aa7f17af8d725cee219af24d2b9c9c535dcb432c8cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / moat_lib_modbus-0.0.2-py3-none-any.whl

Download URL moat_lib_modbus-0.0.2-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3f5b1c0416707333e9f5ddb5d48e43d2a7f68d3fb26f1a9d11688e3a92c0978
BLAKE2b-256 checksum
How to use checksums
e71104935e65d23be783cf58e927c2bc9ea2c1325ea2726a9954daa46038dff5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page