asmuelle / node-temper1

Measure temperatures with nodejs and temper1 usb thermometers
MIT License
24 stars 7 forks source link

Compatibility on macOS (OS X) #9

Closed limulus closed 8 years ago

limulus commented 8 years ago

I plan on working up a fix and submitting a PR in the upcoming days, but thought I would describe the issue while it is fresh on my mind.

On macOS, calling getDevices() returns an empty array, even if there is a compatible device connected. This is remedied by removing the item.interface===1 check.

Why does this happen? Well, as it turns out macOS does not seem to use interface numbers for USB devices. (Or something along those lines — I’m new to USB internals.) So the HID API library (which node-hid makes use of) simply hardcodes a return value for the interface number. That hardcoded value is -1.

Unfortunately, simply removing this check causes two devices to be returned (at least with my Temper1.4 sensor), and attempting to read from their shared USB path nondeterministically returns a cannot open device with path error. Hopefully I can find a way around this that does not affect compatibility with other OSes.

Thanks for this module, it will save me a bunch of time!