protocols: fix off-by-one in payload extraction

Drop all of the checksum bytes. This didn't take the end-of-frame marker
into account.
This commit is contained in:
Grigori Goronzy 2021-01-03 16:10:05 +01:00
parent b46d81a184
commit 0e020f2aa4

View File

@ -417,7 +417,7 @@ class Stc89Protocol(StcBaseProtocol):
raise StcFramingException("packet checksum mismatch")
payload = StcBaseProtocol.extract_payload(self, packet)
return payload[:-1]
return payload[:-2]
def write_packet(self, packet_data):
"""Send packet to MCU.
@ -812,7 +812,7 @@ class Stc12BaseProtocol(StcBaseProtocol):
raise StcFramingException("packet checksum mismatch")
payload = StcBaseProtocol.extract_payload(self, packet)
return payload[:-2]
return payload[:-3]
def write_packet(self, packet_data):
"""Send packet to MCU.