Pymodbus RTU AttributeError

2,335 views
Skip to first unread message

Ionut Dinu

unread,
Jan 30, 2015, 7:41:33 AM1/30/15
to pymo...@googlegroups.com
Hy,
     I used Pymodbus library to acquire data from a server, via RTU. i'll put on this post my pyscript code, noting that same script works perfectly a entire day, until i reboot my linux kernel.

SAMPLE PYTHON SCRIPT:
 
import pymodbus
import serial
import json
from pymodbus.pdu import ModbusRequest
from pymodbus.client.sync import ModbusSerialClient as ModbusClient #initialize a serial RTU client instance
from pymodbus.transaction import ModbusRtuFramer

client= ModbusClient(method = "rtu", port="/dev/ttyO1", baudrate = 19200, stopbits = 1, parity = 'N', bytesize= 8)
#connect to the serial modbus server
connection = client.connect()
#print connection

#starting add, num of reg to read, slave unit.
result= client.read_holding_registers(51457,1,unit= 0x05)
print(result.registers[0])

#closes the underlying socket connection
client.close()

                   My AttributeError look's like that, i dont't know how to fix it.

SMAPLE AttributeError

Traceback (most recent call last):
  File "test_rtu.py", line 27, in <module>
    print(result.registers[0])
AttributeError: 'NoneType' object has no attribute 'registers'
                       
                

ozzyuh .

unread,
Feb 1, 2015, 6:21:24 AM2/1/15
to pymo...@googlegroups.com
Hi,
try and use "print(result.registers)"


--
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.

Message has been deleted

Ionut Dinu

unread,
Feb 2, 2015, 2:14:39 AM2/2/15
to pymo...@googlegroups.com
Hello,
   I've tried your suggestion: print(result.registers) or print result.registers, but no positive result. My error is the same. Thanks for your help!

ozzyuh .

unread,
Feb 3, 2015, 3:29:52 AM2/3/15
to pymo...@googlegroups.com
Hi,

I cant figure what the error means exactly but,
Try and using regular decimal value for unit variable.


Ionut Dinu

unread,
Feb 5, 2015, 3:30:20 AM2/5/15
to pymo...@googlegroups.com
Hello,
 
       Thanks, once again for your help. I resolved my error, it was a port error.

Georgia Tech Research Institute

unread,
Apr 19, 2016, 10:52:01 AM4/19/16
to pymodbus
Hi Ionut,

I'm getting the same error you did.  Can you tell me how you fixed the port issue?

Thanks!

Moghul Mansoor

unread,
Sep 14, 2016, 11:20:20 AM9/14/16
to pymodbus
Hey guys, 

I am getting the same error. Any idea about what I should do with the port?

Thanks!

Leon Lee

unread,
Mar 21, 2019, 10:50:13 AM3/21/19
to pymodbus
Sir, I'm also have the same problem with you , I think maybe I plug with the wrong wire or wrong place
Can you show me or teach me how you fix it~!!!!!
Please!!!!!!

Akash Agarwal

unread,
Mar 22, 2019, 12:31:02 AM3/22/19
to pymo...@googlegroups.com
result is a None type object here. Check it before getting it's attribute values

--

Leon Lee

unread,
Aug 6, 2019, 3:52:41 AM8/6/19
to pymodbus
Hey sir, I got a same error, but how did you solved it?
Reply all
Reply to author
Forward
0 new messages