Skip to content

'NoneType' object has no attribute 'registers' #169

@tusharvb19

Description

@tusharvb19

***Here is my Code

#!/usr/bin/python2.7

from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method='rtu', port='/dev/ttyS1',
stopbits=1, bytesize=8, timeout=0.3,
baudrate=19200)
client.connect()
debug=True
#enable hardware handshake IMPORTANT
client.socket.rtscts=True

#specify which slave you want to talk to
myUnit=1

#read Version
reg = client.read_holding_registers(0,1, unit = myUnit)
print reg
print reg.registers

client.close()

***The output

None
Traceback (most recent call last):
File "test12.py", line 22, in
print reg.registers
AttributeError: 'NoneType' object has no attribute 'registers'

The code is working I guess but not able to extract the data!
Help needed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions