{"id":19623741,"url":"https://github.com/advancedclimatesystems/umodbus","last_synced_at":"2025-05-16T18:09:33.714Z","repository":{"id":43932717,"uuid":"44203795","full_name":"AdvancedClimateSystems/uModbus","owner":"AdvancedClimateSystems","description":"Python implementation of the Modbus protocol.","archived":false,"fork":false,"pushed_at":"2024-04-17T07:45:43.000Z","size":270,"stargazers_count":222,"open_issues_count":41,"forks_count":86,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-10T01:05:05.684Z","etag":null,"topics":["hacktoberfest","modbus","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdvancedClimateSystems.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-13T20:46:19.000Z","updated_at":"2025-04-05T06:44:24.000Z","dependencies_parsed_at":"2024-06-18T16:58:58.764Z","dependency_job_id":null,"html_url":"https://github.com/AdvancedClimateSystems/uModbus","commit_stats":{"total_commits":202,"total_committers":14,"mean_commits":"14.428571428571429","dds":"0.33168316831683164","last_synced_commit":"f1128a73e43f565bacedd1ae99d077d7c9c831f3"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdvancedClimateSystems%2FuModbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdvancedClimateSystems%2FuModbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdvancedClimateSystems%2FuModbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdvancedClimateSystems%2FuModbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdvancedClimateSystems","download_url":"https://codeload.github.com/AdvancedClimateSystems/uModbus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","modbus","python"],"created_at":"2024-11-11T11:35:18.564Z","updated_at":"2025-05-16T18:09:33.688Z","avatar_url":"https://github.com/AdvancedClimateSystems.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://travis-ci.org/AdvancedClimateSystems/uModbus.svg\n   :target: https://travis-ci.org/AdvancedClimateSystems/uModbus\n\n.. image:: https://coveralls.io/repos/AdvancedClimateSystems/uModbus/badge.svg?service=github\n    :target: https://coveralls.io/github/AdvancedClimateSystems/uModbus\n\n.. image:: https://img.shields.io/pypi/v/uModbus.svg\n    :target: https://pypi.python.org/pypi/uModbus\n\n.. image:: https://img.shields.io/pypi/pyversions/uModbus.svg\n    :target: https://pypi.python.org/pypi/uModbus\n\nuModbus\n=======\n\nuModbus or (μModbus) is a pure Python implementation of the Modbus protocol as\ndescribed in the `MODBUS Application Protocol Specification V1.1b3`_. uModbus\nimplements both a Modbus client (both TCP and RTU) and a Modbus server (both\nTCP and RTU). The \"u\" or \"μ\" in the name comes from the the SI prefix \"micro-\".\nuModbus is very small and lightweight. The source can be found on GitHub_.\nDocumentation is available at `Read the Docs`_.\n\nQuickstart\n----------\n\nCreating a Modbus TCP server is easy:\n\n..\n    Because GitHub doesn't support the include directive the source of\n    scripts/examples/simple_tcp_server.py has been copied to this file.\n\n.. code:: python\n\n    #!/usr/bin/env python\n    # scripts/examples/simple_tcp_server.py\n    import logging\n    from socketserver import TCPServer\n    from collections import defaultdict\n    from argparse import ArgumentParser\n\n    from umodbus import conf\n    from umodbus.server.tcp import RequestHandler, get_server\n    from umodbus.utils import log_to_stream\n\n    # Add stream handler to logger 'uModbus'.\n    log_to_stream(level=logging.DEBUG)\n\n    # A very simple data store which maps addresses against their values.\n    data_store = defaultdict(int)\n\n    # Enable values to be signed (default is False).\n    conf.SIGNED_VALUES = True\n\n    # Parse command line arguments\n    parser = ArgumentParser()\n    parser.add_argument(\"-b\", \"--bind\", default=\"localhost:502\")\n\n    args = parser.parse_args()\n    if \":\" not in args.bind:\n        args.bind += \":502\"\n    host, port = args.bind.rsplit(\":\", 1)\n    port = int(port)\n\n    TCPServer.allow_reuse_address = True\n    try:\n        app = get_server(TCPServer, (host, port), RequestHandler)\n    except PermissionError:\n        print(\"You don't have permission to bind on {}\".format(args.bind))\n        print(\"Hint: try with a different port (ex: --bind localhost:50200)\")\n        exit(1)\n\n    @app.route(slave_ids=[1], function_codes=[1, 2], addresses=list(range(0, 10)))\n    def read_data_store(slave_id, function_code, address):\n        \"\"\"\" Return value of address. \"\"\"\n        return data_store[address]\n\n\n    @app.route(slave_ids=[1], function_codes=[5, 15], addresses=list(range(0, 10)))\n    def write_data_store(slave_id, function_code, address, value):\n        \"\"\"\" Set value for address. \"\"\"\n        data_store[address] = value\n\n    if __name__ == '__main__':\n        try:\n            app.serve_forever()\n        finally:\n            app.shutdown()\n            app.server_close()\n\nDoing a Modbus request requires even less code:\n\n..\n    Because GitHub doesn't support the include directive the source of\n    scripts/examples/simple_data_store.py has been copied to this file.\n\n.. code:: python\n\n    #!/usr/bin/env python\n    # scripts/examples/simple_tcp_client.py\n    from argparse import ArgumentParser\n    from socket import create_connection\n\n    from umodbus import conf\n    from umodbus.client import tcp\n\n    # Enable values to be signed (default is False).\n    conf.SIGNED_VALUES = True\n\n    # Parse command line arguments\n    parser = ArgumentParser()\n    parser.add_argument(\"-a\", \"--address\", default=\"localhost:502\")\n\n    args = parser.parse_args()\n    if \":\" not in args.address:\n        args.address += \":502\"\n    host, port = args.address.rsplit(\":\", 1)\n    port = int(port)\n\n    # Returns a message or Application Data Unit (ADU) specific for doing\n    # Modbus TCP/IP.\n    message = tcp.write_multiple_coils(slave_id=1, starting_address=1, values=[1, 0, 1, 1])\n\n    with create_connection((host, port)) as sock:\n        # Response depends on Modbus function code. This particular returns the\n        # amount of coils written, in this case it is.\n        response = tcp.send_message(message, sock)\n\n\nFeatures\n--------\n\nThe following functions have been implemented for Modbus TCP and Modbus RTU:\n\n* 01: Read Coils\n* 02: Read Discrete Inputs\n* 03: Read Holding Registers\n* 04: Read Input Registers\n* 05: Write Single Coil\n* 06: Write Single Register\n* 15: Write Multiple Coils\n* 16: Write Multiple Registers\n\nOther featues:\n\n* Support for signed and unsigned register values.\n\nLicense\n-------\n\nuModbus software is licensed under `Mozilla Public License`_. © 2018 `Advanced\nClimate Systems`_.\n\n.. External References:\n.. _Advanced Climate Systems: http://www.advancedclimate.nl/\n.. _GitHub: https://github.com/AdvancedClimateSystems/uModbus/\n.. _MODBUS Application Protocol Specification V1.1b3: http://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf\n.. _Mozilla Public License: https://github.com/AdvancedClimateSystems/uModbus/blob/develop/LICENSE\n.. _Read the Docs: http://umodbus.readthedocs.org/en/latest/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvancedclimatesystems%2Fumodbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadvancedclimatesystems%2Fumodbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadvancedclimatesystems%2Fumodbus/lists"}