Skip to content

Commit

Permalink
uart fixes (frame length check fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
fivesixzero committed Nov 28, 2020
1 parent fd8be40 commit 30486c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion adafruit_pm25/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _read_uart(self):
serial_data.append(ord(second_byte))
frame_length_bytes = self._uart.read(2)
frame_length = int.from_bytes(frame_length_bytes, "big")
if frame_length in range(0, (MAX_FRAME_SIZE - 4)):
if 0 <= frame_length <= (MAX_FRAME_SIZE - 4):
serial_data.extend(frame_length_bytes)
data_frame = self._uart.read(frame_length)
if len(data_frame) > 0:
Expand Down

0 comments on commit 30486c3

Please sign in to comment.