USB Host port connection detection

Status
Not open for further replies.

UHF

Well-known member
Hello, sorry if I've missed this elsewhere in the forum. I want to detect when a MIDI controller is plugged into the USB Host port of a T3.6. Is there a callback that I can use to detect this? I want to ignore MIDI CC messages (current panel settings) that are sent when certain MIDI controllers are plugged into their host. Thank you.
 
No idea here about MIDI - but as far as USB Host trying the examples:
> ...\hardware\teensy\avr\libraries\USBHost_t36\examples\Serial\MIDI\InputFunctions\InputFunctions.ino
> …\\hardware\teensy\avr\libraries\USBHost_t36\examples\Serial\MIDI\Interface_16x16\Interface_16x16.ino {this one fails on T_4.0 with TD 1.52b2 unless as indicated it is compiled with USB midi16}

With a keyboard I got my wife some years back and never plugged into anything it works to display they keys and buttons and volume control.

(edit) >> this "InputFunctions.ino" shows print text for 'CC' and other messages that could be ignored selectively

Looks gray like this 2011 model - not the newer MK3 :: https://www.amazon.com/M-Audio-Keystation-Ultra-Portable-Keyboard-Controller/dp/B005F3H6QI

Given this behavior it seems you should be able to start with one of these examples.
 
Last edited:
Thanks. Running InputFunctions gives some SysEx messages which I'm assuming are specific to the controller when it first connects, plus the selection of controller messages it's chosen to send. Nothing that is reliably a 'MIDI controller attached' signal though. I feel there must be something that can be used to signal when a USB device connects or disconnects to the host port.
 
There is a DEBUG "#define USBHOST_PRINT_DEBUG" in the USBHost library [ ...\hardware\teensy\avr\libraries\USBHost_t36\USBHost_t36.h ] that will dump a TON of spew on connect and disconnect for each device - turning that on will give the TEXT to search back to the source.

With that and plugging in this keyboard shows - then press/release a single key and turn the volume knob:
Code:
port change: 10001803
    connect
  begin reset
port change: 10001005
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 10 01 00 00 00 08 4D 0A 9D 12 10 01 01 02 00 01 
    VendorID = 0A4D, ProductID = 129D, Version = 0110
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: Keystation Mini 32
enumeration:
Product: Keystation Mini 32
enumeration:
Config data length = 101
enumeration:
Configuration Descriptor:
  09 02 65 00 02 01 00 80 20 
    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 01 00 
  06 24 02 02 02 00 
  09 24 03 01 09 01 02 01 00 
  09 24 03 02 0A 01 01 01 00 
  09 05 81 02 40 00 00 00 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
  05 25 01 01 09 
  09 05 02 02 40 00 00 00 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
  05 25 01 01 01 
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20002580
USBHub memory usage = 960
USBHub claim_device this=20002940
Descriptor 4 = INTERFACE
MIDIDevice claim this=20001EA0
len = 92
  Interface is unknown (might be Yahama)
type: 36, len: 9
    MIDI Header (ignored)
type: 4, len: 9
Descriptor 36 =  ???
Descriptor 4 = INTERFACE
MIDIDevice claim this=20001EA0
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: 81
      rx_size = 64
type: 37, len: 5
    MIDI Endpoint Jack Association (ignored)
type: 5, len: 9
    MIDI Endpoint: 2
      tx_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 Receive
  MIDI Data: avail = 79
queue another receive packet
MIDIDevice Receive
  MIDI Data: 09 90 30 2E 
avail = 78
queue another receive packet
read: 2E309009
Note On, ch=1, note=48, velocity=46
MIDIDevice Receive
  MIDI Data: 09 90 30 00 
avail = 78
queue another receive packet
read: 309009
Note Off, ch=1, note=48, velocity=0
MIDIDevice Receive
  MIDI Data: 0B B0 07 7E 
avail = 78
queue another receive packet
read: 7E07B00B
Control Change, ch=1, control=7, value=126
MIDIDevice Receive
  MIDI Data: 0B B0 07 7D 
avail = 78
queue another receive packet
read: 7D07B00B
Control Change, ch=1, control=7, value=125
 
Status
Not open for further replies.
Back
Top