From 9e50acd012c2a50b41296cad239ea54ea7a4e80e Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Thu, 7 Dec 2017 06:45:29 -0800 Subject: [PATCH] Use actual received length when receiving MIDI data --- midi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/midi.cpp b/midi.cpp index 83068c4..fce2162 100644 --- a/midi.cpp +++ b/midi.cpp @@ -202,7 +202,7 @@ void MIDIDevice::rx_data(const Transfer_t *transfer) print_hexbytes(transfer->buffer, rx_size); uint32_t head = rx_head; uint32_t tail = rx_tail; - uint32_t len = rx_size >> 2; // TODO: use actual received length + uint32_t len = (transfer->length - ((transfer->qtd.token >> 16) & 0x7FFF)) >> 2; for (uint32_t i=0; i < len; i++) { uint32_t msg = rx_buffer[i]; if (msg) {