pythonmodbuspymodbus3

Python read modbus over TCP


I have a modbus device and have connected a modbus RTU to ethernet converter ( and not modbus RTU to modbus TCP converter ).

All modules I have come across can read normal Modbus RTU, Modbus TCP, Modbus ASCII. But I haven't seen any module to read modbus through ethernet port.

When I tested using ModScan, I can see the data when I select Remote TELNET Server.

Is there a way I can read this data using python ??


Solution

  • That's a common case, the devices are remote serial/tcp converters. MOXA has tons of then.

    You should understand that:

    Standard modbus tcp/rtu converting devices change not only physics (ethernet/rs485 eg) but also protocol itself, removing tcp header and adding crc.

    Simple serial/tcp converters (like you have) do not modify protocol.

    You can use your lovely PyModbus after you manually specify rtu-framer for tcp-client.

    client = ModbusClient('localhost', port=5020, framer=ModbusRtuFramer)
    

    https://pymodbus.readthedocs.io/en/latest/source/example/synchronous_client.html