Node.js 从usb读取数据时发生超时错误(错误号:2)
尝试从usb读取数据时,我收到Node.js 从usb读取数据时发生超时错误(错误号:2),node.js,usb,libusb,node-usb,Node.js,Usb,Libusb,Node Usb,尝试从usb读取数据时,我收到LIBUSB\u TRANSFER\u TIMED\u OUT错误(errcode:2)。 我正在使用模块 如果有人能指出我的错误,那就太好了 function onUsbAttached(device) { console.log('you gotta usb.\n'); device.open(); // open the device. // console.log(device.interfaces); var syncI
LIBUSB\u TRANSFER\u TIMED\u OUT
错误(errcode:2
)。
我正在使用模块
如果有人能指出我的错误,那就太好了
function onUsbAttached(device) {
console.log('you gotta usb.\n');
device.open(); // open the device.
// console.log(device.interfaces);
var syncInterface = device.interfaces[0]; // sync interface
var asyncInterface = device.interfaces[1]; // async interface
// console.log('incomingEndpoint', incomingEndpoint);
if(syncInterface.isKernelDriverActive()){
console.log('Kernel driver is active. Detaching kernel driver.');
syncInterface.detachKernelDriver();
}
console.log('Claiming interface');
syncInterface.claim();
var INendpoint = syncInterface.endpoints[0];
var OUTendpoint = syncInterface.endpoints[1];
// .controlTransfer(bmRequestType, bRequest, wValue, wIndex, data_or_length, callback(error, data))
device.controlTransfer(0xC0, 0x32, 0, 0, 1, function (err, data) {
if(err){
console.log('Error while getting data', err);
return ;
}
console.log('Got some data.', data);
});
};