summaryrefslogtreecommitdiff
path: root/libcpu/SConscript
diff options
context:
space:
mode:
authorwdfk-prog <[email protected]>2025-08-09 09:48:31 +0800
committerR b b666 <[email protected]>2025-08-10 12:10:16 +0800
commit302370720e3d41355158378e27b137fc21c0a5ab (patch)
treebb45b27725df6f6f4f62a48f92c9833cbdf06dbf /libcpu/SConscript
parent6bb524eb317275aa2f31e930cf2da3809a6fc118 (diff)
[driver][serial] V1]: fix correct data loss logic when RX ring buffer is full
In the serial ISR (`rt_hw_serial_isr`), the previous logic for handling a full RX FIFO was flawed. When the buffer was filled, it would increment `get_index` (`get_index += 1`). This had two negative consequences: 1. It effectively discarded the oldest byte of data prematurely. 2. It reduced the usable capacity of a buffer of size N to N-1. For example, a 64-byte buffer could only ever hold 63 readable bytes after becoming full. This patch corrects the behavior by implementing a standard overwriting ring buffer strategy. When the buffer is full, the logic is changed to `get_index = put_index`. This ensures that: - When new data arrives, it correctly overwrites the oldest data. - The `get_index` is advanced along with the `put_index`, correctly marking the new start of the buffer. - The full N-byte capacity of the buffer is utilized, always storing the N most recent bytes. This change resolves the unexpected data loss and makes the buffer behavior correct and predictable.
Diffstat (limited to 'libcpu/SConscript')
0 files changed, 0 insertions, 0 deletions