davidLin7692 / pymodbus

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

ModbusRtuFramer fails to decode exception response #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a Modbus/RTU client receives an exception response it fails to decode the 
message and shows a Python backtrace:

Traceback (most recent call last):
  [...]
  File "/usr/lib/python2.7/site-packages/pymodbus/transaction.py", line 352, in populateHeader
    size = pdu_class.calculateRtuFrameSize(self.__buffer)
AttributeError: 'NoneType' object has no attribute 'calculateRtuFrameSize'

The problem is caused by populateHeader() which uses lookupPduClass() to find 
the decoder class for the function code in order to calculate the full frame 
length. However, lookupPduClass() returns None for unknown function codes 
(including all exception codes).

The attached patch modifies lookupPduClass() to return ExceptionResponse for 
function codes above 0x80.

Original issue reported on code.google.com by ingo.van...@gmail.com on 14 Aug 2012 at 11:49

Attachments:

GoogleCodeExporter commented 9 years ago
Never mind, I was looking at the stale SVN repository. The reported bug has 
already been fixed in GitHub.

Original comment by ingo.van...@gmail.com on 14 Aug 2012 at 1:05

GoogleCodeExporter commented 9 years ago

Original comment by Bashw...@gmail.com on 14 Aug 2012 at 3:50