Go Down

Topic: Native USB Port of DUE loses data (Read 297 times) previous topic - next topic

roundseven

Hello,

when sending Midi data over the Native USB Port with the MIDISUSB library some data get lost. I send on 6 channels 1 pair of data (control number, control value) but instead of 6 controller data only three are sent.
When adding SerialUSB.println() 4-5 data-pairs are sent! Thats interesting but it couldn't be the solution to add several lines of prints (for all 16 channels) to make the DUE sending all data.

I recorded the outgoing data on my Mac with "Logic Pro" and also with "MIDI Monitor" to varify the outgoing data. I tried different baud rates but that didn't solved the problem. My IDE is 1.8.7.

Thats the part which is sending the Midi data:

for (int j = 0; j < 5; j++) {
    midiEventPacket_t control = {0x0B, 0xB0 | j, controlData[0][j], controlData[1][j]};
    // SerialUSB.println(j);
    MidiUSB.sendMIDI(control);
    MidiUSB.flush();
}



gbafamily

See if moving the flush() outside the loop helps like so.

Code: [Select]
for (int j = 0; j < 5; j++) {
   midiEventPacket_t control = {0x0B, 0xB0 | j, controlData[0][j], controlData[1][j]};
   MidiUSB.sendMIDI(control);
}
MidiUSB.flush();



roundseven

Thanx, I tried this, but that doesn't help.

After 2 days of trying everything I found out (1 hour ago) that a delay of 1ms solves the problem.

for (int j = 0; j < 5; j++) {
   midiEventPacket_t control = {0x0B, 0xB0 | j, controlData[0][j], controlData[1][j]};
   MidiUSB.sendMIDI(control);
   delay(1);
}

Seems the buffer or driver isn't fast enough to handle many data at the same time? To get all data for 16 channels, each with 12 bytes of controller data, without any loss, a delay of 50ms would be needed. So the buffer (or driver) is not capable of sending 192 bytes simultaneously.

Go Up