Like I said this is a version of the hidapi test program (the enumeration section is not needed for proper operation) that was modified quickly from a already modified version from the net to make it work the adapter SPI devices. Most of the variables and structure preexisted my modifications.Thanks! Reading your code quicky, some questions arise:
- Is "cur_dev" a C++ structure that is being instantiated dynamically?
- Why using the same instance of "buf" and "rbuf" throughout the code?
- Do you need to enumerate all the HID devices, or you can just jump to hid_open() after hid_init()?
Otherwise, the code seems to be straighthforward to me. It resembles what one would do with libusb. The MCP2210 might deserve a class, similar to what I did with the CP2130. Basically, it will be a wrapper around hiddev. I like what I see!
I'll test this. What libraries are you including in your makefile, by the way?
Original test source code:
https://github.com/libusb/hidapi/tree/master/hidtest
My system already had a udev rule to make the hidraw device. You might need to add one for your system.
https://github.com/libusb/hidapi/blob/master/udev/69-hid.rules
A wrapper example.
https://github.com/kerrydwong/MCP2210-Library
Note, the compiled code needs root access to the device and need to be run using "sudo". You may need to add the provided udev rule (99-hid.rules) to the /etc/udev/rules.d directory.
https://github.com/kerrydwong/MCP2210-Library/blob/master/99-hid.rules
Last edited: