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.3.0

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.3.0
File Size Uploaded Provenance Actions
scietex_modbus_service-2.3.0.tar.gz 24.1 kB With provenance Details for scietex_modbus_service-2.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 41.5 kB

Release files / scietex_modbus_service-2.3.0.tar.gz

Download URL scietex_modbus_service-2.3.0.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aad83fc972d9eed5375c23b660583e306e80100547f12180ed2fcd61b9253c95
BLAKE2b-256 checksum
How to use checksums
6fae23c820d33719e4d6d402b1fb10d583e7222e25282334c3c1c318f907c07f
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 16, 2026.

Transparency log

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

Download URL scietex_modbus_service-2.3.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba3277473e5d4beb239399959430fdefa96bca3ad657ec8e39fd4bf077c73cab
BLAKE2b-256 checksum
How to use checksums
942f6b9c30ca6f4454e6bc08a89ba37372d839009a8f0f36340f4807ccf6a200
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 16, 2026.

Transparency log

Security for scietex.modbus-service 2.3.0

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.3.0.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 16, 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