1533 references UART TX but possibly at "python processing" level.
I've been modifying startup code and figuring how the USB OTG features work.
The MP USB_FS device startup is some amazing code with the way it handles the serial interface into the REPL - and its a key to making the pyboard so easy to plug'n'play over a serial channel.
However, the USB_FS is the main system output, and for the the USB Host I'm using the printf and redirecting it to a UART for better stability during startup monitoring.
This hits another issue that the UART TX results in a blocking write to the hardware.
uart.c:
Code: Select all
STATIC void uart_tx_char(pyb_uart_obj_t *uart_obj, int c) {
uint8_t ch = c;
HAL_UART_Transmit(&uart_obj->uart, &ch, 1, uart_obj->timeout);
}
To work in a realtime the debug needs to not change the runtime aspect by much, and a blocking UART write does that.
There are lots of other cases where a blocking uart write is detrimental to system design, one example being.
https://github.com/micropython/micropython/issues/1642
A basic interface which requires a similiar solution has been proposed with
https://github.com/micropython/micropyt ... uart-class uart.write(buf, async=True)
I've recently implemented a solution to this in the context of stm32F429 project, so I'm posting a snippet of some **raw** code that I've wrote to solve the same problem. I can't post the code with #1642 -so attaching it here.
There is also a tutorial on fast serial processing with DMA.
http://www.emblocks.org/wiki/tutorials/ ... sco/serial
I think the DMA is more challenging, and very useful for the high thru put described in the tutorial, and more complex than a simple buffer needed at this stage.
I would like to propose that there be a layer added to the UART TX output processing. This requires a ram buffer to decouple the faster printing from the slower serialization of the UART. The size of the buffer could be an option, with a 0 size buffer having the same blocking behaviour as the current code. I found the debug buffers need to be between 500-3000bytes depending on what type of output is happening.
Just wondering what anybody else might be doing?, is this duplicating some other effort?