Emulating a USB HID Device

Status
Not open for further replies.

mike

Member
I'd like to try an emulate a USB HID device (a pedometer). I know the vendor ID and product ID of what I want to emulate. My questions are:

1. Is it possible to program the Teensy with a specific vendor and product ID? I'm guessing yes, since it can emulate a keyboard and mouse.
2. Can I write C++ code and compile that to an image that the Teensy understands? If so, what toolchain is to be used and how do I upload it to the Teensy? Since it's more complicated than a sketch, I assume using the Arduino IDE is out of the question.
3. I used wireshark to capture some USB traffic to my pedometer, how difficult is the task of emulating this on the Teensy? I have programming knowledge, but no USB programming knowledge.
4. Are there other tools/boards that would make this process any easier? Perhaps analyze and decode things better?

Essentially, what I'm trying to do is plug in the Teensy and the software will think the Teensy is the pedometer and communicate with it as such. Since I didn't write that software, I don't know the data being sent in the USB request message. However, I'm guessing it shouldn't be too difficult to reverse engineer.... but I could be wrong.

Any suggestions on how to approach this with the Teensy? Teensy 2.0 or 3.0?
 
1. Yes
2. You will just edit existing libraries. You can still use arduino IDE.
3. This is quite easy. USB code is well structured in teensy 3.0 library.
4. You need a tool to read the descriptors of the device. For example USBView is enough. If the device is more complex then some sort of analyzer is recommended. I myself have Beagle 12. Really easy to use, but it is quite expensive for hobby usage. Software analyzer that i tried before that was USBlyzer. There is 33-day trial and it costs $200. Gets the job done, but you are limited to only devices that you use with the pc the software is installed on.

Here is one project where i mimic easy transfer cable. Checking the contents of the files should give you some idea what to edit.
 
2. Can I write C++ code and compile that to an image that the Teensy understands? If so, what toolchain is to be used and how do I upload it to the Teensy? Since it's more complicated than a sketch, I assume using the Arduino IDE is out of the question.

Your best bet is to use Arduino, but you'll be editing the files in hardware/teensy/cores/teensy3. It's just C and C++ code in there. You can download Arduino and Teensyduino, run the TD installer and then look at that code. If you feel like you can understand that code, then get a Teensy3.

3. I used wireshark to capture some USB traffic to my pedometer, how difficult is the task of emulating this on the Teensy? I have programming knowledge, but no USB programming knowledge.

You're going to have to learn a bit more about USB to pull this off.

4. Are there other tools/boards that would make this process any easier? Perhaps analyze and decode things better?

For implementing the USB code, Teensy3 is probably the best choice. It's capable of all 16 endpoints in both directions. Teensy2 is limited to 7 endpoints and only unidirectional on the non-control ones, so it can't faithfully emulate a device which uses both IN and OUT on the same endpoint.

Essentially, what I'm trying to do is plug in the Teensy and the software will think the Teensy is the pedometer and communicate with it as such. Since I didn't write that software, I don't know the data being sent in the USB request message. However, I'm guessing it shouldn't be too difficult to reverse engineer.... but I could be wrong.

Your first step is going to be capturing all the device's descriptors, including any HID report descriptors. With HID, the report descriptor gives a lot of information about the format of the data.
 
Status
Not open for further replies.
Back
Top