Skip to content

Commit 5f1e9a3

Browse files
szczyskartben
authored andcommitted
drivers: uart_mcumgr: log warning when smp drops data
Add warning logs when data is dropped on the serial transport by the smp system due to buffer overrun. Signed-off-by: Mike Szczys <[email protected]>
1 parent 520ce6a commit 5f1e9a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/console/uart_mcumgr.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <zephyr/mgmt/mcumgr/transport/serial.h>
1616
#include <zephyr/drivers/console/uart_mcumgr.h>
1717

18+
#include <zephyr/logging/log.h>
19+
LOG_MODULE_REGISTER(uart_mcumgr, CONFIG_MCUMGR_TRANSPORT_LOG_LEVEL);
20+
1821
static const struct device *const uart_mcumgr_dev =
1922
DEVICE_DT_GET(DT_CHOSEN(zephyr_uart_mcumgr));
2023

@@ -89,7 +92,7 @@ static struct uart_mcumgr_rx_buf *uart_mcumgr_rx_byte(uint8_t byte)
8992
if (uart_mcumgr_cur_buf == NULL) {
9093
uart_mcumgr_cur_buf = uart_mcumgr_alloc_rx_buf();
9194
if (uart_mcumgr_cur_buf == NULL) {
92-
/* Insufficient buffers; drop this fragment. */
95+
LOG_WRN("Insufficient buffers, fragment dropped");
9396
uart_mcumgr_ignoring = true;
9497
}
9598
}
@@ -98,7 +101,7 @@ static struct uart_mcumgr_rx_buf *uart_mcumgr_rx_byte(uint8_t byte)
98101
rx_buf = uart_mcumgr_cur_buf;
99102
if (!uart_mcumgr_ignoring) {
100103
if (rx_buf->length >= sizeof(rx_buf->data)) {
101-
/* Line too long; drop this fragment. */
104+
LOG_WRN("Line too long, fragment dropped");
102105
uart_mcumgr_free_rx_buf(uart_mcumgr_cur_buf);
103106
uart_mcumgr_cur_buf = NULL;
104107
uart_mcumgr_ignoring = true;

0 commit comments

Comments
 (0)