gianni-sch / pymodbus

Automatically exported from code.google.com/p/pymodbus
0 stars 0 forks source link

Modbus response is correct, but still get None #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I use this to read Modbus TCP via a Modbus TCP to Modbus RTU gateway to read 
a Modbus RTU device data: 
rr = client.read_discrete_inputs(self.diAddress[idx], self.diN[idx], unit=mbID)
 I make sure I can get response from my device, but the return value "rr" is None
is it timeout? or any problem?

2. I use a program to read data sent in RS-485, the reply is correct.. like 
below:
01 02 00 00 00 08 79 CC 
01 02 01 00 A1 88 

3. and then I use another Modbus TCP program (write in VB) to read data, it's 
also correct, command and reply as below:
command: 01 02 00 00 00 06 --> 01 02 00 00 00 08
reply:   00 00 00 00 00 04 --> 01 02 01 00

4. pymodbus version is 1.2.0

I suggest it due to timeout...
I see default timeout is 3 seconds
but I never see it block 3 seconds to wait reply.
every command time interval is just 1 seconds (I had write 1 seconds delay here)

thanks~

Original issue reported on code.google.com by yguma.y...@gmail.com on 29 Jan 2014 at 2:12

GoogleCodeExporter commented 9 years ago
and my test code as below:
>>> from pymodbus.client.sync import ModbusTcpClient as ModbusClient
>>> client = ModbusClient('127.0.20.1', 10001)
>>> client.connect()
True
>>> rr = client.read_discrete_inputs(1, 8, unit=1)
>>> rr.__dict__
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute '__dict__'
>>> print rr
None

Original comment by yguma.y...@gmail.com on 29 Jan 2014 at 2:57

GoogleCodeExporter commented 9 years ago
hi~ guy
I find what's wrong..
because the reply 6 bytes header is wrong from my modbus gateway
it remove the first 2 bytes, and let it from "01 02" to "00 00"
so it fails...
now the modbus gateway problem is fixed
so everything is correct!!

Original comment by yguma.y...@gmail.com on 13 Mar 2014 at 12:00