Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions platforms/posix/bsp/bspStdio/src/bsp/stdIo/stdIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ extern "C" int32_t getByteFromStdin()
static Uart& uart = Uart::getInstance(Uart::Id::TERMINAL);
uint8_t data_byte = 0;
etl::span<uint8_t> 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;
}
Expand Down
9 changes: 6 additions & 3 deletions platforms/posix/bsp/bspUart/src/bsp/Uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ size_t Uart::write(::etl::span<uint8_t const> const data)

size_t Uart::read(::etl::span<uint8_t> 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<size_t>(result);
}
}
return bytes_read;
return 0U;
}

void Uart::init()
Expand Down
Loading