-
Notifications
You must be signed in to change notification settings - Fork 0
Yes you can! Under Linux, the standard solution for this problem is to use udev rules. Here are some links to udev related websites.
- udev homepage
- Debian's udev overview
- Writing udev rules
- Proper place to ask questions about udev rules
No, libusbx provides an API for writing software on the host. Of course, if the device also acts as a USB host then libusbx could still be useful, but only for the host part of the device.
Yes, libusbx can be used for low-level communication with USB Mass Storage Class devices. But in order to access a file on such a device you must first implement Mass Storage Class, SCSI and the particular filesystem used on the device, most commonly FAT32
.
Of course, we can not do this for you, but you can find a limited example of how to read a data block through Mass Storage using libusbx in the mass_storage test from the xusb.c sample of the the libusbx distribution.
Unlike libusb, libusbx tries tyo support USB HID devices as much as possible, as we understand there exists many generic USB HID devices out there one may want to have easy access to.
On Linux, you must detach the kernel HID driver in order to use libusbx to communicate with the device. If you have a relevant udev rule, then this API does not require root privilege to run.
On Mac OS X. you must install a codeless kext kernel driver and then reboot before you can communicate with the device. This may change once a native HID backend is written for Mac OS X.
On Windows, the native Windows HID driver is supported by libusbx. There are some limitations with regards to accessing HID mice and keyboards, as they are system reserved, as well as getting a direct read of HID report descriptors, but apart from that, you should be able to access an HID device just like any other USB device.
If you want, you can also use the HIDAPI library, by Signal 11 Software, which is also cross-platform. It uses native HID API under Windows and Mac OS X and it can use libusbx/libusb or hidraw as the backend under Linux.
