Bluetooth: nble: Limit number tries when reading from UART

There are situations when nble_read() might stuck reading from UART when
there is no data. Limit number of tries to 10.

Change-Id: I23380b622439ce9fa72b05f4eb527f03c749fce8
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-01-26 14:14:21 +02:00 committed by Anas Nashif
commit 44e311ed19

View file

@ -116,6 +116,7 @@ static int nble_read(struct device *uart, uint8_t *buf,
size_t len, size_t min) size_t len, size_t min)
{ {
int total = 0; int total = 0;
int tries = 10;
while (len) { while (len) {
int rx; int rx;
@ -123,7 +124,7 @@ static int nble_read(struct device *uart, uint8_t *buf,
rx = uart_fifo_read(uart, buf, len); rx = uart_fifo_read(uart, buf, len);
if (rx == 0) { if (rx == 0) {
BT_DBG("Got zero bytes from UART"); BT_DBG("Got zero bytes from UART");
if (total < min) { if (total < min && tries--) {
continue; continue;
} }
break; break;