stmhal/uart: If char is not received within timeout, return EAGAIN error.

Instead of return 0, which means EOF. There's no good way to detect EOF on
continuously active bus like UART, and treat timeout as just temporary
unvailability of data. .read() method of UART object will return None in
this case (instead of 0, which again measn EOF). This is fully compliant
with unix port.
This commit is contained in:
Paul Sokolovsky 2015-10-20 00:27:07 +03:00
parent 83158e0e7f
commit bedab235f9
1 changed files with 3 additions and 3 deletions

View File

@ -772,9 +772,9 @@ STATIC mp_uint_t pyb_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, i
// wait for first char to become available
if (!uart_rx_wait(self, self->timeout)) {
// we can either return 0 to indicate EOF (then read() method returns b'')
// or return EAGAIN error to indicate non-blocking (then read() method returns None)
return 0;
// return EAGAIN error to indicate non-blocking (then read() method returns None)
*errcode = EAGAIN;
return MP_STREAM_ERROR;
}
// read the data