Trouble Communicating the USB Device

I am trying to communicate to a USB scanner with the USB-A port (usb host) as CDC. I have tried many libraries with no success. The closest I have come is using KurtE's libary GIGA_USBHostMBed5_devices but it fails to enumerate with error 18 (USB_TYPE_ERROR). I traced the code back and it appears that error is created when it cant find the device during the early phases of the connect sequence, however, I am seeing the vendor id and device id in the console. I attached the USB definition created from USBView on my PC for reference. This scanner does work in Windows with a serial terminal but I can't get it to work with the Giga. I am hoping someone can help who knows more about USB communications than I do.

Since I am new I cannot upload files. Here is the definition:

[Port2] : USB Serial Device

Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 2
Companion Hub Symbolic Link Name: USB#VID_174C&PID_3074#8&7a4e1fd&0&5#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no

Device Power State: PowerDeviceD0

   ---===>USB4 Information<===---

Root hub port is USB4 Capable: No
Device is tunneled through USB4: No

   ---===>Device Information<===---

English product name: "TOT2D PRODUCT USB UART"

ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address: 0x0D
Open Pipes: 3

      ===>Device Descriptor<===

bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0110
bDeviceClass: 0x02 -> This is a Communication Device
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0xAF99 = Vendor ID not listed with USB.org
idProduct: 0x8003
bcdDevice: 0x0100
iManufacturer: 0x01
English (United States) "Totinfo"
iProduct: 0x02
English (United States) "TOT2D PRODUCT USB UART"
iSerialNumber: 0x03
English (United States) "APP-000000000"
bNumConfigurations: 0x01

      ---===>Open Pipes<===---

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x82 -> Direction: IN - EndpointID: 2
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x05

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

   ---===>Full Configuration Descriptor<===---

      ===>Configuration Descriptor<===

bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x0043 -> Validated
bNumInterfaces: 0x02
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 -> Bus Powered
MaxPower: 0x32 = 100 mA

      ===>Interface Descriptor<===

bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0x01
iInterface: 0x00
-> This is a Communications (CDC Control) USB Device Interface Class

      ===>Descriptor Hex Dump<===

bLength: 0x05
bDescriptorType: 0x24
05 24 00 10 01
-> This is a Communications (CDC Control) USB Device Interface Class

      ===>Descriptor Hex Dump<===

bLength: 0x05
bDescriptorType: 0x24
05 24 01 00 01
-> This is a Communications (CDC Control) USB Device Interface Class

      ===>Descriptor Hex Dump<===

bLength: 0x04
bDescriptorType: 0x24
04 24 02 02
-> This is a Communications (CDC Control) USB Device Interface Class

      ===>Descriptor Hex Dump<===

bLength: 0x05
bDescriptorType: 0x24
05 24 06 00 01

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x82 -> Direction: IN - EndpointID: 2
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x05

      ===>Interface Descriptor<===

bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

      ===>Endpoint Descriptor<===

bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

Might help if you posted which scanner you are trying. Do you have a link for it?

Note: I am not sure if we (@Merlin513 or I) have tried using USB Host with scanners
before. We have done most of our USB Host work on Teensy boards and I ported over
some of it here for the GIGA.

From what I can tell, this device is maybe just using USB Serial (CDC ACM) communications.

Have you tried our example: USBHostSerialToSerial? Did it show anything?

You might try turning on more debug information and see if that helps.
You can do that by editing the Arduino Library: Arduino_USBHostMBbed5 in src
the file dbg.h and change #define DEBUG
I think by default it is set to 0. You might try turning it fully on and set to 4 and see
if that gives any more hints.

Good luck

1 Like

Just to confirm what @KurtE said never tried USB host with a scanner. Most of my focus was to got joysticks/controllers like XBox working with the giga.

1 Like

Thanks for the input. I was fighting some other issues so I ended up switching to the CubeIDE. The Arduino compile times are terrible with lvgl even with a fairly new computer with decent specs.

For my device, I used HAL in USB HOST. Setup the vbus enable line and it connected to my device. However, I didn't receive any data. I had to set line coding and line state and it worked. I am now receiving data. So HAL worked almost out of the box and CubeIde compile times are so much faster.