Skip to content

Commit

Permalink
Advance of processed data pointers in case of dropped packet.
Browse files Browse the repository at this point in the history
For both write and read USB routines, the processed data was not being advanced in case of invalid cable number. This has been resolved.
  • Loading branch information
AmeNote-Michael committed Feb 27, 2025
1 parent e203210 commit 4003480
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/api/Drivers/USBMIDI2/Driver/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,8 @@ Return Value:
// No need to process further if invalid Cable ID
if (!(pDeviceContext->UsbInMask & (0x0001 << cbl_num)))
{
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Invalid Data, Received invalid cable number %lu", pReceivedWords[receivedIndex]);
receivedIndex++; // drop the data
continue;
}

Expand All @@ -2159,6 +2161,8 @@ Return Value:
&pDeviceContext->midi1IsInSysex[cbl_num],
&umpPacket))
{
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! USB MIDI 1.0 Packet not processed, parsing error %lu", pReceivedWords[receivedIndex]);
receivedIndex++; // skip the data
continue;
}

Expand Down Expand Up @@ -2470,6 +2474,17 @@ Return Value:Amy

UINT8 cbl_num = umpPacket.umpData.umpBytes[0] & UMP_GROUP_MASK; // if used, cable num is group block num

// Check to see if valid cable number for USB 1.0 Device
if (!(pDeviceContext->UsbInMask & (0x0001 << cbl_num)))
{
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Invalid Data, Received invalid cable number %d", cbl_num);
// Not handled so ignore
numProcessed += umpPacket.wordCount; // ignore this UMP packet as corrupted
umpWritePacket.wordCount = 0;

continue;
}

switch (umpPacket.umpData.umpBytes[0] & UMP_MT_MASK)
{
case UMP_MT_SYSTEM: // System Common messages
Expand Down Expand Up @@ -3057,7 +3072,6 @@ Return Value:
}

WdfRequestCompleteWithInformation(Request, status, bytesWritten);
//WdfObjectDelete(Request);

return;
}
Expand Down

0 comments on commit 4003480

Please sign in to comment.