# PyModbus **Repository Path**: dabao2025/PyModbus ## Basic Information - **Project Name**: PyModbus - **Description**: Pymodbus 是一个完整的 Modbus 协议实现,为客户端/服务器提供同步/异步 API 和模拟器。 - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: dev - **Homepage**: https://github.com/pymodbus-dev/pymodbus - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-10-11 - **Last Updated**: 2025-10-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README PyModbus - A Python Modbus Stack ================================ .. image:: https://github.com/pymodbus-dev/pymodbus/actions/workflows/ci.yml/badge.svg?branch=dev :target: https://github.com/pymodbus-dev/pymodbus/actions/workflows/ci.yml .. image:: https://readthedocs.org/projects/pymodbus/badge/?version=latest :target: https://pymodbus.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://pepy.tech/badge/pymodbus :target: https://pepy.tech/project/pymodbus :alt: Downloads .. image:: https://img.shields.io/badge/Gurubase-Ask%20PyModbus%20Guru-006BFF :target: https://gurubase.io/g/pymodbus :alt: PyModbus Guru Pymodbus is a full Modbus protocol implementation offering a client and server with synchronous/asynchronous API and simulators. Our releases follow the pattern `X.Y.Z`. We have strict rules for what different version number updates mean: - **Z**, No API changes! bug fixes and smaller enhancements. - **Y**, API changes, bug fixes and bigger enhancements. - **X**, Major changes in API and/or method to use pymodbus Upgrade examples: - 3.9.0 -> 3.9.2: just plugin the new version, no changes needed. - 3.8.0 -> 3.9.0: Smaller changes to the pymodbus calls might be needed - 2.5.4 -> 3.0.0: Major changes in the application might be needed Current release is `3.9.2 `_. Bleeding edge (not released) is `dev `_. All changes are described in `release notes `_ and all API changes are `documented `_ A big thanks to all the `volunteers `_ that helps make pymodbus a great project. Source code on `github `_ Full documentation for newest releases as well as the bleeding edge (dev) `readthedocs `_ Pymodbus in a nutshell ---------------------- Pymodbus consist of 5 parts: - **client**, connect to your favorite device(s) - **server**, simulate your favorite device(s) - **repl**, a commandline text based client/server simulator - **simulator**, an html based server simulator - **examples**, showing both simple and advances usage Common features ^^^^^^^^^^^^^^^ * Full modbus standard protocol implementation * Support for custom function codes * Support serial (rs-485), tcp, tls and udp communication * Support all standard frames: socket, rtu, rtu-over-tcp, tcp and ascii * Does not have third party dependencies, apart from pyserial (optional) * Very lightweight project * Requires Python >= 3.10 * Thorough test suite, that test all corners of the library * Automatically tested on Windows, Linux and MacOS combined with python 3.10 - 3.13 * Strongly typed API (py.typed present) The modbus protocol specification: Modbus_Application_Protocol_V1_1b3.pdf can be found on `modbus org `_ Client Features ^^^^^^^^^^^^^^^ * Asynchronous API and synchronous API for applications * Very simple setup and call sequence (just 6 lines of code) * Utilities to convert int/float to/from multiple registers * Encoder/decoder to help with standard python data types `Client documentation `_ Server Features ^^^^^^^^^^^^^^^ * Asynchronous implementation for high performance * Synchronous API classes for convenience * Simulate real life devices * Full server control context (device information, counters, etc) * Different backend datastores to manage register values * Callback to intercept requests/responses * Work on RS485 in parallel with other devices `Server documentation `_ REPL Features ^^^^^^^^^^^^^ - Server/client commandline emulator - Easy test of real device (client) - Easy test of client app (server) - Simulation of broken requests/responses - Simulation of error responses (hard to provoke in real devices) `REPL documentation `_ Simulator Features ^^^^^^^^^^^^^^^^^^ - Server simulator with WEB interface - Configure the structure of a real device - Monitor traffic online - Allow distributed team members to work on a virtual device using internet - Simulation of broken requests/responses - Simulation of error responses (hard to provoke in real devices) `Simulator documentation `_ Use Cases --------- The client is the most typically used. It is embedded into applications, where it abstract the modbus protocol from the application by providing an easy to use API. The client is integrated into some well known projects like `home-assistant `_. Although most system administrators will find little need for a Modbus server, the server is handy to verify the functionality of an application. The simulator and/or server is often used to simulate real life devices testing applications. The server is excellent to perform high volume testing (e.g. hundreds of devices connected to the application). The advantage of the server is that it runs not only on "normal" computers but also on small ones like a Raspberry PI. Since the library is written in python, it allows for easy scripting and/or integration into existing solutions. For more information please browse the project documentation: https://readthedocs.org/docs/pymodbus/en/latest/index.html Install ------- The library is available on pypi.org and github.com to install with - :code:`pip` for those who just want to use the library - :code:`git clone` for those who wants to help or just are curious Be aware that there are a number of project, who have forked pymodbus and - Seems just to provide a version frozen in time - Extended pymodbus with extra functionality The latter is not because we rejected the extra functionality (we welcome all changes), but because the codeowners made that decision. In both cases, please understand, we cannot offer support to users of these projects as we do not known what have been changed nor what status the forked code have. A growing number of Linux distributions include pymodbus in their standard installation. You need to have python3 installed, preferable 3.11. Install with pip ^^^^^^^^^^^^^^^^ You can install using pip by issuing the following commands in a terminal window:: pip install pymodbus If you want to use the serial interface:: pip install pymodbus[serial] This will install pymodbus with the pyserial dependency. Pymodbus offers a number of extra options: - **repl**, needed by pymodbus.repl - **serial**, needed for serial communication - **simulator**, needed by pymodbus.simulator - **documentation**, needed to generate documentation - **development**, needed for development - **all**, installs all of the above which can be installed as:: pip install pymodbus[