esp-idf
esp-idf copied to clipboard
Ensure serial break event is generated in the correct place in the serial byte stream (IDFGH-4088)
Currently the UART_BREAK event generated upon detection of a serial break is delivered asynchronously to the bytes received by the UART. An event containing bytes received following a serial break is sent prior to the event for the corresponding break. If the serial break is used as a frame delimiter, as it is in many protocols, this makes determining where to delineate frames challenging.
This patch was proposed by @negativekelvin in #4537, and ensures UART_BREAK events are delivered in the correct place in the stream.
Thanks for your contribution.
@Alvin1Zhang Any chance of getting this reviewed and merged any time soon, we are also wanting this fix to be merged ?
Bump, this is important
Any update on why this has not been approved and merged yet ?
how is this not resolved yet?
@negativekelvin is this PR still relevant with the latest v5 changes ?
it was never at any point not relevant. so unfortunately yes. I'm just about to reopen an issue because of it
apparently when espressif determines there is no bug except in your head... they silently ignore it, regardless how many people complain. so we're stuck unless someone updates it for latest idf5 master and everybody who needs it apply the PR manually.
Hi @acf-bwl @moefear85
Sorry this has sat around for an extraordinary long time without further feedback. Currently we hit regression on some of our UART driver unit tests with this change. I'll update this PR as soon as they are resolved.
ok thx for acknowledging the issue, it helps to know I'm not doing something wrong (or atleast not simultaneously).
This PR didn't pass CI with RS-485 test case...
An alternative solution for this issue is very simple: read byte by byte from UART instead of reading 120 bytes when its FIFO is full.
BREAK can happen any time.... just make sure that IDF driver always gets every single byte from UART and copy it to its internal RingBuffer. Doing so, when BREAK happens, the RingBuffer would be already complete and it will be possible to catch the BREAK event and then process the data already copied.
In order to read byte by byte, just initialize the UART IDF Driver and then execute uart_set_rx_full_threshold(uart_port_t uart_num, int threshold), with correct uart_num and threshold = 1.
As far as I extensively experimented, "hardware" RS-485 is broken anyways. I only got it working for multi-drop by implementing collision detection/avoidance in software. RS-232 is far more basic and important, because RS-485 is build on RS-232, meaning if uart breaks aren't correctly detected in RS-232, then neither are they in RS-485, so that's broken too!
Besides, reading byte by byte is not a solution, especially not at 2Mbps. I hate when people assume everyone is just trying to run some simple arduino project. It's supposed to be a professional-grade product. Anyways I moved on a long time ago and will unsubscribe here. Plz don't mention me.
Tested this on v5.3.1 and it receives LIN frames successful.