esp-idf icon indicating copy to clipboard operation
esp-idf copied to clipboard

Ensure serial break event is generated in the correct place in the serial byte stream (IDFGH-4088)

Open acf-bwl opened this issue 5 years ago • 14 comments

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.

acf-bwl avatar Oct 09 '20 23:10 acf-bwl

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 09 '20 23:10 CLAassistant

Thanks for your contribution.

Alvin1Zhang avatar Oct 12 '20 07:10 Alvin1Zhang

@Alvin1Zhang Any chance of getting this reviewed and merged any time soon, we are also wanting this fix to be merged ?

AshUK avatar Nov 05 '20 11:11 AshUK

Bump, this is important

dzarda avatar Dec 11 '21 19:12 dzarda

Any update on why this has not been approved and merged yet ?

AshUK avatar Mar 16 '22 17:03 AshUK

how is this not resolved yet?

moefear85 avatar May 30 '22 16:05 moefear85

@negativekelvin is this PR still relevant with the latest v5 changes ?

AshUK avatar May 30 '22 17:05 AshUK

it was never at any point not relevant. so unfortunately yes. I'm just about to reopen an issue because of it

moefear85 avatar May 30 '22 17:05 moefear85

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.

moefear85 avatar Jun 07 '22 12:06 moefear85

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.

tore-espressif avatar Jun 14 '22 08:06 tore-espressif

ok thx for acknowledging the issue, it helps to know I'm not doing something wrong (or atleast not simultaneously).

moefear85 avatar Jun 14 '22 10:06 moefear85

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.

SuGlider avatar Nov 02 '22 16:11 SuGlider

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.

moefear85 avatar Nov 02 '22 22:11 moefear85

Tested this on v5.3.1 and it receives LIN frames successful.

KenthJohan avatar Sep 19 '24 14:09 KenthJohan