0

I have to develop an application to communicate with a C8051F340-TB board from Silicon Labs through USB (just to be clear, I am using the P3 connector from fig. 4 of previous link, not the USB Debug Adapter from fig. 1). I have flashed the device with an example program that is supposed to echo the received data through the USB. However I cannot try it because I cannot figure out how to send data to a USB device. It is the first time I am working with a USB device at low level.

I am in Xubuntu 18.04 and the lsusb -v command says, among other things, this:

Bus 001 Device 023: ID 10c4:ea61 Cygnal Integrated Products, Inc. CP210x UART Bridge
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x10c4 Cygnal Integrated Products, Inc.
  idProduct          0xea61 CP210x UART Bridge
  bcdDevice            1.00
  iManufacturer           1 Myself
  iProduct                2 USB communication test
  iSerial                 3 0001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               64mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

which seems to be my device (I recognized the "iManufacturer" and "iProduct" fields).

How can I send a byte, or a string, or something to the device? Also, how can I read the data it sends to me?

0

For HID devices, have a look at dmesg, find the corresponding hidraw device, write to or read from that (cat, hexdump).

Depending on what HID class it is, you may also get events on /dev/event....

However, for HID devices, I'd expect

 bInterfaceClass         3 Human Interface Device

so you may not have programmed the device correctly. The HID descriptor (accessible via debugfs) must also be correct.

Also have a look at usbmon (accessible via Wireshark), and libusb, in case you can't get HID to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.