Skip to content

Bug in parsing error responses. #7

@ch82

Description

@ch82

bugs in parsing error responses. pymodbus don't check func_code >=0x80
from pymodbus.factory import ClientDecoder
from pymodbus.transaction import ModbusTransactionManager , ModbusRtuFramer
framer = ModbusRtuFramer(ClientDecoder())
data='\x00\x90\x02\x00\x01i' #error response from device
framer.processIncomingPacket(data,None)

./bug.py
Traceback (most recent call last):
File "bug.py", line 8, in
framer.processIncomingPacket(data,None)
File "build\bdist.win32\egg\pymodbus\transaction.py", line 425, in processIncomingPacket
File "build\bdist.win32\egg\pymodbus\transaction.py", line 328, in checkFrame
File "build\bdist.win32\egg\pymodbus\transaction.py", line 370, in populateHeader
AttributeError: 'NoneType' object has no attribute 'calculateRtuFrameSize'

This exception is caused by code pdu_class = self.decoder.lookupPduClass(func_code) in transaction.py line 369
ClientDecoder.lookupPduClass at line 181 knows nothing about errors(0x80+func) and returns None...

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