USB Host as MIDI router

Status
Not open for further replies.

SteveBar

Well-known member
Hi Paul,
I am using the T3.6 as a MIDI router. I have a hub chip hard connected to the T3.6 host port. How can I associate the "midiList" index with the physical port? I implemented a version of this but would like to hear your ideas on how to do this. I'm asking because I'm having trouble when I plug in a MIDI product that seems to be a USB compound device.
Thanks,
Steve

Code:
USBHost myusb;
USBHub hub1(myusb);

MIDIDevice midi0(myusb);
MIDIDevice midi1(myusb);
MIDIDevice midi2(myusb);
MIDIDevice midi3(myusb);

MIDIDevice* midiList[4] = { &midi0, &midi1, &midi2, &midi3 };
 
The way the "midiList" index is linked to the physical port is by adding a call-back in enumeration.cpp in function void USBHost::enumeration().
The pointer to the device descriptor is passed in the call-back.

The call-back handler checks if the device is connected to the hard wired hub: if (dev->hub_address == 1), because multi-levels of hubs is not supported.
And then check only for MIDI devices: if (dev->bDeviceClass == 0), this is where there may be an issue because I believe, through some USB research, that the Audio (MIDI) devices = 1, not 0. However through many trials (10+ USB MIDI controllers) a device type '1' has never shown up. Further research also suggests that the device=0 means it is a USB compound device and that the USB "interface descriptor" bDeviceClass should be tested for each logical device in the compound device.

Some Q's...
1) I'm not sure "case 14:" (see below) this is the right place for the call-back to be made from. It seems like it is NOT the code location where all the logical devices are being enumerated.
2) Maybe the right place is in function USBHost::claim_drivers(), just above (~ line 400) "// not done, may be more interface for more drivers"
3) And if that is the right place the "interface descriptor" needs to get passed back to the call-back handler... but I don't see that structure anywhere in the function.

BTW the device descriptor is packed with great info!
address = dev->address
hub_address = dev->hub_address
hub_port = dev->hub_port
bDeviceClass = dev->bDeviceClass
bDeviceSubClass = dev->bDeviceSubClass
product = dev->idProduct
vender = dev->idVendor


call-back code was added here... (~ line 289)
Code:
		case 14: // device is now configured
			claim_drivers(dev);
			dev->enum_state = 15;
			// unlock exclusive access to enumeration process.  If any
			// more devices are waiting, the hub driver is responsible
			// for resetting their ports and starting their enumeration
			// when the port enables.
			USBHost::enumeration_busy = false;
             ---->   if (gAttachHandler) { gAttachHandler(dev); }
			return;
 
Status
Not open for further replies.
Back
Top