summaryrefslogtreecommitdiff
path: root/shared-bindings/busio/UART.c
AgeCommit message (Collapse)Author
2020-07-17Merge branch 'main' into type_hintsdherrada
2020-07-03Made every init return Nonedherrada
2020-07-03Made most of the requested changesdherrada
2020-07-02Remove trailing spaceScott Shawcroft
2020-07-02Changed unions to ReadableBuffer and WriteableBufferdherrada
2020-07-02Merge branch 'main' into patch-1Scott Shawcroft
2020-07-02Removed all 'self, )'dherrada
2020-07-02Made suggested changesdherrada
2020-07-02Did busio, fixed up analogiodherrada
2020-06-24Add UART supportScott Shawcroft
2020-05-18Merge pull request #2837 from k0d/serial-debugScott Shawcroft
Add support for a debug console, such as ST-Link VCP.
2020-05-19Enable showing the console on a debug uartMark Olsson
2020-05-13Update countio to python stub docsScott Shawcroft
2020-05-12Swap sphinx to autoapi and the inline stubsScott Shawcroft
2020-05-12Merge branch 'master' into masterdherrada
2020-05-10ujson: do not eat trailing whitespacewarriorofwire
Ujson should only worry about whitespace before JSON. This becomes apparent when you are using MP stream protocol to read directly from input buffers. When you attempt to read(1) on a UART (and possibly other protocols) you have to wait for either the byte or the timeout. Fixes: - Waiting for a timeout after you have completed reading a correct and complete JSON off the input. - Raising an OSError after reading a correct and complete JSON off the input. - Eating more data than semantically owned off the input buffer. - Blocking to start parsing JSON until the entire JSON body has been loaded into a potentially large, contiguous Python object. Code you would write before: ``` line = board_busio_uart_port.read_line() json_dict = json.loads(line) ``` or reaching for fixed buffers and swapping them around in Python. Code that did not work before that does now: ``` json_dict = json.load(board_busio_uart_port) ``` - This removes the need for intermediate copies of data when reading JSON from micropython stream protocol inputs. - It also increases total application speed by parsing JSON concurrently with receiving on boards that read from UART via DMA. - It simplifies code that users write while improving their apps.
2020-04-29Added newlines after every ellipsisdherrada
2020-04-29Fixed indentationdherrada
2020-04-29Did the same for the rest of busiodherrada
2020-04-28Fixed whitespace in busiodherrada
2020-04-25Fixed empty linesdherrada
2020-04-25Added inline pyi to UART.cdherrada
2020-04-17busio/UART: Correct and clarify readline() return.AndrewR-L
Surely readline() "rtype" is string not int as stated (and not bytes as some might expect). Also it is not totally unambiguous what happens on a timeout so it would help to clarify in docs that on a timeout it does NOT return with what it has read so far, rather it leaves all that in the buffer ready for a future read and returns nothing. Likewise clarify that if timeout=0 but there is no newline it DOES return what it has read so far (NOT None). At least this is what I think it does and/or is supposed to do! Python docs are generally not too explicit about what is the proper treatment, so perhaps all the more reason to clarify the interpretation adopted?
2020-03-05rename routines to be clearer; fix wiznet arg typesDan Halbert
2020-02-28new pin validation routines; don't use mp_const_none if NULL will doDan Halbert
2020-02-18Addition of RS485 supportDave Marples
2020-02-18Addition of RTS/CTS/RS485 UART functionalityDave Marples
2019-12-04protocols: Allow them to be (optionally) type-safeJeff Epler
Protocols are nice, but there is no way for C code to verify whether a type's "protocol" structure actually implements some particular protocol. As a result, you can pass an object that implements the "vfs" protocol to one that expects the "stream" protocol, and the opposite of awesomeness ensues. This patch adds an OPTIONAL (but enabled by default) protocol identifier as the first member of any protocol structure. This identifier is simply a unique QSTR chosen by the protocol designer and used by each protocol implementer. When checking for protocol support, instead of just checking whether the object's type has a non-NULL protocol field, use `mp_proto_get` which implements the protocol check when possible. The existing protocols are now named: protocol_framebuf protocol_i2c protocol_pin protocol_stream protocol_spi protocol_vfs (most of these are unused in CP and are just inherited from MP; vfs and stream are definitely used though) I did not find any crashing examples, but here's one to give a flavor of what is improved, using `micropython_coverage`. Before the change, the vfs "ioctl" protocol is invoked, and the result is not intelligible as json (but it could have resulted in a hard fault, potentially): >>> import uos, ujson >>> u = uos.VfsPosix('/tmp') >>> ujson.load(u) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: syntax error in JSON After the change, the vfs object is correctly detected as not supporting the stream protocol: >>> ujson.load(p) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: stream operation not supported
2019-11-27'seconds'Dan Halbert
2019-11-27Squeeze pyruler zh_Latn_pinyinDan Halbert
2019-11-27make UART.write be blocking on SAMD; add timeout propertyDan Halbert
2019-06-12Refactor deinit check to reduce code size.Scott Shawcroft
2019-05-30Improve rST consistency for rst2pyi useScott Shawcroft
2019-04-09Fix version skew for bast_pro_mini buildDan Halbert
2019-02-17A couple build fixes for mp_float_t = double (MICROPY_FLOAT_IMPL_DOUBLE).Lionel Debroux
Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
2019-01-19CharacteristicBuffer: make it be a stream class; add lockingDan Halbert
2019-01-14Add subclass support to displayio.Scott Shawcroft
Also, swap make_news to accept a kwarg map and refine param checking. Fixes #1237
2018-12-04allow KeyboardInterrupt on UART read; fix nrf UART pin claiming; rename ↵Dan Halbert
feather 52840 UART pins
2018-12-03UART changes: timeout in secs, write bytes, etc.Dan Halbert
2018-09-18merge 3.0.2 to masterDan Halbert
2018-09-12UART fixes and enhancements; default board object fixDan Halbert
2018-08-08UART: Always allocate UART objects in the long-lived poolJeff Epler
Particularly when they have buffers that are written via IRQ or DMA, UART objects do not relocate gracefully. If such an object is relocated to the long-lived pool after its original creation, the IRQ or DMA will write to an unexpected location within the Python heap, leading to a variety of symptoms. The most frequent symptom is inability to read from the UART. Consider the particular case of atmel-samd: usart_uart_obj_t contains a usart_async_descriptor contains a _usart_async_device. In _sercom_init_irq_param the address of this contained _usart_async_device is assigned to a global array sercom_to_sercom_dev which is later used from the interrupt context _sercom_usart_interrupt_handler to store the received data in the right ring buffer. When the UART object is relocated to the long-lived heap, there's no mechanism to re-point these internal pointers, so instead take the cowardly way and allocate the UART object as long-lived. Happily, almost all UART objects are likely to be long-lived, so this is unlikely to have a negative effect on memory usage or heap fragmentation. Closes: #1056
2018-08-07Support internationalisation.Scott Shawcroft
2018-02-21Implement UART for 3.0 + related fixes.Dan Halbert
1. UART: ported to ASF4. Allow rx-only and tx-only. Add .baudrate r/w property. 2. Make NeoPixel timing deterministic by turning off caches during NeoPixel writes. 3. Incorporate asf4 updates: a. async USART driver b. bringing Atmel START configuration closer to what we use c. Clock initialization order now specified by CIRCUITPY_GCLK_INIT_1ST and _LAST. 4. supervisor/port.c: Move commented-out clock-test pin setting to correct location.
2017-10-03Do not allow a *io object to be used after deinit().Dan Halbert
Fixes #278, #277, #276, #275.
2017-08-29shared-bindings: Clarify that UART.read() is slow. (#209)Scott Shawcroft
2017-06-20Merge tag 'v1.9.1'2.0.0-alpha.0Scott Shawcroft
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions This release provides an important fix for the USB mass storage device in the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which is now require by some Operating Systems. There are also fixes for the lwIP bindings to improve non-blocking sockets and error codes. The VFS has some regressions fixed including the ability to statvfs the root. All changes are listed below. py core: - modbuiltins: add core-provided version of input() function - objstr: catch case of negative "maxsplit" arg to str.rsplit() - persistentcode: allow to compile with complex numbers disabled - objstr: allow to compile with obj-repr D, and unicode disabled - modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled - provide mp_decode_uint_skip() to help reduce stack usage - makeqstrdefs.py: make script run correctly with Python 2.6 - objstringio: if created from immutable object, follow copy on write policy extmod: - modlwip: connect: for non-blocking mode, return EINPROGRESS - modlwip: fix error codes for duplicate calls to connect() - modlwip: accept: fix error code for non-blocking mode - vfs: allow to statvfs the root directory - vfs: allow "buffering" and "encoding" args to VFS's open() - modframebuf: fix signed/unsigned comparison pendantic warning lib: - libm: use isfinite instead of finitef, for C99 compatibility - utils/interrupt_char: remove support for KBD_EXCEPTION disabled tests: - basics/string_rsplit: add tests for negative "maxsplit" argument - float: convert "sys.exit()" to "raise SystemExit" - float/builtin_float_minmax: PEP8 fixes - basics: convert "sys.exit()" to "raise SystemExit" - convert remaining "sys.exit()" to "raise SystemExit" unix port: - convert to use core-provided version of built-in import() - Makefile: replace references to make with $(MAKE) windows port: - convert to use core-provided version of built-in import() qemu-arm port: - Makefile: adjust object-file lists to get correct dependencies - enable micropython.mem_*() functions to allow more tests stmhal port: - boards: enable DAC for NUCLEO_F767ZI board - add support for NUCLEO_F446RE board - pass USB handler as parameter to allow more than one USB handler - usb: use local USB handler variable in Start-of-Frame handler - usb: make state for USB device private to top-level USB driver - usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command - convert from using stmhal's input() to core provided version cc3200 port: - convert from using stmhal's input() to core provided version teensy port: - convert from using stmhal's input() to core provided version esp8266 port: - Makefile: replace references to make with $(MAKE) - Makefile: add clean-modules target - convert from using stmhal's input() to core provided version zephyr port: - modusocket: getaddrinfo: Fix mp_obj_len() usage - define MICROPY_PY_SYS_PLATFORM (to "zephyr") - machine_pin: use native Zephyr types for Zephyr API calls docs: - machine.Pin: remove out_value() method - machine.Pin: add on() and off() methods - esp8266: consistently replace Pin.high/low methods with .on/off - esp8266/quickref: polish Pin.on()/off() examples - network: move confusingly-named cc3200 Server class to its reference - uos: deconditionalize, remove minor port-specific details - uos: move cc3200 port legacy VFS mounting functions to its ref doc - machine: sort machine classes in logical order, not alphabetically - network: first step to describe standard network class interface examples: - embedding: use core-provided KeyboardInterrupt object
2017-06-07shared-bindings: Update docs to remove with statements from examples but add ↵Scott Shawcroft
more detail to the design guide about their use.
2017-04-10Split up nativeio.0.9.4Scott Shawcroft
This was done to allow greatly granularity when deciding what functionality is built into each board's build. For example, this way pulseio can be omitted to allow for something else such as touchio.