Skip to content

synchronous-example fails #2811

@owillebo

Description

@owillebo

https://pymodbus.readthedocs.io/en/latest/source/client.html#synchronous-example

from pymodbus.client import ModbusTcpClient

client = ModbusTcpClient('MyDevice.lan')       # Create client object
client.connect()                               # connect to device
client.write_coil(1, True, device_id=1)        # set information in device
result = client.read_coils(2, 3, device_id=1)  # get information from device
print(result.bits[0])                          # use information
client.close()                                 # Disconnect device
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32`
pymodbus==3.11.3

After changing MyDevice.lan in to 127.0.0.1 the script fails with;

Traceback (most recent call last):
  File "XXXXXXXXXXXXX\client.py", line 6, in <module>
    result = client.read_coils(2, 3, device_id=1)  # get information from device
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ModbusClientMixin.read_coils() takes 2 positional arguments but 3 positional arguments (and 1 keyword-only argument) were given

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions