adafruit / adafruit/Adafruit_CircuitPython_BluefruitSPI
read_packet needs to check for leftover data in self._buffer
- Dominant language
- Python
- Stars
- 4
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed a strange buffering phenomena documented in https://forums.adafruit.com/viewtopic.php?f=60&t=144694
I've had a _quick glance_ at the code but my first guess is this is because `read_packet()` returns `None` if there's no data coming back from a presumably non-blocking `self.uart_rx()`. I think the lack of checking for data leftover in self._buffer from a previous call to `read_packet()` is the problem. That previous call could have picked up two (or more) commands and `read_packet()` _only returns first_ by design. I've not executed/single-stepped the code here, i'm just guessing from inspection but it seems to match observed behaviour.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing read_packet(), especially how it consumes self._buffer and calls self.uart_rx(). Reproduce the case where one call receives multiple commands, then verify that subsequent calls process leftover buffered data instead of returning None when no new UART data arrives; the issue does not name a test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100