Skip to content

Commit 598251a

Browse files
committed
Clear FIFO on invalid packet reception.
1 parent 610553a commit 598251a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_rfm69.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ def receive(self, timeout_s=0.5, keep_listening=True):
654654
# Handle if the received packet is too small to include the 4 byte
655655
# RadioHead header--reject this packet and ignore it.
656656
if fifo_length < 4:
657-
# Invalid packet, ignore it
657+
# Invalid packet, ignore it. However finish reading the FIFO
658+
# to clear the packet.
659+
device.readinto(self._BUFFER, end=fifo_length)
658660
packet = None
659661
else:
660662
# Read the 4 bytes of the RadioHead header.

0 commit comments

Comments
 (0)