Fixed 1byte running status bug (GitHub issue #12)
This commit is contained in:
parent
e3dd2272e2
commit
63517510b8
41
src/MIDI.hpp
41
src/MIDI.hpp
|
|
@ -547,24 +547,6 @@ bool MidiInterface<SerialPort>::parse()
|
|||
// Else: well, we received another status byte,
|
||||
// so the running status does not apply here.
|
||||
// It will be updated upon completion of this message.
|
||||
|
||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
||||
{
|
||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.data1 = mPendingMessage[1];
|
||||
|
||||
// Save data2 only if applicable
|
||||
if (mPendingMessageExpectedLenght == 3)
|
||||
mMessage.data2 = mPendingMessage[2];
|
||||
else
|
||||
mMessage.data2 = 0;
|
||||
|
||||
mPendingMessageIndex = 0;
|
||||
mPendingMessageExpectedLenght = 0;
|
||||
mMessage.valid = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
switch (getTypeFromStatusByte(mPendingMessage[0]))
|
||||
|
|
@ -629,8 +611,29 @@ bool MidiInterface<SerialPort>::parse()
|
|||
break;
|
||||
}
|
||||
|
||||
// Then update the index of the pending message.
|
||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
||||
{
|
||||
// Reception complete
|
||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.data1 = mPendingMessage[1];
|
||||
|
||||
// Save data2 only if applicable
|
||||
if (mPendingMessageExpectedLenght == 3)
|
||||
mMessage.data2 = mPendingMessage[2];
|
||||
else
|
||||
mMessage.data2 = 0;
|
||||
|
||||
mPendingMessageIndex = 0;
|
||||
mPendingMessageExpectedLenght = 0;
|
||||
mMessage.valid = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Waiting for more data
|
||||
mPendingMessageIndex++;
|
||||
}
|
||||
|
||||
#if USE_1BYTE_PARSING
|
||||
// Message is not complete.
|
||||
|
|
|
|||
Loading…
Reference in New Issue