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.1.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.1.1
File Size Uploaded Provenance Actions
scietex_modbus_service-2.1.1.tar.gz 17.8 kB With provenance Details for scietex_modbus_service-2.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 30.0 kB

Release files / scietex_modbus_service-2.1.1.tar.gz

Download URL scietex_modbus_service-2.1.1.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0cc9435b6928d04b53eb4ebb01cae9847ed328d99226ad30946d9dfedf421ee0
BLAKE2b-256 checksum
How to use checksums
1caac1d2713bfa58c833211cadc7310786a8df67413b1e0d1437abee0e275e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

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

Download URL scietex_modbus_service-2.1.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ff70eaaf69240c871e6cadb6f4b6be9770288a7e08db6431000b8c0784b2d5c
BLAKE2b-256 checksum
How to use checksums
c36ba106b51cdc7428bf0271f0745f079dfc71b6a4def149c948573310f4151c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

Security for scietex.modbus-service 2.1.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.1.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 9, 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