その設定

その設定

その設定

USBポートに接続されているさまざまな種類のバーコードスキャナを使用できるプログラムを作成する必要があります。

これらすべてのスキャナには「シリアルポートエミュレーション」タイプのモードがあり、(私が理解したように)単純なバイトストリームデバイスのように動作する必要があります。

しかし、スキャナの1つは異なる動作をします。最初のバイトがデータ長である固定長(64バイト)チャンクのみを送信し、チャンクの終わりまでデータバイトをゼロで埋めます。

各ブロックは、デバイスの単一の読み取り操作でのみ読み取ることができます。 1バイトも読み取ると、ブロック全体がIOストリームから消えます。

HMIデバイスで検出されたスキャナ(lsusbを使用):

Bus 001 Device 002: ID 05e0:0600 Symbol Technologies
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x05e0 Symbol Technologies
  idProduct          0x0600
  bcdDevice            0.01
  iManufacturer           1 Symbol Technologies, Inc, 2008
  iProduct                2 Symbol Bar Code Scanner
  iSerial                 3 S/N:44F1BF6A7CCE45DEB787C6D4A63A1B62 Rev:PAACLS00-001-R015
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          8 Bus Powered
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      40
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               3
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

比較のために、以下は、通常のバイトストリームデバイスと同じように動作する他のスキャナのlsusb出力です。

Bus 001 Device 003: ID 067e:0803 Intermec Technologies Corp. VCP, Barcode scanner
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         2 Abstract (modem)
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x067e Intermec Technologies Corp.
  idProduct          0x0803 VCP, Barcode scanner
  bcdDevice            2.58
  iManufacturer           1 Intermec
  iProduct                2 SR31T
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           67
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      0
      iInterface              0
      CDC Header:
        bcdCDC               1.10
      CDC ACM:
        bmCapabilities       0x00
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      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             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      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     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

バーコードスキャナーを接続するときのdmesg出力:

[19415.108131] usb 1-1: new full-speed USB device number 4 using xhci_hcd
[19415.252278] usb 1-1: New USB device found, idVendor=05e0, idProduct=0600
[19415.252295] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[19415.252305] usb 1-1: Product: Symbol Bar Code Scanner
[19415.252313] usb 1-1: Manufacturer: Symbol Technologies, Inc, 2008
[19415.252321] usb 1-1: SerialNumber: S/N:44F1BF6A7CCE45DEB787C6D4A63A1B62 Rev:PAACLS00-001-R015
[19415.273661] hid-generic 0003:05E0:0600.0008: hiddev0,hidraw6: USB HID v1.10 Device [Symbol Technologies, Inc, 2008 Symbol Bar Code Scanner] on usb-0000:00:10.0-1/input0

質問:

このスキャナをバイトストリームデバイスとして処理するようにLinuxを設定するにはどうすればよいですか?

ベストアンサー1

部分的な回答:このスキャナに「特殊COMポートドライバ」があり、Windowsコンピュータがある場合は、ドライバの初期化フェーズ中にWindowsがUSBトラフィックを聞いてシリアルポート設定に切り替える方法を確認できます。その後、このトラフィックは背中libusbを使用してLinuxで再生できます。

Windows用USBモニタリングツールには、次のものが含まれます。USBモニタリングまたはUSBCAP、詳しくはGoogleをご覧ください。

ただし、HID記述子を見ると、より簡単な代替手段が提供されます。

おすすめ記事