makenai / node-uvc-control

Control UVC compliant USB webcams from node
80 stars 28 forks source link

ERR_OUT_OF_RANGE buffer error, doesn't work in node 10 and above #28

Closed kevinsimper closed 5 years ago

kevinsimper commented 5 years ago

Running this in node 10.0+ you get this error running the test/default.js

It can be solved by installing and running with node 8: nvm install 8

RangeError [ERR_OUT_OF_RANGE]: The value of "byteLength" is out of range. It must be >= 1 and <= 6. Received 8
    at boundsError (internal/buffer.js:50:9)
    at Buffer.readIntLE (internal/buffer.js:241:3)
    at Device.<anonymous> (/Users/kevinsimper/Projects/test/node-uvc-control/index.js:209:29)
    at Transfer.<anonymous> (/Users/kevinsimper/Projects/test/node-uvc-control/node_modules/usb/usb.js:131:15)

The regression is talked about here: https://github.com/nodejs/node/issues/21956

I sadly don't know what the correct value should be, luckily it is the absolutePanTilt which is not that useful :)

kevinsimper commented 5 years ago

Found the problem; it is because both pan and tilt is inside the same 8 bytes, and are controlled individually. Both values goes from -36000 to 36000, so it doesn't work that well in node 8 either,

Here is the value when I only changed tilt,

absolutePanTilt 92771293593600