Tag: libusb

如何使用libusb将数据发送到node.js中的USB设备

我试图从设备(USB温度计)获取数据,按照这个文档https://www.npmjs.org/package/usb ,但我没有任何结果。 为了从设备获取温度数据,我应该发送类似'd \ n'的数据。 这是我的代码: var usb = require('usb'), term = usb.findByIds(65535, 2); term.open(); var endpoints = term.interfaces[0].endpoints, inEndpoint = endpoints[0], outEndpoint = endpoints[1]; inEndpoint.transferType = 2; inEndpoint.startStream(1, 64); inEndpoint.transfer(64, function (error, data) { if (!error) { console.log(data); } else { console.log(error); } }); inEndpoint.on('data', function (data) { console.log(data); }); inEndpoint.on('error', function (error) { […]