The mac console and USB drivers

Today, I feel pretty optimistic about this project, even though I am not any closer to the goal:
“many devices these days [including this sensor] are made as generic HID (Human Interface Devices) that comply with the USB specifications, so you can enumerate and create a handle to the device (treat it like a file) within c/c++.”

Generic is good. I don’t have to write a driver. C is good, I don’t need to learn about the kernel. Ok, so it can be done, but how?

What I learned about my USB device and its driver

In applications, there is a utility called console which records error message and background processes. Clicking on the log icon shows that there are several logs going on. But only the default one shows any activity when I start the game.

USBSimpleExample: Starting

Found device 0x000091ab

dealWithDevice: found 1 configurations

found interface: 0x000092db

dealWithInterface: found 2 pipes

dealWithPipes: grabbing BULK IN pipe index 1, number 1

dealWithPipes: grabbing BULK OUT pipe index 2, number 2

It seems to me that the game called a generic USB driver called USBSimpleExample which sets up the pipe communications for the device throught the hierarchy described below:

The device is associated to pipes which are connections from the host controller to a logical entity on the device named an endpoint. The pipes are synonymous to byte streams
each pipe is uni-directional, either in or out of the device. endpoint 0 is used to control the device on the bus

To access an endpoint, a hierarchical configuration must be obtained.

1. The device connected to the bus has one (and only one) device descriptor

2. the device descriptor has one or more configuration descriptors. These configurations often correspond to states, e.g. active vs. low power mode.

3. Each configuration descriptor in turn has one or more interface descriptors, which describe certain aspects of the device, so that it may be used for different purposes: for example, a camera may have both audio and video interfaces.

4. Each interface descriptors in turn have one default interface setting and possibly more alternate interface settings

5. Each interface setting has an endpoint descriptor, as outlined above. An endpoint may however be reused among several interfaces and alternate interface settings.

Devices that attach to the bus can be full-custom devices requiring a full-custom device driver to be used, or may belong to a device class. the same device driver may be used for any device that claims to be a member of a certain class. HID is one such device class.…

So there is a generic USB driver. Somehow you tell it you want to talk to your particular device, it finds the device, talks to the device, finds out from the device how many pipes to set up, in this case one for in, one for out.

So I can learn how to access a generic USB device, or how to access a HID compliant device. A third possibility is to see if I can access my sensor through matlab and the psychtoolbox. Quite a few ways to go.

1 Comment

  1. Paris

    December 21, 2008 @ 10:57 am


    Hi Anne,

    You still out there? Saw your web page and thought you might be up on USB/Mac/Drivers/Devices/etc. I need to talk w/ someone re: this stuff.

    Up for it?

    A pleasure to meet ya . . . . Paris

Log in