Page 1 of 1

Misleading error flag in uart.c

Posted: Sun Oct 08, 2017 10:41 am
by parsec
Hi,

This got me scratching my head for awhile. In uart.c there are a few assertion type checks at the beginning of the function uart_read_bytes():

Code: Select all

int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickType_t ticks_to_wait)
{
   UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", (-1));
   UART_CHECK((buf), "uart_num error", (-1)); //<--- 

   ...
}
I think the second check in the code above should actually return a "buffer is null" error? As it is now, if there is a problem with the buffer the result will indicate incorrect UART number.

Re: Misleading error flag in uart.c

Posted: Mon Oct 09, 2017 2:52 am
by ESP_Sprite
That's an oversight on our part indeed. Would you mind opening an issue on Github for this?

Re: Misleading error flag in uart.c

Posted: Mon Oct 09, 2017 7:05 am
by parsec
Done!

Re: Misleading error flag in uart.c

Posted: Mon Oct 09, 2017 7:15 am
by ESP_Sprite
Awesome, many thanks!