【问题标题】:raspberry, cannot write to USB-Serial converter覆盆子,无法写入 USB 串行转换器
【发布时间】:2017-04-10 19:32:02
【问题描述】:

我正在使用与外部设备交互的覆盆子上的小型 Python 脚本。 该外部设备具有 RS232 和 USB 端口,我通过 USB 端口使用它。

lsusb 显示: Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial 所以我猜嵌入式设备中的USB端口内部有一个USB转串口转换器。

直到一切都很好,除了当我通过 PyUSB 打开设备时,我只能得到一个 IN 端点 (0x81) 而不是一个 OUT 端点。

所以我决定通过 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)

只有一个配置,一个接口,一个端点,并且标记为 IN。这可能吗?

提前致谢!

【问题讨论】:

    标签: linux raspberry-pi usb usbserial pyusb


    【解决方案1】:

    这个提示是:

    bInterfaceClass 3 Human Interface Device

    HID 通过中断端点将数据传输到 PC (IN)。反向使用默认控制端点(EP0)。

    所以我猜嵌入式设备中的USB端口内部有一个USB转串口转换器。

    虽然可能是这种情况,但它使用了不寻常的配置。 HID 协议不需要 PC 上的 (OEM) 驱动程序,但对数据速率的限制要低得多——这对于 UPS 等设备来说是可以的。

    TL;DR 只需像使用 pyUSB 的任何其他 HID 设备一样访问该设备,并使用 OUT(Pi=>device)方向的控制消息。

    【讨论】:

    • 你用这个答案让它运行了吗?我有完全相同的设备(ID 0665:5161 Cypress Semiconductor USB to Serial),但我无法让它工作。我对 USB 还很陌生,看到具体代码会真的很有帮助。你发送的是什么requestType (byte)?您要发送什么请求(字节)?什么value和什么index?您是否发送到设备,然后从端点读取?我在 Raspberry Pi 上使用 Java,但如果你有任何功能代码,无论是什么语言(例如 Java、Python 等),都会很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-12
    • 2017-06-21
    • 2018-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    相关资源
    最近更新 更多