Skip to content

Commit

Permalink
firmata#136: Allow sysex messages to have the maximum size
Browse files Browse the repository at this point in the history
The START_SYEX and END_SYSEX bytes do not count
  • Loading branch information
pgrawehr committed May 13, 2023
1 parent 1b78649 commit 906165e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ConfigurableFirmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,17 @@ void FirmataClass::parse(byte inputData)
//fire off handler function
processSysexMessage();
} else {
//normal data byte - add to buffer
storedInputData[sysexBytesRead] = inputData;
sysexBytesRead++;
if (sysexBytesRead == MAX_DATA_BYTES)
{
Firmata.sendString(F("Discarding input message, out of buffer"));
parsingSysex = false;
sysexBytesRead = 0;
waitForData = 0;
if (sysexBytesRead == MAX_DATA_BYTES)
{
Firmata.sendString(F("Discarding input message, out of buffer"));
parsingSysex = false;
sysexBytesRead = 0;
waitForData = 0;
}
else {
// normal data byte - add to buffer (done after the above, so sysex messages can actually have a total length of MAX_DATA_BYTES + 2
storedInputData[sysexBytesRead] = inputData;
sysexBytesRead++;
}
}
} else if ( (waitForData > 0) && (inputData < 128) ) {
Expand Down

0 comments on commit 906165e

Please sign in to comment.