Vastly simplify jump-to-bootloader.js by using uhk.sendUsbPacket()

This commit is contained in:
László Monda
2017-01-15 03:24:33 +01:00
parent 73f682193a
commit e54c1df13e

View File

@@ -1,19 +1,3 @@
#!/usr/bin/env node
let uhk = require('./uhk');
let [endpointIn, endpointOut] = uhk.getUsbEndpoints();
var payload = new Buffer([uhk.usbCommands.jumpToBootloader]);
console.log('Sending ', uhk.bufferToString(payload));
endpointOut.transfer(payload, function(err) {
if (err) {
console.error("USB error: %s", err);
process.exit(1);
}
endpointIn.transfer(64, function(err2, receivedBuffer) {
if (err2) {
console.error("USB error: %s", err2);
process.exit(2);
}
console.log('Received', uhk.bufferToString(receivedBuffer));
})
});
uhk.sendUsbPacket(new Buffer([uhk.usbCommands.jumpToBootloader]));