Arduino MIDI Library v4.2 - receiving SysEx Messages and print on the Serial Mon

Hallo,

i am new to the Arduino.
I have learnd a lot here, but my actual Problem now, i can't find help.
So now i hope someone fine my mistake:

I want to receive SysEx Messages from my Grand MA 2.
On my Test Setup with a Midi reading software i read this bytes:
F0 7F 7F 02 7F 06 01 01 32 64 F7

Here is my sketch that I what to use:

#include <MIDI.h> //activate MIDI
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1,     midiA); //Set Midi In to RX1 on Arduino MEGA



void setup() {
Serial.begin(9600); // activate USB on RX/TX0
// Initiate MIDI communications, listen to all channels
midiA.begin(MIDI_CHANNEL_OMNI);  
//read SysEx
midiA.setHandleSystemExclusive(handle_sysex);
}

void loop() {
// Call MIDI.read the fastest you can for real-time performance.
midiA.read();
}

//SysEx:
void handle_sysex(const byte* a,byte sizeofsysex){
 
  Serial.println(sizeofsysex,DEC);
 //Print Sysex on Serial0 on PC:
 for(int n=0;n<sizeofsysex;n++){
  Serial.print(a[n]);
  Serial.print("  ");
  }
 Serial.print('\n');
}

And here is the Error from the Compiler:

Arduino: 1.6.3 (Mac OS X), Platine: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

midi-sysex-test.ino: In function 'void setup()':
midi-sysex-test.ino:11:44: error: invalid conversion from 'void ()(const byte, byte) {aka void ()(const unsigned char, unsigned char)}' to 'void ()(byte, unsigned int) {aka void ()(unsigned char, unsigned int)}' [-fpermissive]
In file included from /Users/xxxx/Documents/Arduino/libraries/MIDI/MIDI.h:224:0,
from midi-sysex-test.ino:1:
/Users/danielwitka/Documents/Arduino/libraries/MIDI/MIDI.hpp:966:49: error: initializing argument 1 of 'void midi::MidiInterface<SerialPort, Settings>::setHandleSystemExclusive(void ()(byte, unsigned int)) [with SerialPort = HardwareSerial; Settings = midi::DefaultSettings; byte = unsigned char]' [-fpermissive]
template<class SerialPort, class Settings> void MidiInterface<SerialPort, Settings>::setHandleSystemExclusive(void (fptr)(byte array, unsigned size)) { mSystemExclusiveCallback = fptr; }
^

Can anyone help me to find my mistake?

Daniel

Remove your old Arduino 1.6.3 and upgrade to the latest Arduino 1.6.5.

Oh Sorry,

now i have updated the Software:

The error Message is the same:

Arduino: 1.6.5 (Mac OS X), Platine: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build-Optionen wurden verändert, alles wird neu gebaut
midi-sysex-test.ino: In function 'void setup()':
midi-sysex-test:11: error: invalid conversion from 'void ()(const byte, byte) {aka void ()(const unsigned char, unsigned char)}' to 'void ()(byte, unsigned int) {aka void ()(unsigned char, unsigned int)}' [-fpermissive]
In file included from /Users/xxxxx/Documents/Arduino/libraries/MIDI/MIDI.h:224:0,
from midi-sysex-test.ino:1:
/Users/xxxxx/Documents/Arduino/libraries/MIDI/MIDI.hpp:966:49: error: initializing argument 1 of 'void midi::MidiInterface<SerialPort, Settings>::setHandleSystemExclusive(void ()(byte, unsigned int)) [with SerialPort = HardwareSerial; Settings = midi::DefaultSettings; byte = unsigned char]' [-fpermissive]
template<class SerialPort, class Settings> void MidiInterface<SerialPort, Settings>::setHandleSystemExclusive(void (fptr)(byte array, unsigned size)) { mSystemExclusiveCallback = fptr; }
^
invalid conversion from 'void ()(const byte, byte) {aka void ()(const unsigned char, unsigned char)}' to 'void ()(byte, unsigned int) {aka void ()(unsigned char, unsigned int)}' [-fpermissive]

void handle_sysex(const byte* a,byte sizeofsysex){

Your declaration of the handle_sysex function does not match what is required by the library:

(*fptr)(byte* array, unsigned size)

Try:

void handle_sysex(byte* a,unsigned sizeofsysex){

Pete

Oh Thanks,

That was my mistake.
Now it works!!

Dear,

Can I use this CODE on the USBMIDI library?

I have Leonardo and I want to use this simple MIDI implementation over the USB!

Thanks!
MJ