umodbus.readthedocs.io - uModbus — uModbus 1.0.0 documentation

Example domain paragraphs

uModbus or (μModbus) is a pure Python implementation of the Modbus protocol as described in the MODBUS Application Protocol Specification V1.1b3 . uModbus implements both a Modbus client (both TCP and RTU) and a Modbus server (both TCP and RTU). The “u” or “μ” in the name comes from the the SI prefix “micro-“. uModbus is very small and lightweight. The source can be found on GitHub . Documentation is available at Read the Docs .

Creating a Modbus TCP server is easy:

#!/usr/bin/env python # scripts/examples/simple_tcp_server.py import logging from socketserver import TCPServer from collections import defaultdict from umodbus import conf from umodbus.server.tcp import RequestHandler , get_server from umodbus.utils import log_to_stream # Add stream handler to logger 'uModbus'. log_to_stream ( level = logging . DEBUG ) # A very simple data store which maps addresss against their values. data_store = defaultdict ( int ) # Enable values to be signed (default is False). conf