Misleading error flag in uart.c

parsec
Posts: 3
Joined: Sun Jun 18, 2017 7:28 am

Misleading error flag in uart.c

Postby parsec » Sun Oct 08, 2017 10:41 am

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.

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Misleading error flag in uart.c

Postby ESP_Sprite » Mon Oct 09, 2017 2:52 am

That's an oversight on our part indeed. Would you mind opening an issue on Github for this?

parsec
Posts: 3
Joined: Sun Jun 18, 2017 7:28 am

Re: Misleading error flag in uart.c

Postby parsec » Mon Oct 09, 2017 7:05 am

Done!

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Misleading error flag in uart.c

Postby ESP_Sprite » Mon Oct 09, 2017 7:15 am

Awesome, many thanks!

Who is online

Users browsing this forum: Baidu [Spider] and 60 guests