Problem with sendSysEx via USBHost_t36 and a guitar pedal

Status
Not open for further replies.

espoir

Member
Hey,

I'm working on a external controller for my Boss DD-500 delay guitar pedal. This pedals has midi capabilities over USB so I want to use the second usb port of the Teensy 3.6 and the USBHost_t36 library to send mostly system exclusive data to the pedal. I use the following code to check if it's working:

Code:
#include <USBHost_t36.h>
uint8_t buf[] = {0xF0, 0x41, 0x10, 0x00, 0x00, 0x00, 0x4D, 0x12, 0x30, 0x00, 0x10, 0x1F, 0x13, 0x0E, 0xF7}; //this message is a valid message, checked by sending it from Max/MSP to the pedal. 
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
MIDIDevice midi01(myusb);

void setup() {
  delay(1500);
  myusb.begin();
}

void loop() {
  midi01.sendSysEx(15,buf,true);
  delay(5000);
}

I don't receive the data on my pedal, the corresponding parameter does not change. When I use the USBMidi function of the Teensy, send the sysEx-data to my Macbook and forward it via USB to the Boss DD-500, the parameter does change. When I send midi CC-data from the Teensy direct to the pedal with for example
Code:
midi01.sendControlChange(28,127,11);
it works as well. So I think there is something wrong with how the sysEx data is sent out of the Teensy via the USB-host library, but I can't see what is going on.

When I enable USBHOST_PRINT_DEBUG in the USBHost_t36 library this is the output:

Code:
sizeof Device = 36
sizeof Pipe = 96
sizeof Transfer = 64
power up USBHS PHY
port change: 10001803
    connect
  begin reset
port change: 10001805
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 10 01 00 00 00 40 82 05 B3 01 00 01 01 02 00 01 
    VendorID = 0582, ProductID = 01B3, Version = 0100
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: BOSS
enumeration:
Product: DD-500
enumeration:
Config data length = 101
enumeration:
Configuration Descriptor:
  09 02 65 00 02 01 00 C0 00 
    NumInterfaces = 2
    ConfigurationValue = 1
  09 04 00 00 00 01 01 00 00 
    Interface = 0
    Number of endpoints = 0
    Class/Subclass/Protocol = 1 / 1 / 0
  09 24 01 00 01 09 00 01 01 
  09 04 01 00 02 01 03 00 00 
    Interface = 1
    Number of endpoints = 2
    Class/Subclass/Protocol = 1 / 3 / 0
  07 24 01 00 01 41 00 
  06 24 02 01 40 00 
  06 24 02 02 80 00 
  09 24 03 01 20 01 80 01 00 
  09 24 03 02 10 01 40 01 00 
  09 05 03 02 40 00 00 00 00 
    Endpoint = 3 OUT
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
  05 25 01 01 40 
  09 05 84 02 40 00 00 00 00 
    Endpoint = 4 IN
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
  05 25 01 01 20 
enumeration:
USBHub memory usage = 960
USBHub claim_device this=1FFF26E0
USBHub memory usage = 960
USBHub claim_device this=1FFF2AA0
USBHub memory usage = 960
USBHub claim_device this=1FFF2E60
USBHub memory usage = 960
USBHub claim_device this=1FFF3220
Descriptor 4 = INTERFACE
MIDIDevice claim this=1FFF2020
len = 92
Descriptor 36 =  ???
Descriptor 4 = INTERFACE
MIDIDevice claim this=1FFF2020
len = 74
  Interface is MIDI
type: 36, len: 7
    MIDI Header (ignored)
type: 36, len: 6
    MIDI IN Jack (ignored)
type: 36, len: 6
    MIDI IN Jack (ignored)
type: 36, len: 9
    MIDI OUT Jack (ignored)
type: 36, len: 9
    MIDI OUT Jack (ignored)
type: 5, len: 9
    MIDI Endpoint: 3
      tx_size = 64
type: 37, len: 5
    MIDI Endpoint Jack Association (ignored)
type: 5, len: 9
    MIDI Endpoint: 84
      rx_size = 64
