>From: Charles Lepple <[EMAIL PROTECTED]> >Date: Sat, 07 Feb 2004 13:04:07 -0500 > >Matto Marjanovic wrote: >> I'm trying to write a user-space tool for a simple HID device. All this >> device wants is to either receive or send 8 bytes in 'Report 0'. > >The method used in libhid[1] is to bypass hiddev and use libusb directly >on the usbfs nodes for the device.
Thank you for the pointer; I'll check it out. >hiddev works reasonably well for devices with simple descriptors that >conform to the HID spec, but it is much easier to work around HID >implementation bugs in userspace. The hiddev interface appears to have a fundamental design flaw: Report data is accessed via "usages", however multiple elements of a report can have the same "usage" tag. In other words: the HIDIOCG[S,G]USAGE ioctls specify the data to access via a "usage_index", which is used as an index into a field's "value" array. The actual size of that array is given by the field's "report_count". However, in hiddev.c, the usage_index is checked against "field->maxusage", not "field->report_count". "maxusage" is just the number of name-tags allocated to the values, and (from a read of the HID spec) these tags appear to be completely optional. So, it is quite possible that a field have maxusage == 0. In that case, hiddev wouldn't allow reading anything from the report at all. It seems kind of backwards to even label the operation as "get usage" or "set usage", since the 'usage' is just a 'serving suggestion' for a data element in a report. It's not a unique name. Furthermore, the "report_count" isn't officially exposed to user-space. However, for some reason, the HIDIOCGFIELDINFO ioctl returns the value "report_count - 1" in the field_index slot of the ioctl struct. -matt m. ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
