Inexplicable error T4-1

MadMike

Member
Code snippet from usb_midi.h
void setHandleProgramChange(void (*fptr)(uint8_t channel, uint8_t program))
{
// type: 0xC0 ProgramChange
// usb_midi_handleProgramChange = fptr; //zzz
}
if "usb_midi_handleProgramChange = fptr; (above) is commented out, every thing works just fine. If its not commented out, teensy does not work, and is not visible to the programmer - button must be pressed.
Ubuntu 22.04.
Eclipse with Sloeber add-on.
SD card present.
Audio card present.
Many files (hence Eclipse).
I've tried everything I can think of, including banging my head on my PC.
Any suggestions/thoughts/etc can only help.

Regards, Mike
 
What is the value of fptr? Are you sure that's not where the crash is happening?
1. usbMIDI.setHandleProgramChange(mProgramChange); mProgramChange points at a correct and present function.
2. extern void (*usb_midi_handleProgramChange)(uint8_t ch, uint8_t program);
3.
if (usb_midi_handleProgramChange)
(*usb_midi_handleProgramChange)(ch, (n >> 16));
 
1. usbMIDI.setHandleProgramChange(mProgramChange); mProgramChange points at a correct and present function.
2. extern void (*usb_midi_handleProgramChange)(uint8_t ch, uint8_t program);
3.
if (usb_midi_handleProgramChange)
(*usb_midi_handleProgramChange)(ch, (n >> 16));
Also the error I reported exists without running running setHandleProgramChange; the error occurs with just the presence of usb_midi_handleProgramChange = fptr. Almost as if the linker is putting this function in some wrong place.
 
If its not commented out, teensy does not work, and is not visible to the programmer - button must be pressed.

Can you reproduce this problem with the same (or similar) code in Arduino IDE?

If so, can you give us a complete program anyone can copy into Arduino IDE and upload to Teensy to reproduce the problem? We're much better at solving problems when we're able to reproduce them. But that takes a full program, not just a few lines.

Just to be realistic, relatively few people use Eclipse and Sloeber. It also tends to be configurable which gives you powerful features but that flexibility adds a lot of uncertainty when trying to share code to reproduce a problem. Pretty much everyone has Arduino IDE, and Arduino's lack of customization for compiler command lines and other stuff is a huge benefit when reproducing a tough problem.

If you're completely stuck and nobody here has a good answer, please know the path forward is to create a small program in Arduino IDE that reproduces the problem and then share the complete code, so anyone can copy it into Arduino IDE to easily reproduce the issue.
 
Can you reproduce this problem with the same (or similar) code in Arduino IDE?

If so, can you give us a complete program anyone can copy into Arduino IDE and upload to Teensy to reproduce the problem? We're much better at solving problems when we're able to reproduce them. But that takes a full program, not just a few lines.

Just to be realistic, relatively few people use Eclipse and Sloeber. It also tends to be configurable which gives you powerful features but that flexibility adds a lot of uncertainty when trying to share code to reproduce a problem. Pretty much everyone has Arduino IDE, and Arduino's lack of customization for compiler command lines and other stuff is a huge benefit when reproducing a tough problem.

If you're completely stuck and nobody here has a good answer, please know the path forward is to create a small program in Arduino IDE that reproduces the problem and then share the complete code, so anyone can copy it into Arduino IDE to easily reproduce the issue.
Thanks. I'll give the Arduino IDE a try. May take a few days.
 
The name of "mProgramChange" sounds like it is a member function of a c++ class, if that is the case it can't be used as a callback and should give a compilation error unless there is an explicit cast being used.
Again, it would really help to see a complete code listing.
 
Or put more concisely a callback is a function, not a method. If you are using classes and methods you always need some global variable holding a pointer to an instance if you want a callback (or interrupt come to that) to run a method - there is no implicit instance when calling from such a context.
 
Hi, Made a small .ino, but I cannot reproduce my problem. Something about Eclipse+Sloeber, perhaps. Sob and sniff. Meanwhile, thanks for the suggestions from the respondents. I shall continue to try and solve the problem.
 
Back
Top