HID USBデバイスにデータを書き込むには?

HID USBデバイスにデータを書き込むには?

作業するアプリケーションを開発する必要があります。C8051F340-TBUSB経由のSilicon Labs開発ボードでは(明らかに、図1のUSBデバッグアダプタではなく、前のリンクの図4のP3コネクタを使用しています)。 USB経由で受信したデータをエコーするサンプルプログラムでデバイスをフラッシュしました。ところで、USBデバイスにデータを送信する方法がわからないため、試すことはできません。低レベルでUSBデバイスを使用するのは今回が初めてです。

私はXubuntu 18.04にあり、lsusb -vコマンドは何よりも次のことを示しています。

Bus 001 Device 023: ID 10c4:ea61 Cygnal Integrated Products, Inc. CP210x UART Bridge
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x10c4 Cygnal Integrated Products, Inc.
  idProduct          0xea61 CP210x UART Bridge
  bcdDevice            1.00
  iManufacturer           1 Myself
  iProduct                2 USB communication test
  iSerial                 3 0001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               64mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 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:     0x0000
  (Bus Powered)

これは私のデバイスのようです(「iManufacturer」フィールドと「iProduct」フィールドを認識します)。

バイト、文字列、またはその他のコンテンツをデバイスに送信するにはどうすればよいですか?また、送信されたデータをどのように読みますか?

ベストアンサー1

HIDデバイスの場合、dmesgそのhidrawデバイスを表示、検索、デバイスの書き込みまたは読み取り(cathexdump)。

HIDカテゴリによってもイベントを受け取ることができます/dev/event...

ただし、HIDデバイスの場合

 bInterfaceClass         3 Human Interface Device

したがって、デバイスが正しくプログラムされていない可能性があります。 HID記述子(debugfsを介してアクセス可能)も正確でなければなりません。

また、HIDが機能しない場合に備えてusbmon(Wiresharkを介してアクセス可能)とを確認してください。libusb

おすすめ記事