Send 0 and 1 instead of their ASCII counterparts.

This commit is contained in:
László Monda
2016-09-26 01:56:46 +02:00
parent 2b80d75211
commit 554a7b45f6
+4 -10
View File
@@ -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)