console_getline vs 0ms char delay in UART comms
Piotr Barszczewski <piotr@...>
I’ve been reviewing code from a colleague, which (code, not the colleague) is heavily based on the https://docs.zephyrproject.org/latest/samples/subsys/console/getline/README.html I’ve been experiencing some unexpected behaviour when using CuteCom vs screen to communicate with the console. I’ve dug deeper and deeper and eventually it seemed like the value returned by console_getline function was indeed already corrupted. In screen everything worked fine.
My assumption was that when I’m using screen each character is passed 1-by-1 to a buffer and everything is golden. On the other hand CuteCom buffers the input until I press enter and fires away at the serial port - pretty much like M2M communications would work over UART.
Eventually I opened up the https://docs.zephyrproject.org/latest/samples/subsys/console/getline/README.html project and the behaviour was the same. It corrupted the buffer when used in Cutecom and worked ok with screen.
This is an example of the output of FW when sending “1234” over Cutecom with 0ms delay (which is what I have been using +/- forever):
In the end I’ve changed CuteComs char delay to 1ms and everything works well:
Is there some simple CONFIG_ argument to change this? I’ve looked in menuconfig but without luck.
It’s not much of a problem to instruct every user of the FW to change it to 1ms but I’m a bit concerned about using various scripts to communicate with the firmware which will use the console. Depending on the implementation of serial driver it might require additional work to accound for the buffer not handling bursts of data.