
USB 通信経由シリアルをエミュレートする USB CDC-ACM デバイスがあります。CDC 通信およびデータ インターフェイスは、それぞれ 2-1:1.0 (Comm) および 2-1:1.1 (Data) インターフェイス記述子に表示され、ドライバーはcdc_acm
適切にロードされています。
/dev/ttyACMX
私の問題は、通信インターフェイスのみがドライバーによって割り当てられcdc_acm
、データ インターフェイスが無視されることです。デバイスが正常に動作しないようです (ccTalk プロトコルを使用する GBA ST2 Bill Validator)。ドライバーを使用すると、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
ポートに割り当てると、次の操作が見つかりました。時々作品:
- デバイスを接続して
cdc_acm
ドライバーを使用します。これにより、デバイスのスリープ モードが終了します (デバイスの LED が緑色になります) usbserial
を使用するドライバーに切り替えるとmodprobe -r cdc_acm && modprobe usbserial vendor=0x16f9 product=0x0003
、Commインターフェースは無視され、DataインターフェースがUSBポートに割り当てられます。- デバイスがスリープモードに戻った場合は、再度接続して手順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 ポートに接続するにはどうすればよいですか? 各記述子を USB ポートまたは ACM ポートに明示的に接続するには、独自のドライバーを実装する (または cdc_acm ドライバーを拡張する) 必要がありますか?
lsusb
以下は、2-1:1.0 の通信インターフェースと 2-1:1.1 のデータ インターフェースを示すサンプル -v 出力です。
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