Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  42] [ 6]  / answers: 1 / hits: 29988  / 10 Years ago, thu, march 27, 2014, 12:00:00

I have try to get data from device (USB thermometer), following this documentation, but I have not any result.


For getting themperature data from device, I should send the data like that 'dn'.


This is my code:


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('dn'), function (err) {
console.log(err);
});

After running I have got this:


D:DevUSBTestnode_modulesusbusb.js:261
t.submit(new Buffer(self.streamTransferSize), transferDone)
^
Error: LIBUSB_ERROR_NOT_FOUND
at startTransfer (D:DevUSBTestnode_modulesusbusb.js:261:5)
at Array.forEach (native)
at InEndpoint.startStream (D:DevUSBTestnode_modulesusbusb.js:264:23)
at D:DevUSBTestapp.js:15:16
at Object.<anonymous> (D:DevUSBTestapp.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)

More From » node.js

 Answers
11

You forgot to call interface.claim().



https://github.com/nonolith/node-usb#claim


[#71745] Wednesday, March 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
angelr

Total Points: 399
Total Questions: 96
Total Answers: 101

Location: Finland
Member since Sun, May 21, 2023
1 Year ago
;