Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for function objects in ioDeviceAttachInterrupt #136

Closed
pward123 opened this issue Oct 25, 2021 · 5 comments
Closed

Add support for function objects in ioDeviceAttachInterrupt #136

pward123 opened this issue Oct 25, 2021 · 5 comments
Assignees

Comments

@pward123
Copy link

Would it be possible to support non-static class methods as callbacks in ioDeviceAttachInterrupt?

I ran across this post where they came up with this to work around the limitation.

@davetcc
Copy link
Collaborator

davetcc commented Oct 25, 2021

We'll need to take a look at this in terms of safety, if as it looks it's already supported on ESP, then it could certainly be conditional for ESP32 and ESP8266 boards.

@davetcc davetcc added this to the 2.4.1 milestone Sep 25, 2022
@davetcc davetcc self-assigned this Sep 25, 2022
@davetcc
Copy link
Collaborator

davetcc commented Sep 25, 2022

Wow, how time flies, it's been a really busy year, but I've taken a look at this now and it looks like it would work for at least ESP32 and STM32Duino.

@davetcc
Copy link
Collaborator

davetcc commented Sep 25, 2022

see TcMenu/TaskManagerIO#42

davetcc added a commit that referenced this issue Sep 25, 2022
…ing std::function on ESP32 and STM32 boards
@davetcc davetcc closed this as completed Oct 1, 2022
@davetcc
Copy link
Collaborator

davetcc commented Oct 1, 2022

will be added in the next release of taskmanager

@davetcc
Copy link
Collaborator

davetcc commented Oct 1, 2022

Unfortunately, ESP32 does not support this directly, STM32 does, but I'm not sure how safe it even is on STM32 as I don't know how safe std::function objects are in an interrupt context.

Memory visibility and safety in interrupts is my major concern, if anything goes wrong, it would be extremely difficult to debug.

At any rate, we no longer really recommend the original interrupt marshalling, instead we suggest that people use events to handle the raw interrupt and just trigger the event. I thought this would be an easy one supported by ESP32, but unfortunately it is not. I'd recommend you just use that class in your own code with a task manager BaseEvent.

@davetcc davetcc removed this from the 2.4.1 milestone Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants