-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug description
I believe the CAN Alert type is wrongly defined.
As seen here, it is built using EnumSet.
The corresponding definition in esp-idf is here
I believe there is a 1-bit offset in the definition, due to 1-indexing instead of 0-indexing.
In other places in the codebase (eg: the UART driver), we can see 0-indexing is used.
- Would you like to work on a fix?
I can make a PR if needed, if you agree this is indeed wrong
To Reproduce
As an example, using the following:
dbg!((Alert::BusRecovered | Alert::ReceiveQueueFull | Alert::BusOffline).as_repr())prints
(Alert::BusRecovered | Alert::ReceiveQueueFull | Alert::BusOffline).as_repr() = 20608
Looking at the ReceiveQueueFull bit, we should have 0x800 set (see definition in esp-idf).
> hex(20608)
0x5080
> 0x5080 & 0x800
0
> 0x5080 & 0x1000
4096
Moreover, I can see the problem in application code: I need to set Alert::TransmitFailed instead of Alert::ReceiveQueueFull to receive alerts when loosing an incoming frame.
Expected behavior
The Alert EnumSet should match the values in esp-idf.
Environment
- Crate (
esp-idf-hal) version: 0.45.2 - ESP-IDF branch or tag: v5.4
- Target device (MCU): esp32s3
- OS: MacOS 15.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done