Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/drivers/serial/dev_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,8 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
/* if the next position is read index, discard this 'read char' */
if (rx_fifo->put_index == rx_fifo->get_index)
{
rx_fifo->get_index += 1;
rx_fifo->get_index = rx_fifo->put_index;
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting get_index equal to put_index when the buffer is full creates an empty buffer state (get_index == put_index typically indicates empty). This contradicts the is_full flag being set to RT_TRUE on the next line and may cause inconsistent buffer state interpretation elsewhere in the code.

Suggested change
rx_fifo->get_index = rx_fifo->put_index;
rx_fifo->get_index = (rx_fifo->get_index + 1) % serial->config.bufsz;

Copilot uses AI. Check for mistakes.
rx_fifo->is_full = RT_TRUE;
if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0;

_serial_check_buffer_size();
}
Expand Down