TSG
TSG

Reputation: 4625

HID USB access vs libusb

I need to access a USB device from C++ under Linux and am totally new to USB interfacing. The device I'm accessing does not come with any driver - but shows up as an HID device. The device is similar to a machine controller (simple shorts commands in/out). It's not like a mouse/keyboard - so I'm not sure if it SHOULD show up as a HID device.

From what I've read, my options are to access it as a HID device, or blacklist it and access it using libusb. (Please correct me if I got that wrong). It seems like HID access is the way to go - otherwise I have to write a kernel driver for the device.

It would seem like HID access is preferable. Is there an example of how to communicate with a device using HID under Linux? This is a simple USB device with one USB configuration, one read endpoint and one write endpoint.

Upvotes: 4

Views: 7138

Answers (1)

Preston
Preston

Reputation: 2653

I recommend using hidapi. If your device is already setup to work as such, this is a better way than libusb. libusb will work, but you will likely need to implement the HID spec as well as the protocol for your device. If you just use hidapi then you should just have to implement the protocol for the device on top of the hidapi layer. I think I recall that hidapi is also implemented on top of libusb anyway.

Upvotes: 4

Related Questions