0

On macOS, I use IOKit to get and set HID reports over a USB connection (for the curious, this is a controller for a standing desk that allows you to raise and lower the desk programmatically). I can get a list of devices using an IOHIDManager:

_manager = IOHIDManagerCreate(NULL, 0);

NSDictionary *deviceQuery = @{@kIOHIDVendorIDKey: @0x12D3, @kIOHIDProductIDKey: @0x0002};
IOHIDManagerSetDeviceMatching(_manager, (__bridge CFDictionaryRef)deviceQuery);
IOHIDManagerOpen(_manager, kIOHIDManagerOptionNone);

CFSetRef devices = IOHIDManagerCopyDevices(_manager);

// pick a device from the set and you eventually get a...
IOHIDDeviceRef myDevice = foo;

I then build up request buffers and make requests using:

int8_t *_buffer = ...;
IOHIDDeviceSetReport(myDevice, kIOHIDReportTypeFeature, *_buffer & 0xff, (const uint8_t *)_buffer, REQ_BUFFER_SIZE);

… and read responses using:

IOHIDDeviceGetReport(myDevice, kIOHIDReportTypeFeature, *_buffer & 0xff, (uint8_t *)_buffer, RES_BUFFER_SIZE);

What is an analogous way to do this on Linux? I've never worked with USB on Linux before (nor HID devices), and I'm open to pretty much any stack as long as it'll run on a Raspberry Pi.

Matt Patenaude
  • 4,497
  • 1
  • 22
  • 21

1 Answers1

0

to list all devices, capturing interfaces,... on linux libsub is used, see this http://www.microchip.com/forums/m340898.aspx

for the HID reports you can use usbhid-dump http://www.pkill.info/linux/man/8-usbhid-dump/ https://github.com/DIGImend/usbhid-dump or hidraw for low-level

ralf htp
  • 9,149
  • 4
  • 22
  • 34