Replies: 1 comment
-
|
To ensure reliable UART communication, enable hardware flow control and a large enough receive buffer on both sides. uart = UART(
UART_ID, baudrate=BAUD,
tx=Pin(TX), rx=Pin(RX),
rts=Pin(RTS), cts=Pin(CTS),
timeout=0, rxbuf=16384,
flow=UART.RTS | UART.CTS,
)Wiring: Try a low speed first, such as 115200. I managed to reach Since while True:
n = uart.any()
if n:
print(n) # read and process data here
else:
asyncio.sleep(0.01) # pause 0.01 second |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’m looking for advice on reliable file transfer between two microcontrollers on the same board over UART using MicroPython, ideally in a non-blocking / asynchronous way (because the system runs many concurrent tasks).
Context
I have two MCUs:
STM32H562VGT6 (MicroPython) — runs the main application logic. Lots of protocols/tasks running under uasyncio, so I really can’t afford long blocking operations.
ESP32-S3 (MicroPython) — mostly used as a “gateway”: data forwarding and a configuration web page (webserver).
They are connected via a UART link (the UART wiring is correct and basic uart.write() / uart.read() data transfer works fine).
What I need to transfer
telemetry files (often small, JSON),
configuration/settings (both directions),
firmware,
logs (sometimes larger).
I’d like one universal mechanism for all of this, with proper reliability (CRC/ACK/retries, recovery, etc.).
What I already tried / considered
I got something working, but I’ve already spent a lot of time dealing with timeouts, retransmissions, state sync, buffering, and edge cases. Before I invest even more into a fully custom protocol, I’d like to ask if there’s a simpler/proven approach people recommend.
My idea was to bring up PPP on both sides and then use sockets/TCP for file transfer.
I built MicroPython for STM32 with MICROPY_PY_NETWORK_PPP_LWIP=1 and adjusted lwIP memory (fixed pppos_create failed). However, I couldn’t get a PPP link up between two MicroPython endpoints (statuses like PPPERR_DEVICE, isconnected=False). It looks like MicroPython PPP is mainly meant for “client ↔ modem/pppd” rather than MCU↔MCU, or I’m missing something fundamental.
I also looked at Modbus RTU because there are MicroPython libraries available, but I’m concerned because typical implementations are synchronous/blocking, and I need something that plays nicely with uasyncio and doesn’t block other tasks.
Questions
Could you recommend a practical and preferably popular way to implement UART file transfer between two MicroPython devices asynchronously?
What protocols/approaches do people actually use for this?
Are there any existing MicroPython-friendly libraries (or easy-to-adapt Python implementations)?
Does it make sense to use XMODEM/YMODEM/ZMODEM here in MicroPython, and are there known working examples?
Any advice on integrating this with uasyncio without blocking other tasks (cooperative timeouts/polling/IRQ-based RX, etc.)?
I’d really appreciate any suggestions, links to working code, or recommendations on a simpler/proven approach before I commit to building a full custom solution again.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions