micropython uart.read() in SAMD51 is incomplete (only 2 bytes returned)

277 views Asked by At

I have an ATSAMD51 microcontroller integrated in a project-specific board which has also a xbee3 RF module. This xbee3 module is configured for Transparent Mode and the device type is 'router'. I can check this on the XCTU software.

Now, my goal is to install micropython on ATSAMD51 and then send commands to the xbee3 via UART since unfortunately I am not aware of any micropython library that can interact with the xbee. And just out of confusion, I don't want to use the xbee with micropython.

++++++++++++++           ++++++++++++++
++ ATSAMD51 ++ --UART--> ++ XBEE3 RF ++
++++++++++++++           ++++++++++++++
(running                 (transparent
micropython)             mode)

I successfully installed the micropython on the ATSAMD51 and I managed to send commands to the xbee3 via UART. I know this works since when I do uart.write('1234') I can check on the XCTU console that the coordinator node receives this message. However, If I try to send xbee3 AT commands, the uart.read() only gets 2 bytes at most.

Example: screen /dev/tty.usbmodem0000000000001 115200 # enter the python REPL of the ATSAMD51

>>> from machine import UART, Pin
>>> uart = UART(5, rx=Pin('PB02'), tx=Pin('PB03'), baudrate=115200)
>>> uart
UART(5, baudrate=115200, bits=8, parity=None, stop=1, timeout=1, timeout_char=1, rxbuf=256, txbuf=256)
>>> uart.write('1234') # this actually transmits the message to the coordinator node
4
>>> uart.write('+++') # entering in command mode
3
>>> uart.read()
b'OK\r'
>>> uart.write('ATID\r')
5
>>> uart.read()
b'FO\r' # this should be FOO which is the device PAN ID
>>> uart.write('ATXX\r')
5
>>> uart.read()
b'ER\r' # this should be ERROR

Any command I send I always get only 2 characters + the \r (carriage return).

Thank you!

I've tried different baudrates and timeouts. If I try to connect to the xbee directly from the computer via serial this works as expected. So I guess this is somehow related with the micropython UART configuration in the SAMD51?

1

There are 1 answers

0
Carlos Mão de Ferro On

The answer for the problem is here. A temporary fix is available here.