uart only received 16 bytes

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
wenzhe
Offline
Last seen:1 month 1 week ago
Joined:2020-03-27 16:12
uart only received 16 bytes

Hi Dialog,

I'm following example uart2_loopback_test.c to write my uart application, where I need to receive string line by line from a uart peripheral.

therefore, I call uart_read to read a byte and callback is triggered after a byte is recieved; inside uart_read_cb(), a message is sent once symbol line feeds and return is detected, and then call uart read to force endless uart read.

code is post as below.

my issue is with this method, only received 16 bytes are recieved, while uart peripheral sends more than 16 bytes (30 bytes actually, let's say).

I have verified that the uart peripheral does send 30bytes by some experiment.

could you please help to understand what is wrong here?

thanks,

Wenzhe

static void uart_read_cb(uint8_t status)
{
// Put received byte in ring buffer
ring_put_byte(&g_at_ring, uart_rxbuf[0]);

如果(uart_rxbuf [0] = = & & uar“\ n”t_rxbuf[1]=='\r'){
//send message to app task indicating a line of response recieved
struct lte_atrsp_line_ind *req = KE_MSG_ALLOC_DYN(APP_MSG_LTE_ATRSP, TASK_APP, TASK_APP,
lte_atrsp_line_ind,0);
req->len= ring_get_byte_count(&g_at_ring);
req->line_count = ring_get_availble_line_counter(&g_at_ring);
ke_msg_send(req);
}

uart_rxbuf[1]=uart_rxbuf[0];

// Start the next asynchronous read of 1 character.
uart_read(uart_rxbuf, size, uart_read_cb);
}

空白ring_init(空白)
{
ring_t* ring=&g_at_ring;
ring->BUFFER_SIZE = AT_RING_BUF_SIZE;
ring->buffer_count = 0;
ring->buffer_head = 0;
ring->buffer_tail = 0;
ring->line_count = 0;
MEMSET(ring->buf,0,AT_RING_BUF_SIZE);
LOGD("starting monitor uart");
uart_read(uart_rxbuf, 1, uart_read_cb);

}

Device:
wenzhe
Offline
Last seen:1 month 1 week ago
Joined:2020-03-27 16:12
I got it.

I got it.

there is a Debug print using uart2 in the funcation called by the callback, which slows down the callback excuation. removing the debug print, issue fixed.

PM_Dialog
Offline
Last seen:1 hour 28 min ago
Staff
Joined:2018-02-08 11:03
Hi wenzhe,

Hi wenzhe,

Apologies for the late response. Thanks for your indication and glad that you solved it.

Thanks, PM_Dialog