Hello,
I'm trying to use modbus-tk to grab a few values from an S7-200. The
PLC is configured as slave, and as such I'm using the
rtumaster_example.py on the computer side.
I'm using an USB <=> RS-485 dongle, based on pl2303 chipset (fully
supported under linux).
However, it seems that everything I get back on the serial link is
"255". See below:
Code:
master = modbus_rtu.RtuMaster(serial.Serial(port="/dev/ttyUSB0",
baudrate=115200,
bytesize=8,
parity=serial.PARITY_NONE,
stopbits=1,
xonxoff=0))
master.set_timeout(10.0)
master.set_verbose(True)
logger.info("connected")
logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 40001, 1))
Ouptut:
2010-10-27 14:53:55,754 INFO modbus_rtu.__init__ MainThread RtuMaster /
dev/ttyUSB0 is opened
2010-10-27 14:53:55,768 INFO rtumaster_example.<module> MainThread
connected
2010-10-27 14:53:55,777 DEBUG modbus.execute MainThread ->
1-3-156-65-0-1-250-78
2010-10-27 14:53:55,794 DEBUG modbus.execute MainThread <-
255-255-255-255-255-255-255
Traceback (most recent call last):
File "/home/py/Software/modbus-tk/examples/rtumaster_example.py",
line 37, in <module>
logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 40001,
1))
File "/usr/local/lib/python2.6/dist-packages/modbus_tk-0.4-py2.6.egg/
modbus_tk/utils.py", line 26, in new
raise excpt
ModbusInvalidResponseError: Response address 255 is different from
request address 1
If I change the parameters of "execute" to grab more registers, I get
more bytes in return, but the value still is only 255:
Code:
logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 40001, 2))
(rest is identical)
Ouptut:
2010-10-27 14:56:12,986 DEBUG modbus.execute MainThread ->
1-3-156-65-0-2-186-79
2010-10-27 14:56:13,017 DEBUG modbus.execute MainThread <-
255-255-255-255-255-255-255-255-255
(rest is identical)
I have know idea about what I should check next. Any hint will be much
appreciated.
Pierre-Yves