From bd34794d263302e2c82290e53a3860093528ae32 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Mon, 16 Oct 2023 21:12:14 +0800 Subject: [PATCH] Add error handling --- client/src/uart/uart_posix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/uart/uart_posix.c b/client/src/uart/uart_posix.c index b864da4b1..ff2a6cde3 100644 --- a/client/src/uart/uart_posix.c +++ b/client/src/uart/uart_posix.c @@ -509,6 +509,10 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin res = read(spu->fd, transitBuf, RingBuf_getAvailableSize(spu->udpBuffer)); RingBuf_enqueueBatch(spu->udpBuffer, transitBuf, res); } + // Stop if the OS has some troubles reading the data + if (res < 0) { + return PM3_EIO; + } continue; }