Hi, I am using libuartes to comunicate with gps and I get the Rx buffer
like a problem already asked in this thread
when I send a text "abc"
the first 3 times : everything is fine (9 bytes)
on the 4th time : my application call 2 NRF_LIBUARTE_ASYNC_EVT_RX_DATA event
- the first event show it receive "a" (10th byte => full)
- the second event show it receive "bc"
because in uarte define I define _rx_buf_size = 10
I think nrf_libuarte_async_rx_free() function will free each NRF_LIBUARTE_ASYNC_EVT_RX_DATA was called. And the next time nRF receive data from GPS, data I received will be put at the start of rx_buffer
So how can I solve this problem ? I want each time I receive data from GPS, the received data buffer will be put at the start of uarte's rx_buffer
Here is my uarte define, and uarte handle, debug terminal
NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 10, 3); void send_Uart1(char *sdata, int len) { ret_code_t ret; ret = nrf_libuarte_async_tx(&libuarte1, sdata, len); // Fixing issue text was sent too fast if (ret == NRF_ERROR_BUSY) { buffer_t buf = { .p_data = sdata, .length = len, }; ret = nrf_queue_push(&m_buf_queue, &buf); APP_ERROR_CHECK(ret); } else { APP_ERROR_CHECK(ret); } } // Function to handle uart1 event void uart_event_handler1(void *context, nrf_libuarte_async_evt_t *p_evt) { nrf_libuarte_async_t *p_libuarte = (nrf_libuarte_async_t *)context; ret_code_t ret; switch (p_evt->type) { case NRF_LIBUARTE_ASYNC_EVT_ERROR: break; case NRF_LIBUARTE_ASYNC_EVT_RX_DATA: NRF_LOG_INFO("text in RX = %s length = %d",p_evt->data.rxtx.p_data, p_evt->data.rxtx.length); memcpy(textReceived_Uart1, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length); NRF_LOG_INFO("call RX_DATA event UART1\n============="); nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length); send_Uart1(textReceived_Uart1, sizeof(textReceived_Uart1)); m_loopback_phase = true; break; case NRF_LIBUARTE_ASYNC_EVT_TX_DONE: if (m_loopback_phase) { if (!nrf_queue_is_empty(&m_buf_queue)) { NRF_LOG_INFO("call !nrf_queue_is_empty(&m_buf_queue)\n"); buffer_t buf; ret = nrf_queue_pop(&m_buf_queue, &buf); APP_ERROR_CHECK(ret); UNUSED_RETURN_VALUE(nrf_libuarte_async_tx(p_libuarte, buf.p_data, buf.length)); } } break; default: break; } }