gianni-sch / pymodbus

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

Read_holding_registers returns None when reading from multiple addresses #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I am using pymodbus with an FDTI USB-RS485 converter to read a Modbus RTU 
device. When I continually read from a single array on the device 
(client.read_holding_registers(7680, 58, 1)) I can reliably read the data but 
when I try to read from multiple arrays in sequence it first starts returning 
None on one or two of them but within seconds they all start to return None. I 
can see on the USB device that it both transmits and received data but it still 
returns None. I have configured the client as follows:

         client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=0.15)
         client.connect()

And I am reading the registers using:
        sleep(0.1)
        amalgamated_values = client.read_holding_registers(7680, 58, 1)
        sleep(0.1)
        thd_values = client.read_holding_registers(4352, 6, 1)
        sleep(0.1)
        hv1_values = client.read_holding_registers(7936, 14, 1)
        sleep(0.1)
        hv2_values = client.read_holding_registers(8192, 14, 1)
        sleep(0.1)
        hv3_values = client.read_holding_registers(8448, 14, 1)
        sleep(0.1)
        hi1_values = client.read_holding_registers(8704, 14, 1)
        sleep(0.1)
        hi2_values = client.read_holding_registers(8960, 14, 1)
        sleep(0.1)
        hi3_values = client.read_holding_registers(9216, 14, 1)
        sleep(0.1)
        power_values = client.read_holding_registers(518, 12, 1)

Initially one of the variables will show 'None', then more of them, and then 
all of them will return 'None' continuously. I have tried a number of measures 
to recover from this including an Except in the event that 'None' is received 
in which I attempt to reconnect to the client but nothing I have tried has 
resolved the issue.
 Except:
        client.close()
        client = None
        client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=19200, stopbits=1, parity='N', bytesize=8, timeout=0.5)
        client.connect()
        sleep(1)

I would really appreciate any help that you could offer me! I have a log file 
attached if that is any help.

Thanks so much!

Paddy

Original issue reported on code.google.com by paddy.m....@gmail.com on 20 Dec 2012 at 2:19

Attachments:

GoogleCodeExporter commented 9 years ago
So have you tried this without adding any of those sleep calls? For RTU it may 
be better to use the async version and then adding deffereds.

Original comment by Bashw...@gmail.com on 13 Jan 2013 at 7:29

GoogleCodeExporter commented 9 years ago
just increase your time out... problem will be solved.

i have one more problem relating to it that after 1020 reads it replies none to 
every read. Any help will be appreciated.

and if paddy your problem is solved than plz tell me how?

Original comment by luv.raja...@gmail.com on 4 Apr 2013 at 9:38

GoogleCodeExporter commented 9 years ago

Original comment by Bashw...@gmail.com on 15 Jul 2013 at 5:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
 If resolved, Please share a solution to this issue..

Original comment by rushabh....@gmail.com on 7 Dec 2013 at 2:40