Make the test LED actually blink.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user