A Modbus RTU/ASCII/TCP device simulator for testing and development
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modbusim-0.1.7.tar.gz.
File metadata
- Download URL: modbusim-0.1.7.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.15.8-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e73bd117684bde33873647bc738705e18086676f3fbaccfd5957c7bb9d3412af
|
|
| MD5 |
b415b02e2bbd280a9c851f6a3324f9ed
|
|
| BLAKE2b-256 |
710262979fdfd516a4152869e4a06b1842db1bf24ab93c1100baf9f2a5aa07d4
|
File details
Details for the file modbusim-0.1.7-py3-none-any.whl.
File metadata
- Download URL: modbusim-0.1.7-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.15.8-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd30ce295ba480c24c9413124c97762d60fca90a4c8ca73ed86bb847f7bf230a
|
|
| MD5 |
c619b1654ad07c3837857cf844dd2269
|
|
| BLAKE2b-256 |
2add1434554e54bd28734c34a48db4a06a60611b38d7952b806f15e89e99cc85
|