m1dst
March 29, 2017, 5:57pm
1
I am using a Panda III (G80) and trying to connect to USB devices. I have successfully managed to connect to a USB keyboard.
I have also tried various other devices but with each one the DeviceConnectFailed event is thrown. Is there something specific which causes this event? I was hoping for the UnknownDeviceConnected and then have to write a handler for the device but no such luck.
I have tried numerous USB devices on my desk but it might be they are too complex (eg a combined usb soundcard and rs232).
The main device I am trying to connect is a midi controller. I have managed to connect it to a USB host shield on an Arduino and get the data stream and was hoping to do the same here.
I even tried connecting a USB memory card reader with a 2GB FAT card inserted and even that triggered the DeviceConnectFailed event.
I am calling Controller.Reset (when the following events are fired; Disconnected, DeviceConnectFailed) as an attempt to resolve another issue but no such luck. I found that once the DeviceConnectFailed event had been thrown, removing the device and reinserting the keyboard caused the DeviceConnectFailed event to be thrown again. Pushing the reset button / restarting the debugger solves it.
If I insert and remove the keyboard (fresh debug session) then all works fine as many times as I do it until I insert a different device.
The code is really simple as it has just come from the samples thus farâŠ
Controller.KeyboardConnected += Controller_KeyboardConnected;
Controller.UnknownDeviceConnected += ControllerOnUnknownDeviceConnected;
Controller.DeviceConnectFailed += ControllerOnDeviceConnectFailed;
Controller.Start();
Anyone have any suggestions?
1 Like
I have the same behavior on my G80 development board.
In my case, the problem occurs if my USB device is already connected when the development board is powered up.
I perform my tests with a DSLR camera.
If I connect the USB device after booting the development board, there is no problem and the event âUnknownDeviceConnectedâ is well raised.
But from the moment the âDeviceConnectFailedâ event is thrown, I am forced to remove the power for a few seconds for everything to work properly.
I do not encounter these problems with the G400 development board.
m1dst
March 30, 2017, 2:18am
3
Interesting⊠Iâve just updated the model of the board I am using as I couldnât do it immediately due to it being my first post. I am using a Panda III which is also G80 based.
1 Like
@ m1dst -
We will take a look on this!
For now, try to call Reset right after Start()
GHI.Usb.Host.Controller.Start();
GHI.Usb.Host.Controller.Reset();
m1dst
April 3, 2017, 10:34am
5
Thanks for your reply. Just tried and it made no difference.
Once the device failed event has been thrown, no USB devices are detected until the unit is rebooted. Always throws the DeviceConnectFailed event.
The bigger problem I have is the fact the USB device wonât detect anyway.
In case it helps, here is a dump from USB Device Tree Viewer.
=========================== USB Port2 ===========================
Connection Status : 0x01 (Device is connected)
Port Chain : 1-5-3-2
Properties : 0x01
IsUserConnectable : yes
PortIsDebugCapable : no
PortHasMultiCompanions : no
PortConnectorIsTypeC : no
======================== USB Device ========================
+++++++++++++++++ Device Information ++++++++++++++++++
Device Description : USB Composite Device
Device Path : \\.\usb#vid_17cc&pid_1120#16b6f356#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Device ID : USB\VID_17CC&PID_1120\16B6F356
Hardware IDs : USB\VID_17CC&PID_1120&REV_0011 USB\VID_17CC&PID_1120
Driver KeyName : {36fc9e60-c465-11cf-8056-444553540000}\0033 (GUID_DEVCLASS_USB)
Driver : \SystemRoot\System32\drivers\usbccgp.sys (Version: Date: )
Driver Inf : C:\WINDOWS\inf\usb.inf
Legacy BusType : PNPBus
Class : USB
Class GUID : {36fc9e60-c465-11cf-8056-444553540000} (GUID_DEVCLASS_USB)
Interface GUID : {a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Service : usbccgp
Enumerator : USB
Location Info : Port_#0002.Hub_#0012
Location IDs : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(5)#USB(3)#USB(2), ACPI(_SB_)#ACPI(PCI0)#ACPI(XHC1)#ACPI(RHUB)#ACPI(HS05)#USB(3)#USB(2)
Container ID : {5d92f971-b9a8-5661-8ee4-a6fb7ff0ac81}
Manufacturer Info : (Standard USB Host Controller)
Capabilities : 0x94 (Removable, UniqueID, SurpriseRemovalOK)
Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code : 0
Address : 2
Power State : D0 (supported: D0, D2, D3, wake from D0, wake from D2)
Child Device 1 : USB Input Device
Device ID : USB\VID_17CC&PID_1120&MI_00\8&34A38A20&0&0000
Class : HIDClass
Child Device 1 : HID-compliant vendor-defined device
Device ID : HID\VID_17CC&PID_1120&MI_00\9&22480EB3&0&0000
Class : HIDClass
Child Device 2 : Traktor Kontrol F1
Device ID : USB\VID_17CC&PID_1120&MI_01\8&34A38A20&0&0001
Class : USB
Child Device 1 : Kontrol F1 Midi
Device ID : NIUSB_ENUM\NIKF1_AVS\9&A84826E&0&0
Class : MEDIA
---------------- Connection Information ---------------
Connection Index : 0x02 (2)
Connection Status : 0x01 (DeviceConnected)
Current Config Value : 0x01
Device Address : 0x19 (25)
Is Hub : 0x00 (no)
Number Of Open Pipes : 0x02 (2)
Device Bus Speed : 0x02 (High-Speed)
Pipe0ScheduleOffset : 0x00 (0)
Pipe1ScheduleOffset : 0x00 (0)
--------------- Connection Information V2 -------------
Connection Index : 0x02 (2)
Length : 0x10 (16 bytes)
SupportedUsbProtocols : 0x03
Usb110 : 1 (yes)
Usb200 : 1 (yes)
Usb300 : 0 (no)
ReservedMBZ : 0x00
Flags : 0x00
DevIsOpAtSsOrHigher : 0 (Is not operating at SuperSpeed or higher)
DevIsSsCapOrHigher : 0 (Is not SuperSpeed capable or higher)
DevIsOpAtSsPlusOrHigher : 0 (Is not operating at SuperSpeedæ±ç” or higher)
DevIsSsPlusCapOrHigher : 0 (Is not SuperSpeedæ±ç” capable or higher)
ReservedMBZ : 0x00
-------------------- Device Descriptor --------------------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x01 (Device Descriptor)
bcdUSB : 0x200 (USB Version 2.00)
bDeviceClass : 0x00 (defined by the interface descriptors)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x17CC
idProduct : 0x1120
bcdDevice : 0x0011
iManufacturer : 0x01 (String Descriptor 1)
Language 0x0409 : "Native Instruments"
iProduct : 0x02 (String Descriptor 2)
Language 0x0409 : "Traktor Kontrol F1"
iSerialNumber : 0x06 (String Descriptor 6)
Language 0x0409 : "16B6F356"
bNumConfigurations : 0x01
------------------ Configuration Descriptor -------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0039 (57 bytes)
bNumInterfaces : 0x02
bConfigurationValue : 0x01
iConfiguration : 0x04 (String Descriptor 4)
Language 0x0409 : "Traktor Kontrol F1 HID"
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0xF0 (480 mA)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x02 (2 Endpoints)
bInterfaceClass : 0x03 (HID - Human Interface Device)
bInterfaceSubClass : 0x00 (None)
bInterfaceProtocol : 0x00 (None)
iInterface : 0x00 (No String Descriptor)
------------------- HID Descriptor --------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (HID Descriptor)
bcdHID : 0x0110 (HID Version 1.10)
bCountryCode : 0x00 (00 = not localized)
bNumDescriptors : 0x01
Descriptor 1:
bDescriptorType : 0x22 (Class=Report)
wDescriptorLength : 0x01E7 (487 bytes)
Error reading descriptor : ERROR_INVALID_PARAMETER
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0040
Bits 15..13 : 0x00 (reserved, must be zero)
Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet)
Bits 10..0 : 0x40 (64 bytes per packet)
bInterval : 0x04 (4 ms)
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x01 (Direction=OUT EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0040
Bits 15..13 : 0x00 (reserved, must be zero)
Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet)
Bits 10..0 : 0x40 (64 bytes per packet)
bInterval : 0x04 (4 ms)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x01
bAlternateSetting : 0x00
bNumEndpoints : 0x00 (Default Control Pipe only)
bInterfaceClass : 0xFE (Application Specific)
bInterfaceSubClass : 0x01 (Device Firmware Upgrade)
bInterfaceProtocol : 0x01 (Runtime)
iInterface : 0x05 (String Descriptor 5)
Language 0x0409 : "Traktor Kontrol F1 DFU"
----- Device Firmware Update Functional Descriptor ----
bLength : 0x07 (7 bytes)
bDescriptorType : 0x21 (DFU Functional Descriptor)
bmAttributes : 0x07
Bit 7..4: reserved : 0x00
Bit 3: WillDetach : 0x00
Bit 2: ManifestTolerant : 0x01
Bit 1: CanUpload : 0x01
Bit 0: CanDownload : 0x01
wDetachTimeOut : 0x00FA (250 ms)
wTransferSize : 0x0040 (max 64 bytes)
bcdDFUVersion : 0x0000 (Version 0.0)
--------------- Device Qualifier Descriptor ---------------
bLength : 0x0A (10 bytes)
bDescriptorType : 0x06 (Device_qualifier Descriptor)
bcdUSB : 0x200 (USB Version 2.00)
bDeviceClass : 0x00 (Interface Class Defined Device)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x40 (64 Bytes)
bNumConfigurations : 0x01 (1 other-speed configuration)
bReserved : 0x00
------------ Other Speed Configuration Descriptor -------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x07 (Other_speed_configuration Descriptor)
wTotalLength : 0x0039 (57 bytes)
bNumInterfaces : 0x02
bConfigurationValue : 0x01
iConfiguration : 0x04 (String Descriptor 4)
Language 0x0409 : "Traktor Kontrol F1 HID"
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0xF0 (480 mA)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x02 (2 Endpoints)
bInterfaceClass : 0x03 (HID - Human Interface Device)
bInterfaceSubClass : 0x00 (None)
bInterfaceProtocol : 0x00 (None)
iInterface : 0x00 (No String Descriptor)
------------------- HID Descriptor --------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (HID Descriptor)
bcdHID : 0x0110 (HID Version 1.10)
bCountryCode : 0x00 (00 = not localized)
bNumDescriptors : 0x01
Descriptor 1:
bDescriptorType : 0x22 (Class=Report)
wDescriptorLength : 0x01E7 (487 bytes)
Error reading descriptor : ERROR_INVALID_PARAMETER
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0040
Bits 15..13 : 0x00 (reserved, must be zero)
Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet)
Bits 10..0 : 0x40 (64 bytes per packet)
bInterval : 0x03 (3 ms)
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x01 (Direction=OUT EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0040
Bits 15..13 : 0x00 (reserved, must be zero)
Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet)
Bits 10..0 : 0x40 (64 bytes per packet)
bInterval : 0x03 (3 ms)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x01
bAlternateSetting : 0x00
bNumEndpoints : 0x00 (Default Control Pipe only)
bInterfaceClass : 0xFE (Application Specific)
bInterfaceSubClass : 0x01 (Device Firmware Upgrade)
bInterfaceProtocol : 0x01 (Runtime)
iInterface : 0x05 (String Descriptor 5)
Language 0x0409 : "Traktor Kontrol F1 DFU"
----- Device Firmware Update Functional Descriptor ----
bLength : 0x07 (7 bytes)
bDescriptorType : 0x21 (DFU Functional Descriptor)
bmAttributes : 0x07
Bit 7..4: reserved : 0x00
Bit 3: WillDetach : 0x00
Bit 2: ManifestTolerant : 0x01
Bit 1: CanUpload : 0x01
Bit 0: CanDownload : 0x01
wDetachTimeOut : 0x00FA (250 ms)
wTransferSize : 0x0040 (max 64 bytes)
bcdDFUVersion : 0x0000 (Version 0.0)
-------------------- String Descriptors -------------------
------ String Descriptor 0 ------
bLength : 0x04 (4 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language ID[0] : 0x0409 (English - United States)
------ String Descriptor 1 ------
bLength : 0x26 (38 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Native Instruments"
------ String Descriptor 2 ------
bLength : 0x26 (38 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Traktor Kontrol F1"
------ String Descriptor 3 ------
bLength : 0x02 (2 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "" *!*CAUTION zero length
------ String Descriptor 4 ------
bLength : 0x2E (46 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Traktor Kontrol F1 HID"
------ String Descriptor 5 ------
bLength : 0x2E (46 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Traktor Kontrol F1 DFU"
------ String Descriptor 6 ------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "16B6F356"
----- String Descriptor 0xEE -----
bLength : 0x26 (38 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Traktor Kontrol F1"
Brett
April 3, 2017, 5:41pm
6
I was imagining some farm implement (Tractor/Traktor) but it looks like itâs this DJ Controllers : Traktor Kontrol F1 | Traktor which is still cool, but less agricultural
@ m1dst -
Donât try Reset after failed. Try at very beginning right after Start().
And try with USB thumb drive to see if we are on same boat!
m1dst
April 5, 2017, 11:18am
8
With the code below I sometimes get met with âA first chance exception of type âSystem.Exceptionâ occurred in GHI.Usb.dllâ and âAn unhandled exception of type âSystem.Exceptionâ occurred in GHI.Usb.dllâ. This happens when a USB device is plugged in and a debug session is started or once the USB is inserted. It doesnât happen every time. Odd.
I can get a USB keyboard to fire the events and even a USB stick. I can toggle the hardware and all is well.
If I change for a USB microsd card reader the âDeviceConnectFailedâ event fires and from that point all hardware (including the keyboard and USB stick which just worked) now start firing the âDeviceConnectFailedâ. I now have to stop the debug session, press the reset button and then start another debug session.
As you will see from the code it canât be any simpler.
using System;
using Microsoft.SPOT;
using GHI.Usb.Host;
using System.Threading;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
Controller.KeyboardConnected += Controller_KeyboardConnected;
Controller.MassStorageConnected += ControllerOnMassStorageConnected;
Controller.DeviceConnectFailed += ControllerOnDeviceConnectFailed;
Controller.UnknownDeviceConnected += ControllerOnUnknownDeviceConnected;
Controller.Start();
Controller.Reset();
Thread.Sleep(Timeout.Infinite);
}
private static void Controller_KeyboardConnected(object sender, Keyboard keyboard)
{
Debug.Print("Keyboard connected.");
keyboard.Disconnected += KeyboardOnDisconnected;
}
private static void KeyboardOnDisconnected(BaseDevice sender, EventArgs eventArgs)
{
Debug.Print("Keyboard disconnected.");
Controller.Reset();
}
private static void ControllerOnMassStorageConnected(object sender, MassStorage massStorage)
{
Debug.Print("Thumbdrive connected.");
massStorage.Disconnected += MassStorageOnDisconnected;
}
private static void MassStorageOnDisconnected(BaseDevice sender, EventArgs eventArgs)
{
Debug.Print("Thumbdrive disconnected.");
Controller.Reset();
}
private static void ControllerOnUnknownDeviceConnected(object sender, Controller.UnknownDeviceConnectedEventArgs unknownDeviceConnectedEventArgs)
{
Debug.Print("Unknown device connected.");
}
private static void ControllerOnDeviceConnectFailed(object sender, EventArgs eventArgs)
{
Debug.Print("Device failed.");
Controller.Reset();
}
}
}
Ran into this exact issue today using G80 TH moduleâŠ
Simple Joystick thing. USB Joystick cannot be plugged in during power up or it will never detect, exact same symptoms as this thread (including with suggestion of Controller.Reset())
Is there any resolution to this?
@ MitchT - We do not yet have a fix.
m1dst
May 8, 2017, 9:40am
11
Is there anything any of us can do to help move this forward? Have you been able to repro it or is it stuck in a backlog?
MitchT
May 8, 2017, 10:17am
12
Sigh hehâŠ
Well⊠I guess Iâm going to be using ~16 GPIO today⊠:dance:
./weller
@ m1dst - We were able to reproduce it.
MitchT
May 8, 2017, 10:27am
14
Yay repro!
If it helps any, I did notice that my USB 5v is more like 4.3v by the time the G80 takes its share and powers the flightstick. I may try shoving a proper 5V source on there.
MitchT
May 21, 2017, 3:29am
15
Bumpity bump bump.
Has there been any progress?
Is there a GHI board that isnât completely USB-Host borked that I can throw money at to resolve this?
What happened when you provided a better 5V power source?
@ MitchT - While we were able to reproduce it, we have no work around at this time.
m1dst
May 23, 2017, 3:51pm
18
Iâll add that I tried adding a solid, stable external power source and it made no difference to the stability of the USB Host. Iâm currently experimenting with rebuilding with an Arduino Due but the experience is nowhere near as nice as VS and C#.
MitchT
May 31, 2017, 2:12am
19
@ John - Well thatâs unfortunate.
Is there a confirmed GHI product that doesnât exhibit this issue? IE: G120
@ MitchT - We do not have a confirmed product at this time.