View Full Version : Teensy RawHID dll and feature request

09-07-2013, 06:15 PM
The attached example code includes a simple DLL that automatically detects and sends raw HID packets to a Teensy. For example, the sketch "SimpleRawHID" will blink the LED on the Teensy 1..256 times based on the value sent in the first (0th) byte of a data packet. To upload the firmware, make sure "USB Type: Raw HID" is set. The Windows executable "example2.exe" allows the user to send data to the device.
The dll command
hidCommand(reportID, byteA, byteB, byteC: byte)
will automatically detect a Teensy, connect and send the specified data (for the sample sketch, byteA controls the flashing). If you have a different device (with a different vendor ID or product ID), you can connect using the dll command
hidConnect(VendorID,ProductID: integer)
and the example executable demonstrates this as well.

I do have one feature request: in raw HID mode, the Teensy fails to recognize any raw HID packets where the report ID is any value other than 0. To demonstrate this, load the "SimpleRawHID" sketch onto the Teensy and run the Example2.exe executable. Note that there is no flashing when the ReportID value is different from zero. It would be terrific if the Teensy could identify all report types, perhaps allowing the user to follow a RawHID.recv call with a RawHID.lastRecvReportID. This can be generally useful for raw HID communication, but particularly important for projects where we want to emulate popular raw HID APIs. For example, the attachment also includes an example sketch for mimicking the Measurement Computing 1208fs, but that device uses report IDs for several settings. Having control of this with the Teensy would make it very simple to re-use code designed for the MCC 1208fs.