type: 37, len: 5
    MIDI Endpoint Jack Association (ignored)
new_Pipe
new_Pipe
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 5 = ENDPOINT
Descriptor 37 =  ???
Descriptor 5 = ENDPOINT
Descriptor 37 =  ???
MIDIDevice transmit complete
  MIDI Data: 04 F0 41 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 4D 12 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 10 1F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 07 13 0E F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Does anyone have an idea what can be wrong and how to fix it?

Thanks!

Roald
 
Apparently Boss pedals are not usb midi compliant but Paul is open to addressing incompatibilities.

This one is midi usb compliant, as far as I can see. On the pedal I can change the USB mode from 'vendor' to 'generic'. When it is on 'generic' the following code does work (sending midi cc data to switch the pedal on and off via the USBHost_t36 library.) When I set it to 'vendor' it does not work.

Code:
#include <USBHost_t36.h>
int val = 0;
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
MIDIDevice midi01(myusb);

void setup() {
  delay(1500);
  myusb.begin();
}

void loop() {
  midi01.sendControlChange(28,(val++ % 2)*127,11);
  delay(5000);
}
 
No, CC does work when the pedal is in generic mode, but System Exclusive does not work. And that is the main problem..
 
How have you established it will not respond to valid sysex commands?

I don't know about you but I NEVER send good sysex on the first try. And this thing has four model# bytes and a bunch of other stuff you need to get right for even the simplest command.
 
Last edited:
I've build an editor for this pedal in javascript which works fine. It took me some time, but now I do understand how to create the correct SysEx messages, so I'm pretty sure the SysEx data is correct. And as I mentioned in my first post, if I send the data from the Teensy through the usb-midi connection to my mac and forward it with a midi-patchbay-app to the pedal it does change the parameter.
 
if I send the data from the Teensy through the usb-midi connection to my mac and forward it with a midi-patchbay-app to the pedal it does change the parameter.

Oh, if only I could somehow reproduce this here. Then I could connect my USB protocol analyzer between the Mac and the pedal, to see what's different about the USB communication.

Any chance you could help me to recreate this communication? I suppose the first step would be the get another Teensy to act as a stand-in for the pedal?

I'm not a musician. I don't actually use MIDI for anything. I own 3 cheap MIDI instruments, which I bought only for the purpose of testing Teensy's USB MIDI. I have no idea what the "midi-patchbay-app" is, and even if I did have the software, I would need pretty specific instructions to get it set up the same way you're using.

But I do know USB communication & Teensy. I wrote these libraries doing the USB MIDI, both device and host. If somehow get the same setup you're using, I do have the gear and experience to look at what's actually different between the Mac's communication and what's in USBHost_t36. If I can capture & inspect the actual USB packets, I'll probably be able to come up with a fix for USBHost_t36 to make it more compatible with this pedal.
 
Any chance you could help me to recreate this communication? I suppose the first step would be the get another Teensy to act as a stand-in for the pedal?
I hope I can, what exactly do you need to get more information about the problem? The fun thing about this pedal that it has USB-midi and midi over the standard 5 pins connectors. So I can connect two devices at the same time. Next to this I can forward the incoming data from the 5-pin-connector to USB midi or the other way around. So what I did: I used Max/MSP to send a message from my Mac to the pedal via a midi-interface, so via the 5-pin-connector. The pedal forwards this to the USB-midi port and sends it to the Teensy. When I received the sent SysEx message on the Teensy I transmitted the message I want to send to the pedal from the Teensy. Below the output of the USBHost_t36 in debug mode:

Code:
MIDIDevice Receive
  MIDI Data: 04 F0 41 10 14 F0 41 10 04 00 00 00 14 00 00 00 04 4D 12 30 14 4D 12 30 04 00 10 1F 14 00 10 1F 07 13 0E F7 17 13 0E F7 
avail = 69
queue another receive packet
read: 1041F004
read: 1041F014
read: 4
read: 14
read: 30124D04
read: 30124D14
read: 1F100004
read: 1F100014
read: F70E1307

MIDIDevice transmit complete
  MIDI Data: 04 F0 41 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 4D 12 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

