Skip to content

Commit b37b2fa

Browse files
committed
overwrite old data if fifo is full
1 parent e136222 commit b37b2fa

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • ports/nrf/common-hal/busio

ports/nrf/common-hal/busio/UART.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context)
7373
switch ( event->type ) {
7474
case NRFX_UARTE_EVT_RX_DONE:
7575
for(uint8_t i=0; i < event->data.rxtx.bytes; i++) {
76-
ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]);
76+
if ( ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]) < 0 ) {
77+
// if full overwrite old data
78+
(void) ringbuf_get(&self->rbuf);
79+
ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]);
80+
}
7781
}
7882

7983
// keep receiving

0 commit comments

Comments
 (0)