Hi everyone,
I use the UARTE to receive data, and I want to clear rx buffer every time, because If not when the buffer will be full, the next data I received will be split into two parts,
for example, the buffer is 32bytes, for now i received 30bytes, if i send 4bytes data next time, the data print like that
# SEGGER J-Link RTT Viewer V7.00a Terminal Log File
# Compiled: 15:35:52 on Apr 16 2021
# Logging started @ 03 Mar 2023 09:44:31
00> buf.p_data[0] = 5A,len = 30
00> buf.p_data[1] = 5A,len = 30
00> buf.p_data[2] = 0,len = 30
00> buf.p_data[3] = 1,len = 30
00> buf.p_data[4] = 1,len = 30
00> buf.p_data[5] = 5A,len = 30
00> buf.p_data[6] = 5A,len = 30
00> buf.p_data[7] = 0,len = 30
00> buf.p_data[8] = 1,len = 30
00> buf.p_data[9] = 1,len = 30
00> buf.p_data[10] = 5A,len = 30
00> buf.p_data[11] = 5A,len = 30
00> buf.p_data[12] = 0,len = 30
00> buf.p_data[13] = 1,len = 30
00> buf.p_data[14] = 1,len = 30
00> buf.p_data[15] = 5A,len = 30
00> buf.p_data[16] = 5A,len = 30
00> buf.p_data[17] = 0,len = 30
00> buf.p_data[18] = 1,len = 30
00> buf.p_data[19] = 1,len = 30
00> buf.p_data[20] = 5A,len = 30
00> buf.p_data[21] = 5A,len = 30
00> buf.p_data[22] = 0,len = 30
00> buf.p_data[23] = 1,len = 30
00> buf.p_data[24] = 1,len = 30
00> buf.p_data[25] = 5A,len = 30
00> buf.p_data[26] = 5A,len = 30
00> buf.p_data[27] = 0,len = 30
00> buf.p_data[28] = 1,len = 30
00> buf.p_data[29] = 1,len = 30
00> buf.p_data[0] = 5A,len = 2
00> buf.p_data[1] = 5A,len = 2
00> buf.p_data[0] = 0,len = 2
00> buf.p_data[1] = 1,len = 2
# Logging stopped @ 03 Mar 2023 09:44:58
The rx buff is 32bytes, first time I send 30bytes from uart, in rtt log, you can see I received data length = 30, and then I send 4 bytes, the rtt log show that two part of it, a part is 5A 5A length = 2,
another is 0 1 length = 2.
I think the question is the rx buffer is full, but I use the nrf_libuarte_async_rx_free(p_libearte, p-evt->data.rxtx.p_data, p_evt->data.rxtx.length); to clear the buffer.
In this function I found that only when the buffer was full it will be cleared.
So, how should clear the buffer every time?
Best regards,
Lurn