Open s54b32julian opened 1 week ago
Linking the previous discussion: https://github.com/espressif/esp-idf/issues/9152#issuecomment-1757026192
Linking the previous discussion: #9152 (comment)
Was not my comment/discussion, but thanks for linking the need is the same from this person in the linked comment.
Maybe @Dazza0 ? Or has someone from the community a workaround to make this happen?
@s54b32julian What you want to do in ISR?
I have a patch for twai driver soft-filter
, which can register an RX callback, dose it meet your requiest?
0001-feat-twai-support-software-filter-for-legacy-twai-dr.patch
@wanckl : thanks for this, I will study this deeply and see if it could help me.
My task is, to react on specific messages within a tight time frame. So the goal is, while the esp32 is busy with other load heavy tasks, always when a twai message is received and put into the internal RX buffer i need an interrupt where i can set up a ISR. In this ISR I would just quickly check if it's a message i have to respond/react immediately or can schedule the task for this message (response/calcutation/IOs etc) for later.
This is in automotive CAN network absolute mandatory. Maybe a esp32 without any other task on it is with some luck able to respond in time, but with other tasks, especially with load heavy things running, nearly impossible. I currently see for this way no other possibility. And change the complete hardware to something like a MCP2515 with its external interrupt pin is no option at the moment (and maybe wasted potential of the esp32)
@s54b32julian
The patch contain an test twai_software_filter
, you can search for it.
the callback provide only the msg ID of current RX msg, to let you decide if receive it or not.
no data or other infomation provided, not sure if it is OK for you,
Wouldn't it be feasible to set up a separate control / watcher task that blocks on twai_read_alerts()
?
You should probably watch for
#define TWAI_ALERT_RX_DATA 0x00000004 /**< Alert(4): A frame has been received and added to the RX queue */
Answers checklist.
General issue report
In Automotive CAN bus it's mandatory often to respond/react to a received message within a specific or strict time frame. So the User should be able to interact with the interrupt if a TWAI message is received. I see in most external can controllers there is a HW interrupt available. I see this request/issue also from other users that want to use TWAI and change because of this to a external can controller with HW interrupt. But I'm tied to the internal TWAI of esp and have to use it.
I have read the documentation and try to find online a solution, but I couldn't solve this issue. So how can the user/I interact with the ISR? Best would be a user friendly setup but I would also happy if there is a workaround how I can access/set up this?