refactor(usb): Use hid-api instead of lib-usb (#404)

* refactor(usb): Rewrite jump-to-bootloder to node-hid

* refactor(usb): Rewrite the whole usb packages to HID-API

* refactor(usb): Deleted not valid usb command files

* refactor(usb): Deleted not supported usb commands

* Remove obsolete script.

* Remove obsolete script.

* Fix script.

* Fix script.

* No need to assign the silent property because it has been removed.

* This workaround may work on other platforms, but it certainly doesn't work on Linux. It makes some scripts not work, so I'm commenting it out.

* Fix bootloader VID and PID.
This commit is contained in:
Róbert Kiss
2017-09-06 14:32:58 +02:00
committed by László Monda
parent 3cbd3bb5ea
commit 30c74c06d3
23 changed files with 953 additions and 814 deletions

View File

@@ -1,30 +1,19 @@
#!/usr/bin/env node
let uhk = require('./uhk');
let [endpointIn, endpointOut] = uhk.getUsbEndpoints();
var arg = process.argv[2] || '';
const uhk = require('./uhk');
const device = uhk.getUhkDevice();
let lastWatchdogCounter = -1;
function monitorI2c() {
var payload = new Buffer([uhk.usbCommands.readDebugInfo]);
const payload = new Buffer([uhk.usbCommands.readDebugInfo]);
// 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);
}
let watchdogCounter = (receivedBuffer[1] << 0) + (receivedBuffer[2] << 8) + (receivedBuffer[3] << 16) + (receivedBuffer[4] << 24);
if (watchdogCounter === lastWatchdogCounter) {
process.exit(0);
}
// console.log('Received', watchdogCounter);
setTimeout(monitorI2c, 100)
})
});
device.write(uhk.getTransferData(payload));
device.write([64]);
const receivedBuffer = Buffer.from(device.readSync());
const watchdogCounter = (receivedBuffer[1] << 0) + (receivedBuffer[2] << 8) + (receivedBuffer[3] << 16) + (receivedBuffer[4] << 24);
if (watchdogCounter === lastWatchdogCounter) {
process.exit(0);
}
setTimeout(monitorI2c, 100)
}
monitorI2c();