modem: modem_iface_uart_async: handle RX errors

Re-enable reception on the UART instance when `UART_RX_DISABLED`
triggers, which can happen when errors occur on the line.

This stops the driver permanently moving into an unresponsive state.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2023-05-06 17:52:23 +10:00 committed by Carles Cufí
parent 4598e6bf0a
commit ec362d4a48

View file

@ -61,6 +61,21 @@ static void iface_uart_async_callback(const struct device *dev,
/* Notify upper layer that new data has arrived */
k_sem_give(&data->rx_sem);
break;
case UART_RX_STOPPED:
break;
case UART_RX_DISABLED:
/* RX stopped (likely due to line error), re-enable it */
rc = k_mem_slab_alloc(&uart_modem_async_rx_slab, (void **)&buf, K_FOREVER);
if (rc < 0) {
LOG_ERR("RX disabled and buffer starvation");
break;
}
rc = uart_rx_enable(dev, buf, RX_BUFFER_SIZE,
CONFIG_MODEM_IFACE_UART_ASYNC_RX_TIMEOUT_US);
if (rc < 0) {
LOG_ERR("Failed to re-enable UART");
}
break;
default:
break;
}