diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-11 17:57:10 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-21 22:15:20 +0100 |
commit | 481d714bd56e0173668b249760e9cea8fce9b04f (patch) | |
tree | 4a1e9458676177d05b18e7d50966469bf44e1ec1 /tests/pyb | |
parent | 20f59e182e1ca5874a94ce939f8a81af6c3dd71a (diff) | |
download | micropython-481d714bd56e0173668b249760e9cea8fce9b04f.tar.gz micropython-481d714bd56e0173668b249760e9cea8fce9b04f.zip |
stmhal: Overhaul UART class to use read/write, and improve it.v1.3.4
UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.
Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.
The object includes optional read buffering, using interrupts. You can set
the buffer size dynamically using read_buf_len keyword arg. A size of 0
disables buffering.
Diffstat (limited to 'tests/pyb')
-rw-r--r-- | tests/pyb/uart.py | 8 | ||||
-rw-r--r-- | tests/pyb/uart.py.exp | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/tests/pyb/uart.py b/tests/pyb/uart.py index 6e0118d155..288022fea4 100644 --- a/tests/pyb/uart.py +++ b/tests/pyb/uart.py @@ -2,11 +2,13 @@ from pyb import UART uart = UART(1) uart = UART(1, 9600) -uart = UART(1, 9600, bits=8, stop=1, parity=None) +uart = UART(1, 9600, bits=8, parity=None, stop=1) print(uart) uart.init(1200) print(uart) -uart.any() -uart.send(1, timeout=500) +print(uart.any()) +print(uart.write('123')) +print(uart.write(b'abcd')) +print(uart.writechar(1)) diff --git a/tests/pyb/uart.py.exp b/tests/pyb/uart.py.exp index 58ded4d848..dd98e17968 100644 --- a/tests/pyb/uart.py.exp +++ b/tests/pyb/uart.py.exp @@ -1,2 +1,6 @@ -UART(1, baudrate=9600, bits=8, stop=1, parity=None) -UART(1, baudrate=1200, bits=8, stop=1, parity=None) +UART(1, baudrate=9600, bits=8, parity=None, stop=1, timeout=1000, timeout_char=0, read_buf_len=64) +UART(1, baudrate=1200, bits=8, parity=None, stop=1, timeout=1000, timeout_char=0, read_buf_len=64) +False +3 +4 +None |