Hello,
I'm using an arduino MEGA 2560, with MIDI library 4.3.1.
After some time I finally found that I cannot receive SysEx messages longer than 63bytes. The bellow instructions work fine until 63 bytes. FOr example, if I set the SysExMaxSize= 16, then I receive SysEx up to 16bytes, not longer. Code works as per settings.
But if I set a custom value above 63 bytes, which I need for my code, then it only receives SysEx messages with length <64 bytes.
Is there a hard limitation on that board? Or maybe another custom setting in the library?
Lionel
In case, here bellow is the code:
//With MIDI OUT plug to MIDI IN, this code sends to MIDI OUT a SisEx message
//with increasing size at each time a button is pressed. The code receives this
//Sysex message to the MIDI IN prints it to serial monitor.
/////////////////////////MAIN SETTINGS////////////////////////////
#include <MIDI.h>
#include <Keypad.h>
struct MySettings : public midi::DefaultSettings
{
static const unsigned SysExMaxSize = 128 ;
// Accept SysEx messages up to xxx bytes long.
//but works only bellow 64 bytes
};
// Create a 'MIDI' object using MySettings bound to Serial1.
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, MySettings);
//////////////////////////////KEYPAD//////////////////////////////////
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'a','b','c','d'},
{'e','f','g','h'},
{'i','j','k','l'},
{'m','n','o','p'}
};
byte rowPins[ROWS] = {41, 39, 37, 35}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {27, 29, 31, 33}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int i = 60; // first SysEx syze setting
void setup()
{
Serial.begin(9600);
MIDI.begin();
MIDI.turnThruOff();
}
void loop()
{
byte Message[i];
//*************************SEND******************************************
char key = keypad.getKey();
//Si une touche du clavier est enfoncée
if (key != NO_KEY)
{
for (int j = 0; j<i; j++)
{
Message[j]=0;
}
MIDI.sendSysEx(i, Message, false); // envoie le message sysex
Serial.print("SysEx sent: ");
//Boucle pour écrire dans le moniteur série le message SysEx envoyé
for (int j = 0; j<i; j++)
{
Serial.print(Message[j],HEX);
Serial.print(" ");
}
Serial.println("");
i++;
}
//*************************RECEIVE******************************************
//si un message midi est reçu
if (MIDI.read()==1)
{
int a = MIDI.getSysExArrayLength (); // récupère la longueur du message SysEx
const byte * MyArray; // Déclare la structure qui va recevoir le message SysEx
MyArray = MIDI.getSysExArray(); // Récupère le message SysEx
Serial.print("Received ");
Serial.print(a);
Serial.print(" bytes: ");
for (int i = 0; i<a; i++)
{
Serial.print(MyArray[i], HEX);
Serial.print(" ");
}
Serial.println();
}
}