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 extmod/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ static const mp_rom_map_elem_t machine_uart_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_uart_deinit_obj) },

{ MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read1_obj) },
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write1_obj) },

{ MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&machine_uart_any_obj) },
{ MP_ROM_QSTR(MP_QSTR_txdone), MP_ROM_PTR(&machine_uart_txdone_obj) },
Expand Down
4 changes: 2 additions & 2 deletions ports/cc3200/mods/pybuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,13 @@ static const mp_rom_map_elem_t pyb_uart_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_txdone), MP_ROM_PTR(&machine_uart_txdone_obj) },

/// \method read([nbytes])
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read1_obj) },
/// \method readline()
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
/// \method readinto(buf[, nbytes])
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
/// \method write(buf)
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write1_obj) },
{ MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) },

// class constants
Expand Down
15 changes: 7 additions & 8 deletions ports/esp32/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,19 +628,18 @@ static mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
return 0;
}

TickType_t time_to_wait;
if (self->timeout == 0) {
time_to_wait = 0;
} else {
time_to_wait = pdMS_TO_TICKS(self->timeout);
}
TickType_t time_to_wait = self->timeout > 0 ? pdMS_TO_TICKS(self->timeout) : 0;

bool release_gil = time_to_wait > 0;
bool release_gil = (self->timeout + self->timeout_char) > 0;
if (release_gil) {
MP_THREAD_GIL_EXIT();
}

int bytes_read = uart_read_bytes(self->uart_num, buf_in, size, time_to_wait);
int bytes_read = uart_read_bytes(self->uart_num, buf_in, 1, time_to_wait);
if (size > 1 && bytes_read != 0) {
time_to_wait = self->timeout_char > 0 ? pdMS_TO_TICKS(self->timeout_char) : 0;
bytes_read += uart_read_bytes(self->uart_num, buf_in + 1, size - 1, time_to_wait);
}

if (release_gil) {
MP_THREAD_GIL_ENTER();
Expand Down
2 changes: 1 addition & 1 deletion py/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
}

int error;
mp_uint_t out_sz = mp_stream_read_exactly(args[0], bufinfo.buf, len, &error);
mp_uint_t out_sz = mp_stream_rw(args[0], bufinfo.buf, len, &error, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE);
if (error != 0) {
if (mp_is_nonblocking_error(error)) {
return mp_const_none;
Expand Down
Loading