-
Notifications
You must be signed in to change notification settings - Fork 65
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
calling write(MB,msg) from a function pointer function creates issue #67
Comments
does the regular write(msg) work? |
I don’t recall if it worked or not, I believe it did not but I cannot remember the behavior when I tried the regular write. I will confirm and try the cast though. Thanks :) |
Same behavior as original issue. |
Doing a malloc for the size of the message structure seemed to get the program to at least reset… however no change in behavior as far as proper functioning. |
So I think I figured this out. Using your FlexCAN_T4 object as an extern in a different C file creates allll sorts of issues. I moved everything into one file and it seemed to work out. Not sure if this is how this is supposed to work (C++ classes are still confusing to me), but that one threw me through a loop. |
Should also note, using a pointer instead of extern also created the same issues. |
Can confirm this and am seeing hard lockups when the FlexCAN_T4 object is declared extern within .h/.cpp files. Lockups occur every time when calling Strangely this does not seem to be occurring if all files are using .ino extensions. I believe when using the arduino/PIO compile scripts with .ino files, the scope of the Can0 object will become global and the extern is ignored. |
Attached is a simple example showing this. It has been tested on a Teensy 3.5 This will send a msg every 500ms and report back over Serial the total number of msgs sent. By default the Can0 object is not declared extern and everything works fine. If you uncomment the |
Hey, not sure if this is the right mechanism to explain this issue, but I am trying to call the write(mb,msg) function from a function called by a pointer, and the entire program crashes and does not recover. I do get one CAN TX, that is not always packed correctly, but that is all.
I don't know enough about all of this to make a call what is wrong, or if I am out of line trying to call a write with a function pointer, but here is the relevant code snippets minus some of the CAN setup:
Setup:
Pointer call:
Function from pointer function:
Not sure if this is an library issue, or just my bad code. Function pointer calls work great with any other function though.
The text was updated successfully, but these errors were encountered: