Attempting to decode a truncated data packet would raise an exception,
leaving the decoder in a state where next packet will get appended to it
and decoded as one packet.
This patch adds an explicit check for length before trying to decode the
data and CRC fields, allowing graceful handling of truncated packets.
self.packet_summary += ' %02X' % db
self.packet_summary += ' ]'
+ if len(packet) < 32:
+ self.putp([28, ['Invalid packet (shorter than 32 bits)']])
+ return
+
# Convenience Python output (no annotation) for all bytes together.
self.ss, self.es = self.bits[16][1], self.bits[-16][2]
self.putpb(['DATABYTES', databytes])