Skip to content

Commit

Permalink
Fixed erronous CRC handling
Browse files Browse the repository at this point in the history
If the CRC recieved is not correct in my case my slave got caught in a deadlock, not taking any new requests. This addition fixed that.
  • Loading branch information
JStrbg authored and dhoomakethu committed Feb 11, 2019
1 parent 6960d9c commit 5030514
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pymodbus/framer/rtu_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ def checkFrame(self):
data = self._buffer[:frame_size - 2]
crc = self._buffer[frame_size - 2:frame_size]
crc_val = (byte2int(crc[0]) << 8) + byte2int(crc[1])
return checkCRC(data, crc_val)
if checkCRC(data, crc_val):
return True
else:
_logger.debug("CRC invalid, discarding header!!")
self.resetFrame()
return False
except (IndexError, KeyError, struct.error):
return False

Expand Down

0 comments on commit 5030514

Please sign in to comment.