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:
parent
e8ffda4a73
commit
44e311ed19
1 changed files with 2 additions and 1 deletions
|
@ -116,6 +116,7 @@ static int nble_read(struct device *uart, uint8_t *buf,
|
|||
size_t len, size_t min)
|
||||
{
|
||||
int total = 0;
|
||||
int tries = 10;
|
||||
|
||||
while (len) {
|
||||
int rx;
|
||||
|
@ -123,7 +124,7 @@ static int nble_read(struct device *uart, uint8_t *buf,
|
|||
rx = uart_fifo_read(uart, buf, len);
|
||||
if (rx == 0) {
|
||||
BT_DBG("Got zero bytes from UART");
|
||||
if (total < min) {
|
||||
if (total < min && tries--) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue