Send 0 and 1 instead of their ASCII counterparts.
This commit is contained in:
+4
-10
@@ -18,22 +18,16 @@ usbInterface.claim();
|
|||||||
var endpointIn = usbInterface.endpoints[0];
|
var endpointIn = usbInterface.endpoints[0];
|
||||||
var endpointOut = usbInterface.endpoints[1];
|
var endpointOut = usbInterface.endpoints[1];
|
||||||
|
|
||||||
var state = '1';
|
var state = 1;
|
||||||
|
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
console.log('Sending ', state);
|
console.log('Sending ', state);
|
||||||
state = state === '1' ? '0' : '1'
|
state = state ? 0 : 1
|
||||||
endpointOut.transfer(state, function(err) {
|
console.log(state)
|
||||||
|
endpointOut.transfer(new Buffer([state]), function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("USB error: %s", err);
|
console.error("USB error: %s", err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
endpointIn.transfer(64, function(err2, receivedStr) {
|
|
||||||
if (err2) {
|
|
||||||
console.error("USB error: %s", err2);
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
console.log('Received "%s"', receivedStr);
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|||||||
Reference in New Issue
Block a user