mrid
mrid

Reputation: 5796

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 ??

Upvotes: 1

Views: 10674

Answers (1)

grapes
grapes

Reputation: 8646

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

You should understand that:

  • 'modbus rtu' - this is serial modbus, contains data+crc16
  • 'modbus tcp' - this is TcpHeader[6 bytes] + data.
  • 'modbus rtu over tcp' - this is YOUR case.

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

Upvotes: 3

Related Questions