![USB 장치를 HID로 등록하려면 어떻게 해야 합니까?](https://linux55.com/image/142747/USB%20%EC%9E%A5%EC%B9%98%EB%A5%BC%20HID%EB%A1%9C%20%EB%93%B1%EB%A1%9D%ED%95%98%EB%A0%A4%EB%A9%B4%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%ED%95%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
하드웨어 장치가 있고 HID 라이브러리를 통해 C로 통신하고 싶습니다. 그러나 장치가 HID로 표시되지 않습니다. 이를 수행할 수 있는 방법이 있습니까(아마도 udev 규칙을 사용하여)?
$ dmesg
usb 1-2: new full-speed USB device number 7 using xhci_hcd
usb 1-2: New USB device found, idVendor=104d, idProduct=3001
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: ESP301 Motion Control
usb 1-2: Manufacturer: NEWPORT Corp.
usb 1-2: SerialNumber: 0000000000000000
$ lsusb -v
Bus 001 Device 007: ID 104d:3001 Newport Corporation
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x104d Newport Corporation
idProduct 0x3001
bcdDevice 1.01
iManufacturer 1 NEWPORT Corp.
iProduct 2 ESP301 Motion Control
iSerial 3 0000000000000000
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 2
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
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
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 1
Device Status: 0x0001
Self Powered
답변1
HID 자체는 실제로 장치 유형이 아니지만 다양한 장치 유형과 상호 작용하기 위한 표준 프로토콜입니다(USB에 의존하지도 않고 Bluetooth, I2C 및 기타 하위 수준 통신 프로토콜을 통해서도 사용됨). 그러나 장치 자체가 프로토콜을 지원해야 합니다. 그렇지 않으면 소프트웨어가 장치에 전달하는 내용을 이해할 수 없습니다.
귀하의 경우 문제의 장치는 VSC(공급업체별 클래스)로 식별된 단일 엔드포인트를 제공합니다. 이는 설계자가 다른 표준 USB 장치 유형에 적합하지 않다고 생각했다는 것을 표현하는 멋진 방법입니다. 이러한 일부 장치에는 다른 모드로 전환하기 위해 전송할 수 있는 특수 명령이 있을 수 있습니다. 여기에는 HID 모드로 전환하는 명령이 포함될 수 있으며 장치 설명서에 설명되어 있습니다.
그러나 실제로는 libusb를 사용하여 일반적인 명령 세트를 사용하여 장치와 직접 통신하고 HID의 오버헤드를 건너뛸 수 있습니다.