USB MIDI on Teensy 3; midi debugging

Status
Not open for further replies.

cmason

Well-known member
I succeeded in getting MIDI transmit to work. I "borrowed" the code from teensy2 and massaged (read: hacked) it to work with the new usb mechanism. I'm honestly not sure what took so long, but I think ultimately I just needed to insert some delay before I started sending usb messages.

Code is here. Apologies for the mess I made there.

I'm now trying to get the USB-debug HID RAW stuff working (aka hid_listen). I'm again in this state where the teensy is recognized by the USB host but no data is transmitted (hid_listen just prints dots).

Debugging this stuff is a bit of a pain. I'd appreciate any suggestions on debugging tips. I assume there's no real debugging tools at the teensy level (like remote gdb or something). I found USB Prober on the Mac and that's somewhat useful. I'm hoping for something that would let me see the raw USB traffic from/to my Mac for a specific device. I noticed this post about debugging USB under linux, so maybe I'll just hook the teensy up to my raspberry pi and use that.

The teensy is so cool. I feel like I'm learning a ton just by hacking on it at this level. Thanks to Paul for all the effort and for providing such a great development environment with full source code.

-c
 
Hi Chris,
Much appreciate you sharing your work. This is a piece of code that I will need in the not too distant future.

Rob
 
When I attempt to use MIDI I'm told only Arduino leonardo supports MIDI. Attempting to compile gives header errors. I believe this is just the IDE getting in my way, but I thought I read MIDI wasn't yet supported.

Is this simply not so?
 
USB Debug Tools on MacosX

I don't know how useful it is, but on Linux, the "Wireshark" ethernet-packet monitoring program can also monitor USB traffic, with the usbmon module, I was able to see Teensy 3 USB traffic using it. See for example http://dangerousprototypes.com/forum/viewtopic.php?f=2&t=4606#p44948

For posterity: there's an Apple USB development page that links to the downloadable debug logging versions of the USB drivers. Then there's a tool -- USB Prober, installed in the Mac Developer tools -- which can turn on and off logging. USB Prober also has the ability to display the configuration information from attached USB devices.

However, the messages these drivers give are still incredibly cryptic and huge. The dump from the 3.5 second period in which the Teensy gets configured by the Mac host is 5000 lines long (!) and has messages like:

Code:
    2.097 [3]	IOUSBHIDDriver(IOUSBHIDDriver)[0xf66fb00]::GetHIDDescriptor Final request failed; err = 0xe000404f
    2.097 [1]	IOUSBHIDDriver(IOUSBHIDDriver)[0xf66fb00]::start - super::start returned false!
    2.097 [1]	IOUSBHIDDriver(IOUSBHIDDriver)[0xf66fb00]::start - @ 0x6200000 aborting startup
    2.097 [5]	IOUSBPipe[0xd09ac80]::AbortPipe

My strategy so far has been to grep this output for the address assigned to the Teensy by the mac (which can very between pluggings) and then stare at it for along time to read the tea leaves. For instance, this one is I believe saying that the Teensy failed to send the HID raw report descriptor.

I'm going to try running Wireshark on my raspberry pi (as my primary development machine is a mac and I imagine that running Wireshark inside a virtual machine will just complicate matters). Since making USB devices is part of the reason I was interested in the Teensy, I suppose I need to figure out way to get Wireshark working. I guess a USB protocol analyzer would be easier, but they're like $400.

Just thought I'd post this in case anyone else is crazy (read: stupid) enough to try to debug teensy USB stuff on the mac.

-c
 
When I attempt to use MIDI I'm told only Arduino leonardo supports MIDI. Attempting to compile gives header errors. I believe this is just the IDE getting in my way, but I thought I read MIDI wasn't yet supported.

Is this simply not so?

I should have noted: I'm not using the Arduino development environment. I'm just compiling using the Makefile that Paul provided and the compiler toolchain from the Arduino.app that he posted on the Teensy 3 Kickstarter page. This code is standalone, and will upload to the Teensy using Paul's Teensy Loader.

I should also note that I only have MIDI transmit working so far, not receive.

I honestly haven't found that Arduino IDE very useful. It just seems to get in the way of what's really going on. I've been using AppCode's new C++ support and, having been spoiled by their Java IDE, I'm finding the code completion and navigation stuff to be hard to live without.
 
I'm planning to work on MIDI soon. I use a Total Phase Beagle USB protocol analyzer....
 
I'd be curious to hear if Wireshark is usable on the Raspberry Pi. I booted my normally-Windows laptop into Linux for that purpose, as I assumed that the R-Pi would be too slow to run it well (plus the R-Pi has a history of USB stack issues, which last I checked are still not fully debugged.)
 
If I remember correctly Wireshark uses usbmon. I always found Wireshark cumbersome, so I used usbmon directly.

The IDE is written in Java, so we never really liked each other much. I just wrote a quick IDE with Python and ACE. I'll release code later.
 
Bambu, thanks that's useful to know. I was afraid I was going to have to setup remote X, etc.

Here's a page that seems useful talking about running usbmon directly.

I can confirm that the usbmon.ko is indeed present on the raspberry pi. Tonight I'll try to follow the above linked instructions to capture traces and report back what I find.

-c
 
When I attempt to use MIDI I'm told only Arduino leonardo supports MIDI. Attempting to compile gives header errors. I believe this is just the IDE getting in my way, but I thought I read MIDI wasn't yet supported.

Is this simply not so?

Using native USB MIDI on the Teensy is not like using serial DIN MIDI on an arduino. Specifically, you don't add the MIDI library header include to your code - because your code is not calling that library. Instead, it's all hidden away in the hardware folders. You just select USB MIDI in the IDE, and use it.

Additionally, USB MIDI on Teensy 3 is not ported yet - but you can copy across from Teensy 2 and then hack on it to make it work, as the OP is starting to do.
 
Last edited:
Hello,
Thanks to all of you who are sharing theyr knowledge.

Jus to let you know if you need to analyse and compare usbmon log you can help yourself with a free tool call Virtual USB Analyzer.
This program was originaly desing to analyse vmware output debug. but they say in the main page that you can use dump from usbmon.

Cheers.

/Ouistyty
 
Status
Not open for further replies.
Back
Top