0

I am trying to read and write data on RTU over Modbus TCP with python. But it prints false, this means client.connect() has failed.

from pymodbus.client import ModbusTcpClient    
from pymodbus.transaction import ModbusRtuFramer as ModbusFramer

client = ModbusTcpClient("192.168.1.232", port=502, framer=ModbusFramer)
success = client.connect()
print(success)

Could anyone help to check this problem?Thanks

import random
  • 3,054
  • 1
  • 17
  • 22
劉姿汶
  • 1
  • 1
  • Is there a specific reason why you're specifying the `framer`? The [example code](https://pymodbus.readthedocs.io/en/latest/readme.html#example-code) doesn't do that. Regardless, are you certain that the IP address and port are correct? – import random Jul 04 '23 at 04:05
  • I check this link to get the info, https://stackoverflow.com/questions/73330328/python-modbus-rtu-over-tcp, and this IP and port is correct – 劉姿汶 Jul 04 '23 at 05:16
  • I want to use pymodbus to read modbus, and this modbus is RTU over TCP, so I am finding the method to read and write it – 劉姿汶 Jul 04 '23 at 05:18
  • And I find the framer on this document, https://buildmedia.readthedocs.org/media/pdf/pymodbus/latest/pymodbus.pdf – 劉姿汶 Jul 04 '23 at 05:39
  • If you have verified the IP address and port with different software as demonstrated in the [linked question](https://stackoverflow.com/questions/73330328/python-modbus-rtu-over-tcp), then [enable debug logging](https://pymodbus.readthedocs.io/en/latest/source/examples.html#modbus-payload-server) and [edit] your question to include more information. To what device are you trying to connect? – import random Jul 04 '23 at 12:14

0 Answers0