1

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

mrid
  • 5,782
  • 5
  • 28
  • 71
  • You need more info on this "ethernet converter", basically, which protocol is used? Is it UDP or TCP based? Which port number is used? – Ronaldo Aug 13 '18 at 12:35
  • The converter is TCP based. T've tried port 23, and 5001 – mrid Aug 14 '18 at 12:27
  • Protocol? (I understand it is NOT Modbus TCP). Any manual, part number? – Ronaldo Aug 14 '18 at 12:53
  • @Ronaldo I'm using Moxa NPort 5110 (https://www.moxa.com/product/NPort_5110.htm). The website just says `Serial-to-Ethernet Solution`, so dont know much about how it's working – mrid Aug 15 '18 at 03:30
  • and I would like to read the data register-wise (in case tcp removes that format) as I have various parameters in diff registers I want to read – mrid Aug 15 '18 at 03:38
  • the manual is here https://www.moxa.com/doc/man/NPort_5000_Series_UM_e4.1.pdf – Ronaldo Aug 15 '18 at 16:19
  • I took a click glance and it seems that you need to put the converter in the "Real COM Mode". That way you can send Modbus RTU formatted data to the converter using a TCP connection and the device will forward it to the RTU device. Do not forget to set the serial port parameters accordingly. – Ronaldo Aug 15 '18 at 16:20
  • By the way, you will have to stick with the Modbus way of reading registers (the same for both RTU and TCP). – Ronaldo Aug 15 '18 at 16:21
  • @Ronaldo I guess you got me wrong...the converter is converting to the ethernet just fine ( that's why I'm able to read using modscan ). the problem is I don't know how to read it im my python program – mrid Aug 18 '18 at 15:58
  • Got it! So just send Modbus-RTU formatted data to the converter, using a modbus library, maybe pymodbus. – Ronaldo Aug 20 '18 at 18:40

1 Answers1

3

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

grapes
  • 8,185
  • 1
  • 19
  • 31