ModbusIM - Modbus Device Simulator
A Python package for simulating Modbus RTU/ASCII/TCP devices for testing and development purposes.
[](https://opensource.org/licenses/Apache 2.0 )
Features
- Simulate Modbus RTU/ASCII/TCP devices
- Support for all standard Modbus function codes
- Easy-to-use CLI interface
- Programmatic API for integration with tests
- Configurable device behavior
- Docker support for easy deployment
Installation
Using pip
pip install modbusim
Using Poetry (for development)
git clone https://github.com/yourusername/modbusim.git
cd modbusim
poetry install
Using Docker
# Build the image
docker build -t modbusim .
# Run the Modbus TCP simulator
docker run -p 5020:5020 modbusim
Or using Docker Compose:
docker-compose up -d
Usage
Command Line Interface
Start a Modbus RTU simulator:
modbusim rtu --port /tmp/ptyp0 --baudrate 9600
Start a Modbus TCP simulator:
modbusim tcp --host 0.0.0.0 --port 5020
Python API
from modbusim import ModbusSimulator
# Create a simulator instance
simulator = ModbusSimulator(
mode="rtu", # or "tcp"
port="/tmp/ptyp0", # or host="0.0.0.0" for TCP
baudrate=9600
)
# Start the simulator
simulator.start()
try:
# Your test code here
while True:
# Keep the simulator running
pass
except KeyboardInterrupt:
# Stop the simulator
simulator.stop()
Development
Running Tests
make test
Linting and Formatting
make lint # Run linters
make format # Format code
Building and Publishing
make build # Build the package
make publish # Publish to PyPI
Docker Development
Build the development image
docker-compose -f docker-compose.dev.yml build
Run tests in Docker
docker-compose -f docker-compose.dev.yml run --rm modbusim make test
Start a development shell
docker-compose -f docker-compose.dev.yml run --rm --service-ports modbusim bash
License
Apache 2.0 - See LICENSE for more information.
Metadata
Release files for modbusim 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modbusim-0.1.7.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modbusim-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / modbusim-0.1.7.tar.gz
| Download URL | modbusim-0.1.7.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e73bd117684bde33873647bc738705e18086676f3fbaccfd5957c7bb9d3412af
|
|
BLAKE2b-256 checksum How to use checksums |
710262979fdfd516a4152869e4a06b1842db1bf24ab93c1100baf9f2a5aa07d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.12 Linux/6.15.8-200.fc42.x86_64
|
Release files / modbusim-0.1.7-py3-none-any.whl
| Download URL | modbusim-0.1.7-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd30ce295ba480c24c9413124c97762d60fca90a4c8ca73ed86bb847f7bf230a
|
|
BLAKE2b-256 checksum How to use checksums |
2add1434554e54bd28734c34a48db4a06a60611b38d7952b806f15e89e99cc85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.12 Linux/6.15.8-200.fc42.x86_64
|