Details on USB- no luck so far

Identification

Every device has a (unique) Vendor and Product ID. These are provided (sold) by usb.org to identify a device. You can use a library like libusbx to enumerate all connected devices and select the one with the Vendor and Product ID you are looking for.

HID Descriptors

The point of HID descriptors is actually to do away with drivers. HID descriptors are a universal way of describing your device so you don’t need to waste time on a driver for every system/architecture/etc/. (Same concept as the JVM.)

Reports

You will use either the input, output, or feature reports to read or write to your device. You send a stream to your device on the input or feature report. This is typically 8 bytes I believe. Only one of which is a single character you wish to write. The HID descriptor contains all the information you need to put together a report. Although I’m struggling to find a related link to clarify this.

Potential Libraries

In an effort to be open-minded here are all the libraries I am familiar with and some info about them.

libusb-0.1

First off is libusb-0.1. This used to be the go to and was built in to many Linux kernels and Windows I believe. It is very easy to use and there is a lot of documentation. However, the owner never updated and it wasn’t edited for many years. It supports only synchronous transfers. (If an error occurs, the program can wait infinitely while it expects a transfer.)

libusbx

Next is libusbx. This is what most people would suggest today and I agree. It was published by those frustrated by the owner of libusb-0.1. The code is much more lightweight, up-to-date, and importantly does not require root privileges like libusb-0.1 and libusb-1.0 (Discussed in a second). It supports synchronous or asynchronous transfers.

libusb-1.0

Then there is libusb-1.0. This was the first update to libusb-0.1 in some number of years. It is not compatible with libusb-0.1. This was published the same day as libusbx as a retaliation (I assume) and an attempt to rectify the lack of updated content and conserve a user-base. It supports synchronous or asynchronous transfers.

hid.h

Finally, there is the hid library. This was built on top of libusb as another layer of abstraction. But honestly, I think it’s just really confusing and it just adds more overhead than necessary.

Some Good Resources

Understanding HID Descriptors

Control Message Transfer Documentation (Very Good Link IMO)

Rolling Your Own HID Descriptor

Good Visual of HID Reports for Transfers

Great List of bmRequestType constants (You will need this or similar)

A simple terminal app for speaking with DigiSpark using libusbx and libusb-0.1

I know this isn’t exactly what you are looking for, but maybe it will get you started!

Leave a Comment