Can't get the most basic commands to work

112 views
Skip to first unread message

Adam Wasilenko

unread,
Mar 27, 2019, 12:31:39 AM3/27/19
to pymodbus
I am banging my head against the wall trying to get somewhere with modbus.

I have an inverter (Schneider XW+) and a communication "combox" that acts as the modbus tcp bridge to the inverter. Inverter is address 10.

Here is my code:

from pymodbus.client.sync import ModbusTcpClient as ModbusClient


client
= ModbusClient('10.0.0.14', 502)
client
.connect()


result
= client.read_holding_registers(10,10)
print(result)
##client.close()


Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (0 received)
>>> client.is_socket_open()
False
>>> client.connect()
True
>>> client.is_socket_open()
True
>>> client.read_holding_registers(10,10)
ModbusIOException()
>>>

Now in a desperation I started downloading freeware and got some numbers to show up in this modbus poll program: https://www.modbustools.com/download.html

It said it connected, it didn't work if the address wasn't 10, I have some confidence some communication was happening. 

Where do I go from here?

sanju dhoomakethu

unread,
Mar 27, 2019, 12:36:15 AM3/27/19
to pymo...@googlegroups.com
You are missing the device address information in the read_holding_register request.

Try 
client.read_holding_registers(10,10, unit=<unit-address>)

Also please enable the debug logs so that we know what exactly is happening.

import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


--
You received this message because you are subscribed to the Google Groups "pymodbus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymodbus+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Wasilenko

unread,
Mar 27, 2019, 12:49:15 AM3/27/19
to pymodbus
Alas, data! I'm not even mad I wasted half a day on this anymore. Thank you Sanju!!!!!! 
Reply all
Reply to author
Forward
0 new messages