esp-rs / esp-hal

no_std Hardware Abstraction Layers for ESP32 microcontrollers
https://docs.esp-rs.org/esp-hal/
Apache License 2.0
762 stars 212 forks source link

Uart: problems after added check of err_wr_mask in config #1580

Open maxwen opened 6 months ago

maxwen commented 6 months ago

I have written an esp32 mbus scanner for reading the smartmeter of my energy provider. It uses an mbus scanner attached to uart (from MikroElektronika).

That worked fine before the following was added to uart.rs

... // Setting err_wr_mask stops uart from storing data when data is wrong according // to reference manual T::registerblock() .conf0() .modify(|, w| w.err_wr_mask().set_bit()); ...

And the subsequent check for events in read_async ... let mut events = .... | RxEvent::RxFrameError | RxEvent::RxGlitchDetected | RxEvent::RxParityError; ...

I can bring it back working as before when disabling setting err_wr_mask and disabling that those three events return an Err.

The read loop is based on rx_timeout to sync the packets which are sent periodically from the smartmeter. Its a very slow connection (2400 baud)

Now I am unsure why this creates those "errors". Is this just "normal" for those kind of connections? If yes - would it make sense to add some kind of config to disable those "forced" checks "on demand"?

So I guess it comes down to what exactly means "data is wrong according to reference manual"

dignifiedquire commented 3 months ago

having the same issue, would be great if this could be a config option

MabezDev commented 3 months ago

We'll get to this eventually, but a PR would be most welcome :).

clabbenius commented 1 month ago

Do you have an example code snippet where you use read_async uart? And what are you experiencing?

dignifiedquire commented 1 month ago

I don’t have a link right now, but what I am doing is implementing LIN over uart and need to read the initial break signal, which does not translate cleanly to a uart signal.