Commit Graph

66 Commits

Author SHA1 Message Date
Scott Shawcroft
083960ce90
Fix SAMD51 builds and Prox Trinkey
Adds CIRCUITPY_BUSIO_UART to disable UART by raising ValueError
that no pins work.
2021-08-11 11:53:26 -07:00
microDev
916bd92b0c
update native_uart implementation 2021-07-13 08:56:18 +05:30
microDev
fc975d6147
Merge branch 'adafruit:main' into add_uart_subclassing 2021-07-13 08:53:37 +05:30
Jeff Epler
52540a9830 Rename EXTENDED_FIELDS -> MP_TYPE_EXTENDED_FIELDS 2021-07-12 06:57:59 -05:00
Jeff Epler
7302bc09a7 rename the type flag to EXTENDED for consistency 2021-07-09 14:59:37 -05:00
Jeff Epler
d37f8a1a5a milestone: a selection of builds succeed 2021-07-06 10:57:44 -05:00
Jeff Epler
df56ba207f WIP 2021-07-06 09:25:56 -05:00
Scott Shawcroft
3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
microDev
a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Scott Shawcroft
3f08cb47b8
Merge remote-tracking branch 'adafruit/main' into busio-uart-rp 2021-02-25 16:59:15 -08:00
Scott Shawcroft
52bc935fa7
A few minor fixes for corner cases
* Always clear the peripheral interrupt so we don't hang when full
* Store the ringbuf in the object so it gets collected when we're alive
* Make UART objects have a finaliser so they are deinit when their
  memory is freed
* Copy bytes into the ringbuf from the FIFO after we read to ensure
  the interrupt is enabled ASAP
* Copy bytes into the ringbuf from the FIFO before measuring our
  rx available because the interrupt is based on a threshold (not
  > 0). For example, a single byte won't trigger an interrupt.
2021-02-25 16:50:57 -08:00
microDev
5d7fdafcde
implement suggested changes
- add internal buffering
- rtc initialization fix
2021-02-25 00:48:36 +05:30
microDev
b12ccefbe6
uart implementation for rp2040 2021-02-19 18:36:00 +05:30
Dan Halbert
ed49c02feb add timeout; finish up for PR 2021-02-17 23:24:11 -05:00
adam_cummick:g9T51EHpC9gPQqG6sb9Q@gitlab.com
23c292a2a1 Add native_uart calls 2021-01-06 08:54:26 -05:00
Adam Cummick
4809c92354 WIP - Add native helper based on displayio 2020-12-30 16:02:07 -05:00
Taku Fukada
d356581651 Fix several type hints 2020-07-27 18:05:13 +09:00
dherrada
612c6bb86b
Merge branch 'main' into type_hints 2020-07-17 14:55:30 -04:00
dherrada
d0d949cd24 Made every init return None 2020-07-03 14:23:34 -04:00
dherrada
3df03a5650 Made most of the requested changes 2020-07-03 13:49:00 -04:00
Scott Shawcroft
70fdde4aaa
Remove trailing space 2020-07-02 15:11:40 -07:00
dherrada
9b4ffc0571 Changed unions to ReadableBuffer and WriteableBuffer 2020-07-02 17:47:52 -04:00
Scott Shawcroft
c33542f978
Merge branch 'main' into patch-1 2020-07-02 13:56:09 -07:00
dherrada
54cb1feea0 Removed all 'self, )' 2020-07-02 13:28:36 -04:00
dherrada
522b17ca93 Made suggested changes 2020-07-02 13:25:07 -04:00
dherrada
cb259de5ef Did busio, fixed up analogio 2020-07-02 10:23:17 -04:00
Scott Shawcroft
a26102607e
Add UART support 2020-06-24 12:47:58 -07:00
Scott Shawcroft
2c2b53303d
Merge pull request #2837 from k0d/serial-debug
Add support for a debug console, such as ST-Link VCP.
2020-05-18 18:13:31 -07:00
Mark Olsson
007c92ee6a Enable showing the console on a debug uart 2020-05-19 02:02:52 +02:00
Scott Shawcroft
3ffa5604fc
Update countio to python stub docs 2020-05-13 08:36:16 -07:00
Scott Shawcroft
4e8de3c554
Swap sphinx to autoapi and the inline stubs 2020-05-12 17:28:24 -07:00
dherrada
c534a872a2
Merge branch 'master' into master 2020-05-12 12:26:02 -04:00
warriorofwire
eb3d5fa453 ujson: do not eat trailing whitespace
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-05-10 20:45:42 -07:00
dherrada
a2a32fea1a
Added newlines after every ellipsis 2020-04-29 15:55:06 -04:00
dherrada
093461e816
Fixed indentation 2020-04-29 15:45:19 -04:00
dherrada
deccdcc1d6
Did the same for the rest of busio 2020-04-29 15:20:05 -04:00
dherrada
724dcda3ec
Fixed whitespace in busio 2020-04-28 18:39:58 -04:00
dherrada
e7874277ab
Fixed empty lines 2020-04-25 15:35:24 -04:00
dherrada
7070fe1995
Added inline pyi to UART.c 2020-04-25 15:25:31 -04:00
AndrewR-L
f572b72306
busio/UART: Correct and clarify readline() return.
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-04-17 15:10:36 +01:00
Dan Halbert
817b5be320 rename routines to be clearer; fix wiznet arg types 2020-03-05 16:35:31 -05:00
Dan Halbert
b6206406de new pin validation routines; don't use mp_const_none if NULL will do 2020-02-28 23:43:04 -05:00
Dave Marples
d388899985 Addition of RS485 support 2020-02-18 23:16:40 +00:00
Dave Marples
84ad3d8393 Addition of RTS/CTS/RS485 UART functionality 2020-02-18 23:16:40 +00:00
Jeff Epler
238e121236 protocols: Allow them to be (optionally) type-safe
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-12-04 09:29:57 -06:00
Dan Halbert
d089f16656 'seconds' 2019-11-27 14:49:39 -05:00
Dan Halbert
dd6dfeb30a Squeeze pyruler zh_Latn_pinyin 2019-11-27 14:47:35 -05:00
Dan Halbert
b32a9192df make UART.write be blocking on SAMD; add timeout property 2019-11-27 13:05:29 -05:00
Scott Shawcroft
a35d9b469d
Refactor deinit check to reduce code size. 2019-06-12 11:36:43 -07:00
Scott Shawcroft
cfe24b8532
Improve rST consistency for rst2pyi use 2019-05-30 19:02:47 -07:00