Make the test LED actually blink.

This commit is contained in:
László Monda
2016-09-26 01:40:54 +02:00
parent 4e13f910dd
commit 2b80d75211

View File

@@ -18,18 +18,22 @@ usbInterface.claim();
var endpointIn = usbInterface.endpoints[0];
var endpointOut = usbInterface.endpoints[1];
var str = '0';
console.log('Sending "%s"', str);
endpointOut.transfer(str, function(err) {
if (err) {
console.error("USB error: %s", err);
process.exit(1);
}
endpointIn.transfer(64, function(err2, receivedStr) {
if (err2) {
console.error("USB error: %s", err2);
process.exit(2);
var state = '1';
setInterval(function() {
console.log('Sending ', state);
state = state === '1' ? '0' : '1'
endpointOut.transfer(state, function(err) {
if (err) {
console.error("USB error: %s", err);
process.exit(1);
}
console.log('Received "%s"', receivedStr);
})
});
endpointIn.transfer(64, function(err2, receivedStr) {
if (err2) {
console.error("USB error: %s", err2);
process.exit(2);
}
console.log('Received "%s"', receivedStr);
})
});
}, 500)