Should I use xQueueReceive for UART?
Posted: Mon Dec 26, 2016 12:27 pm
What is more optimal way to use UART: using xQueueReceive or not and read one by one byte?
I wont use any other event.type.
I wont use any other event.type.
Code: Select all
while (1) {
if (xQueueReceive(m_uart_queue, (void *)&event, 10 / portTICK_PERIOD_MS)) {
if (event.type == UART_DATA) {
uint32_t len = bufferEnd - ptr;
if (len > event.size) len = event.size;
int ret = uart_read_bytes(MODULE_UART_NUM, (uint8_t *) ptr, len, 10);
if (ret > 0) {
...
}
}
}
}
Code: Select all
while (1) {
uint32_t len = 1;
int ret = uart_read_bytes(MODULE_UART_NUM, (uint8_t *) ptr, len, 10 / portTICK_PERIOD_MS);
if (ret > 0) {
...
}
}