pyModbusTCP


NamepyModbusTCP JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/sourceperl/pyModbusTCP
SummaryA simple Modbus/TCP library for Python
upload_time2022-06-05 10:22:27
maintainer
docs_urlNone
authorLoic Lefebvre
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master
                :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml

.. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest
               :target: http://pymodbustcp.readthedocs.io/

pyModbusTCP |badge_tests| |badge_docs|
======================================

A simple Modbus/TCP client library for Python.
pyModbusTCP is pure Python code without any extension or external module dependency.

Since version 0.1.0, a server is also available for test purpose only (don't use in project).

Tests
-----

The module is currently test on Python 3.5, 3.6, 3.7, 3.8, 3.9 and 3.10.

For Linux, Mac OS and Windows.

Documentation
-------------

Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.

Setup
-----

You can install this package from:

PyPI, the easy way:

.. code-block:: bash

    # install the last available release (stable)
    sudo pip install pyModbusTCP

.. code-block:: bash

    # install a specific version (here release v0.1.10)
    sudo pip install pyModbusTCP==v0.1.10

From GitHub:

.. code-block:: bash

    # install a specific version (here release v0.1.10) directly from github servers
    sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10

Note on the use of versions:

Over time, some things can change. So, it's a good practice that you always use a specific version of a package for
your project, instead of just relying on the default behavior. Without precision, the installation tools will always
install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP
automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just
doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of
the change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions
available.

Usage example
-------------

See examples/ for full scripts.

include (for all samples)
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    from pyModbusTCP.client import ModbusClient

module init (TCP always open)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    # TCP auto connect on first modbus request
    c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)

module init (TCP open/close for each request)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    # TCP auto connect on modbus request, close after it
    c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)

Read 2x 16 bits registers at modbus address 0 :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    regs = c.read_holding_registers(0, 2)

    if regs:
        print(regs)
    else:
        print("read error")

Write value 44 and 55 to registers at modbus address 10 :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    if c.write_multiple_registers(10, [44,55]):
        print("write ok")
    else:
        print("write error")

Know issue with older Python version on Windows
-----------------------------------------------

On windows OS with older Python version (<3), win_inet_pton module is require. This avoid exception "AttributeError:
'module' object has no attribute 'inet_pton'".

install win_inet_pton:

.. code-block:: bash

    sudo pip install win_inet_pton

import win_inet_pton at beginning of your code:

.. code-block:: python

    import win_inet_pton
    from pyModbusTCP.client import ModbusClient
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sourceperl/pyModbusTCP",
    "name": "pyModbusTCP",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Loic Lefebvre",
    "author_email": "loic.celine@free.fr",
    "download_url": "https://files.pythonhosted.org/packages/47/d0/b1fb0eb5178a6acbce7a6f392aa39d45c9e8e3f4f62d5415d8c8d035165a/pyModbusTCP-0.2.0.tar.gz",
    "platform": "any",
    "description": ".. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master\n                :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml\n\n.. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest\n               :target: http://pymodbustcp.readthedocs.io/\n\npyModbusTCP |badge_tests| |badge_docs|\n======================================\n\nA simple Modbus/TCP client library for Python.\npyModbusTCP is pure Python code without any extension or external module dependency.\n\nSince version 0.1.0, a server is also available for test purpose only (don't use in project).\n\nTests\n-----\n\nThe module is currently test on Python 3.5, 3.6, 3.7, 3.8, 3.9 and 3.10.\n\nFor Linux, Mac OS and Windows.\n\nDocumentation\n-------------\n\nDocumentation of the last release is available online at https://pymodbustcp.readthedocs.io/.\n\nSetup\n-----\n\nYou can install this package from:\n\nPyPI, the easy way:\n\n.. code-block:: bash\n\n    # install the last available release (stable)\n    sudo pip install pyModbusTCP\n\n.. code-block:: bash\n\n    # install a specific version (here release v0.1.10)\n    sudo pip install pyModbusTCP==v0.1.10\n\nFrom GitHub:\n\n.. code-block:: bash\n\n    # install a specific version (here release v0.1.10) directly from github servers\n    sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10\n\nNote on the use of versions:\n\nOver time, some things can change. So, it's a good practice that you always use a specific version of a package for\nyour project, instead of just relying on the default behavior. Without precision, the installation tools will always\ninstall the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP\nautomatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just\ndoesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of\nthe change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions\navailable.\n\nUsage example\n-------------\n\nSee examples/ for full scripts.\n\ninclude (for all samples)\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    from pyModbusTCP.client import ModbusClient\n\nmodule init (TCP always open)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    # TCP auto connect on first modbus request\n    c = ModbusClient(host=\"localhost\", port=502, unit_id=1, auto_open=True)\n\nmodule init (TCP open/close for each request)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    # TCP auto connect on modbus request, close after it\n    c = ModbusClient(host=\"127.0.0.1\", auto_open=True, auto_close=True)\n\nRead 2x 16 bits registers at modbus address 0 :\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    regs = c.read_holding_registers(0, 2)\n\n    if regs:\n        print(regs)\n    else:\n        print(\"read error\")\n\nWrite value 44 and 55 to registers at modbus address 10 :\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    if c.write_multiple_registers(10, [44,55]):\n        print(\"write ok\")\n    else:\n        print(\"write error\")\n\nKnow issue with older Python version on Windows\n-----------------------------------------------\n\nOn windows OS with older Python version (<3), win_inet_pton module is require. This avoid exception \"AttributeError:\n'module' object has no attribute 'inet_pton'\".\n\ninstall win_inet_pton:\n\n.. code-block:: bash\n\n    sudo pip install win_inet_pton\n\nimport win_inet_pton at beginning of your code:\n\n.. code-block:: python\n\n    import win_inet_pton\n    from pyModbusTCP.client import ModbusClient",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple Modbus/TCP library for Python",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/sourceperl/pyModbusTCP"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47d0b1fb0eb5178a6acbce7a6f392aa39d45c9e8e3f4f62d5415d8c8d035165a",
                "md5": "4683b5de1af816cede59783f172b0ca2",
                "sha256": "2eacea4f75e8899cf6bbbc74b933d531c1ffee071a1072ac29a7e470af3812fa"
            },
            "downloads": -1,
            "filename": "pyModbusTCP-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4683b5de1af816cede59783f172b0ca2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23445,
            "upload_time": "2022-06-05T10:22:27",
            "upload_time_iso_8601": "2022-06-05T10:22:27.509197Z",
            "url": "https://files.pythonhosted.org/packages/47/d0/b1fb0eb5178a6acbce7a6f392aa39d45c9e8e3f4f62d5415d8c8d035165a/pyModbusTCP-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-06-05 10:22:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sourceperl",
    "github_project": "pyModbusTCP",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pymodbustcp"
}
        
Elapsed time: 0.09004s