I'm trying to get the node-hid (https://github.com/node-hid/node-hid) module working on Windows 7. I can open a device and write to it, but no data ever arrives.
I've verified the device is sending data. I've dug through the node-hid code (HID.cc) and tried several things to get it working:
On Windows 8, with the hid_read_timeout call change, this all works fine. I'm not sure what may have changed between the two systems, but I plan on using this on windows XP as well, so I can't just call it good.
I'm struggling to come up with more ideas as to how to debug this issue. Has anyone successfully done this before? Is there a better option to use Node.js with an HID device?
After some serious debugging, I found that for some reason I have as of yet not been able to determine, the source file, HID.cc for the node module node-hid needed a call to hid_init() within the constructor before the hid_open call. I'm assuming that somehow this is getting hit with multiple threads, making the safety of calling hid_init before hid_open necessary.
I now have this working on both windows 7 and windows 8.
Summary of changes I had to make: Add hid_init before the hid_open call I'm using. Change hid_read to hid_read_timeout in a loop. (Since reads won't return on windows XP when shutting down otherwise.)
Once I've cleaned it up, I'll send the author my changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With