Make jump-to-bootloader.js able to reenumerate the UHK as BusPal proxy.
This commit is contained in:
@@ -6,6 +6,9 @@ let pollingIntervalMs = 100;
|
|||||||
let bootloaderTimeoutMs = 5000;
|
let bootloaderTimeoutMs = 5000;
|
||||||
let jumped = false;
|
let jumped = false;
|
||||||
|
|
||||||
|
console.log(process.argv[2])
|
||||||
|
let enumerationMode = process.argv[2] === 'buspal' ? uhk.enumerationModes.busPal : uhk.enumerationModes.bootloader;
|
||||||
|
|
||||||
console.log('Trying to jump to the bootloader...');
|
console.log('Trying to jump to the bootloader...');
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
timeoutMs -= pollingIntervalMs;
|
timeoutMs -= pollingIntervalMs;
|
||||||
@@ -26,8 +29,14 @@ setInterval(() => {
|
|||||||
if (device && !jumped) {
|
if (device && !jumped) {
|
||||||
console.log('UHK found, jumping to bootloader');
|
console.log('UHK found, jumping to bootloader');
|
||||||
let t = bootloaderTimeoutMs;
|
let t = bootloaderTimeoutMs;
|
||||||
device.write(uhk.getTransferData(new Buffer([uhk.usbCommands.jumpToBootloader, 0, t&0xff, (t&0xff<<8)>>8, (t&0xff<<16)>>16, (t&0xff<<24)>>24])));
|
let message = new Buffer([uhk.usbCommands.jumpToBootloader, enumerationMode, t&0xff, (t&0xff<<8)>>8, (t&0xff<<16)>>16, (t&0xff<<24)>>24]);
|
||||||
|
console.log(message);
|
||||||
|
device.write(uhk.getTransferData(message));
|
||||||
jumped = true;
|
jumped = true;
|
||||||
|
|
||||||
|
if (enumerationMode == uhk.enumerationModes.busPal) {
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, pollingIntervalMs);
|
}, pollingIntervalMs);
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ exports = module.exports = moduleExports = {
|
|||||||
readDebugInfo: 17,
|
readDebugInfo: 17,
|
||||||
jumpToSlaveBootloader: 18,
|
jumpToSlaveBootloader: 18,
|
||||||
},
|
},
|
||||||
|
enumerationModes: {
|
||||||
|
bootloader: 0,
|
||||||
|
busPal: 1,
|
||||||
|
normalKeyboard: 2,
|
||||||
|
compatibleKeyboard: 3,
|
||||||
|
},
|
||||||
systemPropertyIds: {
|
systemPropertyIds: {
|
||||||
usbProtocolVersion: 0,
|
usbProtocolVersion: 0,
|
||||||
bridgeProtocolVersion: 1,
|
bridgeProtocolVersion: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user