2014-03-27 4 views
4

이 문서 https://www.npmjs.org/package/usb에 따라 장치 (USB 온도계)에서 데이터를 가져 오려고했지만 결과가 없습니다.libusb를 사용하여 node.js의 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) { 
    console.log(error); 
}); 
outEndpoint.transferType = 2; 
outEndpoint.startStream(1, 64); 
outEndpoint.transfer(new Buffer('d\n'), function (err) { 
    console.log(err); 
}); 

내가 이것을 가지고 실행 한 후 :

D:\Dev\USBTest\node_modules\usb\usb.js:261 
    t.submit(new Buffer(self.streamTransferSize), transferDone) 
    ^
Error: LIBUSB_ERROR_NOT_FOUND 
    at startTransfer (D:\Dev\USBTest\node_modules\usb\usb.js:261:5) 
    at Array.forEach (native) 
    at InEndpoint.startStream (D:\Dev\USBTest\node_modules\usb\usb.js:264:23) 
    at D:\Dev\USBTest\app.js:15:16 
    at Object.<anonymous> (D:\Dev\USBTest\app.js:35:2) 
    at Module._compile (module.js:456:26) 
    at Object.Module._extensions..js (module.js:474:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Function.Module.runMain (module.js:497:10) 

답변

관련 문제