0

I'm working on a small Python script on a raspberry that interacts with an external device. that external device has either RS232 and USB ports and I'm using it through the USB port.

lsusb shows: Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial So i guess that the USB port in the embedded device internally has a USB to Serial converter.

Till there everything is fine, except that when I open the device through PyUSB I can only get an IN endpoint (0x81) but not an OUT endpoint.

So I decided to inspect through lsusb -v:

Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0665 Cypress Semiconductor
  idProduct          0x5161 USB to Serial
  bcdDevice            0.02
  iManufacturer           3 (error)
  iProduct                1 (error)
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      27
          Report Descriptor: (length is 27)
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Input, data= [ 0x82 ] 130
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Volatile Bitfield
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Output, data= [ 0x82 ] 130
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Volatile Bitfield
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              12
Device Status:     0x0000
  (Bus Powered)

There is only one configuration, one interface, one endpoint and that's marked as IN. Is that possible?

Thanks in advance!

payam_sbr
  • 1,428
  • 1
  • 15
  • 24
ZeroMemory
  • 23
  • 6

1 Answers1

1

This hint is:

bInterfaceClass 3 Human Interface Device

HID transports data to the PC (IN) via an interrupt endpoint. The reverse direction uses the default control endpoint (EP0).

So i guess that the USB port in the embedded device internally has a USB to Serial converter.

While this may be the case, it uses an unusual configuration. The HID protocol won't require (OEM) drivers on a PC, but has much lower limits on data rates- which is OK for devices like an UPS.

TL;DR Just access the device like any other HID device with pyUSB, and use control messages for the OUT (Pi=>device) direction.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • Did you get it running with this answer? I have exactly the same device (ID 0665:5161 Cypress Semiconductor USB to Serial) and I don't manage to get it work. I'm pretty new to USB and it would be *really* helpful to see concrete code. What *requestType (byte)* are you sending? What *request (byte)* are you sending? What *value* and what *index*? Are you sending to the *device*, but then reading from the endpoint? I'm using Java on a Raspberry Pi, but if you have just any functional code, no matter in a what language (e.g. Java, Python, whatever), it would be really helpful. – Marco Sep 25 '18 at 16:38