Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions umodbus/client/serial/redundancy_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ def validate_crc(msg):
"""
if not struct.unpack('<H', get_crc(msg[:-2])) ==\
struct.unpack('<H', msg[-2:]):
raise CRCError('CRC validation failed.')
raise CRCError(msg)


class CRCError(Exception):
""" Valid error to raise when CRC isn't correct. """
pass
"""CRC validation failed."""

def __str__(self):
return self.__doc__
2 changes: 1 addition & 1 deletion umodbus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ def recv_exactly(recv_fn, size):
response = b''.join(chunks)

if len(response) != size:
raise ValueError
raise ValueError(response)

return response