Skip to main content

scietex.modbus_service

scietex.modbus_service is a scietex.service worker that runs the serial-to-TCP Modbus gateway from scietex.hal.serial. It bridges a serial RS485 bus to TCP/IP: TCP clients speak plain Modbus/TCP, and the gateway routes each request to the right device on the bus by device id.

The worker is a long-running daemon. It owns one serial port and one TCP listener, both built once at startup from modbus.yml and torn down on shutdown. Configuration can also be pushed at runtime through the framework's remote-config channel, but the gateway itself is restart-required — see Remote configuration.

Python ≥ 3.10 · License: MIT

Documentation

Installation

pip install scietex.modbus_service

This pulls in scietex.hal.serial (the gateway core) and scietex.service[valkey] (the worker framework and its Valkey transport).

Quick start

1. Write a configuration file

The service reads modbus.yml from a modbus/ subdirectory of its config directory. Create it by hand, or let the service generate defaults on first run. The file is the bootstrap layer of a four-layer merge: constructor defaults < modbus.yml < the framework's config.yml snapshot < the remote modbus section. Each layer is a field-level patch — a key absent from a layer inherits the layer below, null clears it back to the constructor default, and a value sets it:

serial:
  port: /dev/ttyUSB0
  baudrate: 9600
  bytesize: 8
  parity: N
  stopbits: 1
  timeout: null
host: 0.0.0.0
port: 502
default_framer: RTU
devices:
  1:
    framer: RTU
  2:
    framer: ASCII
allow_unknown_devices: false
bus_retries: 0

port at the top level is the TCP listen port; serial.port is the serial device path. They are unrelated — do not conflate them.

2. Run the service

start-modbus-service --conf-dir /etc/scietex

The service resolves its config directory automatically when --conf-dir is omitted (see Configuration). It runs in the foreground until it receives SIGINT or SIGTERM.

3. Point a Modbus/TCP client at it

Connect to host:port and issue normal Modbus/TCP requests, using the target device id as the unit id. No special protocol is required.

Configuration at a glance

The defaults below are the constructor (L0) values: a field absent from every layer, or explicitly cleared with null, resolves to the value shown.

Setting Default Meaning
serial.port /dev/ttyUSB0 Serial device path
serial.baudrate 9600 Bus baud rate
host / port 0.0.0.0 / 502 TCP bind address and port
default_framer RTU Framer for devices without an explicit entry
devices {} Per-device routing table, keyed by device id
allow_unknown_devices false Route unknown ids with the default framer
bus_retries 0 Retry count for bus transactions

Full field reference: Configuration.

Container

A Containerfile is included. It installs the released package from PyPI (selected by the VERSION build arg), runs as a non-root appuser in the dialout group, mounts /config, and sets SCIETEX_CONFIG_DIR=/config:

podman build --build-arg VERSION=2.1.0 -t scietex-modbus-service .
podman run --rm \
  --device /dev/ttyUSB0 \
  --cap-add NET_BIND_SERVICE \
  -v ./config:/config \
  scietex-modbus-service

Port 502 is privileged — binding it needs --cap-add NET_BIND_SERVICE, or override the port in modbus.yml. See Deployment for details.

Development

Dependencies are managed with uv; checks and tests run through tox:

uv sync --all-extras
uv run tox                    # format, lint, type, py314
uv run tox -e py314           # tests only

See AGENTS.md for the full toolchain and repo conventions.

Metadata

Release files for scietex.modbus-service 2.6.1

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

Source distribution (sdist)

Source distribution for scietex.modbus-service 2.6.1
File Size Uploaded Provenance Actions
scietex_modbus_service-2.6.1.tar.gz 27.3 kB With provenance Details for scietex_modbus_service-2.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scietex.modbus-service 2.6.1
File Interpreter ABI Platform Actions
scietex_modbus_service-2.6.1-py3-none-any.whl Python 3 none any Details for scietex_modbus_service-2.6.1-py3-none-any.whl

Total release size: 47.5 kB

Release files / scietex_modbus_service-2.6.1.tar.gz

Download URL scietex_modbus_service-2.6.1.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f88a5965d5266756e9b8b25077ca1a77f97321a57a2f48bfdef0133037124f99
BLAKE2b-256 checksum
How to use checksums
a473a2ae1f557902f9e97d3ddb7a5c2da1b12fdc592c9cda55c56070b1faf6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / scietex_modbus_service-2.6.1-py3-none-any.whl

Download URL scietex_modbus_service-2.6.1-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dee37c9b224761a850302e13efc71df11e1975bc5eb9edc2ce24df96953a52e
BLAKE2b-256 checksum
How to use checksums
e63247a0179bb21bad364c13faf5c2224665de17f11c3695ac86b93d210c4478
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for scietex.modbus-service 2.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scietex_modbus_service-2.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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