USB cdc_acm 驅動程式未將資料介面指派給任何連接埠

USB cdc_acm 驅動程式未將資料介面指派給任何連接埠

我有一個 USB CDC-ACM 設備,模擬 USB 串行通訊。 CDC 通訊和資料介面分別顯示在 2-1:1.0(通訊)和 2-1:1.1(資料)介面描述符上,且驅動cdc_acm程式正在正確載入。

/dev/ttyACMX我的問題是驅動程式僅分配通訊接口cdc_acm,但資料接口被忽略。它似乎會阻止設備正常工作(使用 ccTalk 協議的 GBA ST2 帳單驗證器)。使用驅動程式在 Windows 8+ 上運作良好usbser.sys

使用cdc_acm驅動程序,dmesg 和 lsusb 輸出為:

$ dmesg
[ 3484.982436] usb 2-1: new full-speed USB device number 4 using ohci-pci
[ 3485.251788] usb 2-1: New USB device found, idVendor=16f9, idProduct=0003
[ 3485.251792] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3485.251794] usb 2-1: Product: GBA ST2
[ 3485.251795] usb 2-1: Manufacturer: Astrosystems
[ 3485.251796] usb 2-1: SerialNumber: 06010010001
[ 3485.260103] cdc_acm 2-1:1.0: ttyACM0: USB ACM device

$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/12p, 12M
    |__ Port 1: Dev 4, If 0, Class=Communications, Driver=cdc_acm, 12M
    |__ Port 1: Dev 4, If 1, Class=CDC Data, Driver=cdc_acm, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/12p, 480M

表明:

  • 2-1:1.0 分配給/dev/ttyACM0
  • 2-1:1.1 被忽略

透過使用usbserial驅動程式將資料介面分配給/dev/ttyUSBX端口,我發現以下操作有時作品:

  1. 插入設備並讓它使用cdc_acm驅動程式。這會導致設備退出睡眠模式(設備 LED 變為綠色)
  2. 切換到usbserial使用 的驅動程序modprobe -r cdc_acm && modprobe usbserial vendor=0x16f9 product=0x0003,導致 Comm 介面被忽略,而 Data 介面被分配給 USB 連接埠
  3. 如果裝置返回睡眠模式,則需要重新插入並從步驟 1 重新初始化

使用usbserial驅動程式時:

  • 2-1:1.0 被忽略
  • 2-1:1.1 分配給/dev/ttyUSBX

相關 dmesg 和 lsusb:

$ dmesg
[ 3688.481125] usbserial_generic 2-1:1.0: Generic device with no bulk out, not allowed.
[ 3688.481153] usbserial_generic: probe of 2-1:1.0 failed with error -5
[ 3688.481157] usbserial_generic 2-1:1.1: The "generic" usb-serial driver is only for testing and one-off prototypes.
[ 3688.481158] usbserial_generic 2-1:1.1: Tell [email protected] to add your device to a proper driver.
[ 3688.481160] usbserial_generic 2-1:1.1: generic converter detected
[ 3688.481219] usb 2-1: generic converter now attached to ttyUSB0

$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/12p, 12M
    |__ Port 1: Dev 4, If 0, Class=Communications, Driver=, 12M
    |__ Port 1: Dev 4, If 1, Class=CDC Data, Driver=usbserial_generic, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/12p, 480M

我的猜測是,設備使用 CDC 通訊介面來執行某種初始化,然後在使用時使用 CDC 資料介面。

如何將兩個介面連接到 USB 和/或 ACM 連接埠?我是否應該實現自己的驅動程式(或擴展 cdc_acm 驅動程式)以將每個描述符明確附加到 USB 或 ACM 連接埠?

以下是範例lsusb-v 輸出,顯示 2-1:1.0 上的通訊介面和 2-1:1.1 上的資料介面:

Bus 002 Device 003: ID 16f9:0003
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x16f9
  idProduct          0x0003
  bcdDevice           14.06
  iManufacturer           1 Astrosystems
  iProduct                2 GBA ST2
  iSerial                 3 06010010001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           62
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              4 GBA USB Serial Port
      CDC Header:
        bcdCDC               1.20
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              50
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0
      iInterface              4 GBA USB Serial Port
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 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:     0x0001
  Self Powered

相關內容