summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-05-02 22:04:55 +1000
committerDamien George <damien.p.george@gmail.com>2019-05-07 13:56:42 +1000
commit34942d0a72980173eca51b201f271f67bcae46b5 (patch)
tree324e419a3ba4fb620e8a9d3e3c7c1cee74394562
parent7e90e22ea52665e38138d1e704d5e527439b663c (diff)
stm32/machine_uart: Change default UART timeout to 0, for non blocking.
It's more common to need non-blocking behaviour when reading from a UART, rather than having a large timeout like 1000ms (the original behaviour). With a large timeout it's 1) likely that the function will read forever if characters keep trickling it; or 2) the function will unnecessarily wait when characters come sporadically, eg at a REPL prompt.
-rw-r--r--docs/library/pyb.UART.rst2
-rw-r--r--ports/stm32/machine_uart.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/docs/library/pyb.UART.rst b/docs/library/pyb.UART.rst
index 4359f1d9d..ab7ab2fb8 100644
--- a/docs/library/pyb.UART.rst
+++ b/docs/library/pyb.UART.rst
@@ -69,7 +69,7 @@ Constructors
Methods
-------
-.. method:: UART.init(baudrate, bits=8, parity=None, stop=1, \*, timeout=1000, flow=0, timeout_char=0, read_buf_len=64)
+.. method:: UART.init(baudrate, bits=8, parity=None, stop=1, \*, timeout=0, flow=0, timeout_char=0, read_buf_len=64)
Initialise the UART bus with the given parameters:
diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c
index 169e8c589..29369c0c1 100644
--- a/ports/stm32/machine_uart.c
+++ b/ports/stm32/machine_uart.c
@@ -224,7 +224,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const
{ MP_QSTR_parity, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
{ MP_QSTR_stop, MP_ARG_INT, {.u_int = 1} },
{ MP_QSTR_flow, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = UART_HWCONTROL_NONE} },
- { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1000} },
+ { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_timeout_char, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_rxbuf, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_read_buf_len, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, // legacy