diff --git a/platforms/posix/bsp/bspStdio/src/bsp/stdIo/stdIo.cpp b/platforms/posix/bsp/bspStdio/src/bsp/stdIo/stdIo.cpp index 56c70d0f9bd..8a7185aeafb 100644 --- a/platforms/posix/bsp/bspStdio/src/bsp/stdIo/stdIo.cpp +++ b/platforms/posix/bsp/bspStdio/src/bsp/stdIo/stdIo.cpp @@ -23,8 +23,8 @@ extern "C" int32_t getByteFromStdin() static Uart& uart = Uart::getInstance(Uart::Id::TERMINAL); uint8_t data_byte = 0; etl::span data(&data_byte, 1U); - uart.read(data); - if (data.size() == 0) + size_t const bytes_read = uart.read(data); + if (bytes_read == 0) { return -1; } diff --git a/platforms/posix/bsp/bspUart/src/bsp/Uart.cpp b/platforms/posix/bsp/bspUart/src/bsp/Uart.cpp index e60f9603112..de2bb48d46a 100644 --- a/platforms/posix/bsp/bspUart/src/bsp/Uart.cpp +++ b/platforms/posix/bsp/bspUart/src/bsp/Uart.cpp @@ -29,12 +29,15 @@ size_t Uart::write(::etl::span const data) size_t Uart::read(::etl::span data) { - size_t bytes_read = 0; if (_initialized) { - bytes_read = ::read(_std_in_fd, data.data(), data.size()); + ssize_t const result = ::read(_std_in_fd, data.data(), data.size()); + if (result > 0) + { + return static_cast(result); + } } - return bytes_read; + return 0U; } void Uart::init()