read: F70E1317

MIDIDevice transmit complete
  MIDI Data: 04 00 10 1F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 07 13 0E F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The message that I sent from Max/MSP is this:
Code:
F0 41 10 00 00 00 4D 12 30 00 10 1F 13 0E F7

The pedal changed it's parameter when I sent the message from Max/MSP, but not when I sent it from the Teensy to the pedal.

Is this any useful information?

It would be great if you can come up with a fix for the library to make it work. Let me know if there is more specific information I can pass to you.
 
The debug info is interesting. Looks like part (most) of the message may be getting truncated. Hard to say for sure, and if that is the case, difficult to know if it's a bug in the library or something wrong in the main program. Also looks like the incoming data has 2 messages interleaved, but why I'm not sure. Maybe the receiving code isn't handling that well?

Any change you could write a smallest-possible program which only sends the sysex message in loop(), plus a 1 second delay. That would eliminate all the receive stuff and give us a small & simple stand-alone program for testing.

If a simple stand-alone program does work, that's useful info too. Then we can try looking at the receive code and message forwarding.
 
This is the simple every one second send a message code:
Code:
#include <USBHost_t36.h>
uint8_t buf[] = {0xF0, 0x41, 0x10, 0x00, 0x00, 0x00, 0x4D, 0x12, 0x30, 0x00, 0x10, 0x1F, 0x13, 0x0E, 0xF7}; 
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
MIDIDevice midi01(myusb);

void setup() {
  delay(1500);
  myusb.begin();
}

void loop() {
  midi01.sendSysEx(15,buf,true);
  delay(1000);
  Serial.println();
}

and this is its output:

Code:
MIDIDevice transmit complete
  MIDI Data: 04 F0 41 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 4D 12 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 10 1F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 07 13 0E F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

MIDIDevice transmit complete
  MIDI Data: 04 F0 41 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 4D 12 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 10 1F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 07 13 0E F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 
I'm getting similar issues trying to send SysEx messages to a Novation Launchpad X. I can send and receive notes fine, but I can't get SysEx messages to work. When I run this code with debugging enabled:
Code:
uint8_t data[] = {0xF0, 0x00, 0x20, 0x29, 0x02, 0x0C, 0x0E, 0x01};
midiDevice.sendSysEx(sizeof(data), *data, false, 0);
I get the following debug output:
Code:
MIDIDevice transmit complete
  MIDI Data: 04 F0 99 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 00 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 04 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
MIDIDevice transmit complete
  MIDI Data: 05 F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Was anyone able to send SysEx messages correctly?
 
I tried to narrow down the issue with short and simple SysEx messages, here's what I got.

Sending an empty message sends the SysEx start byte F0 (see https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message under "System Exclusive"), followed by F7 as the SysEx termination message. This seems to be ok.
Code:
uint8_t data0[] = {};
midi1.sendSysEx(0, *data0);
Code:
MIDI Data: 06 F0 F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Sending a one-byte message already seems to have some issue. The start and termination bytes are there, but the middle data byte 0x01 is transformed to 00.
Code:
uint8_t data1[] = {0x01};
midi1.sendSysEx(1, *data1);
Code:
MIDI Data: 07 F0 00 F7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Similarly, 0x02 gets transformed to 03, 0x03 gets transformed to 20, 0x04 gets transformed to D1... I'm not sure what is going on. It could be that I'm misunderstanding something, but I would expect that part to match. Could there be an issue with MIDIDeviceBase::write_packed()?
 
I found the issue, it was related to a missed compilation warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'const uint8_t* {aka const unsigned char*}'

Casting the parameter before passing it to the sendSysEx() method solved the issue.

With the following code I was able to put the LaunchpadX into programmer mode. Note that the device documentation specify the F0 and F7 delimiters, but these are added automatically by the USBHost_t36 library.
Code:
uint8_t data[] = {0x00, 0x20, 0x29, 0x02, 0x0C, 0x0E, 0x01};
midi1.sendSysEx(sizeof(data), (const uint8_t *)data);
 
Status
Not open for further replies.
Back
Top