refactore: create feature modules (#387)
* add @angular/cli to the project * increase nodejs version -> 8.2.1 * add lerna * merge web and shared module * move electron module into packages as uhk-agent Electron agent functionality is not working * delete symlinker * convert private properties to public of component if used in html * revert uhk-message.component * fix component path * fix the correct name of the uhk-message.component.scss * building web and electron module * delete uhk-renderer package * handle device connect disconnect state * add privilege detection * fix set privilege functionality * turn back download keymap functionality * add bootstrap, select2 js and fix null pointer exception * turn back upload data to keyboard * fix send keymap * fix test-serializer * add missing package.json * merging * fix appveyor build * fix linting * turn back electron storage service * commit the missing electron-datastorage-repository * update node to 8.3.0 in .nvmrc and log node version in appveyor build * set exact version number in appveyor build * vertical align privilege and missing device components * set back node version to 8 in appveyor * move node-usb dependency from usb dir to root maybe it is fix the appveyor build * revert usb to root * fix electron builder script * fix electron builder script * turn off electron devtools * remove CTRL+U functionality * fix CTRL+o * fix lint error * turnoff store freeze * start process when got `Error: EPERM: operation not permitted` error * move files from root usb dir -> packages/usb
This commit is contained in:
committed by
László Monda
parent
97770f67c0
commit
0f558e4132
41
packages/usb/read-config.js
Executable file
41
packages/usb/read-config.js
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env node
|
||||
let fs = require('fs');
|
||||
let uhk = require('./uhk');
|
||||
|
||||
const chunkSize = 63;
|
||||
|
||||
let isHardwareConfig = process.argv[2] === 'h';
|
||||
let configTypeString = isHardwareConfig ? 'hardware' : 'user';
|
||||
let isFirstSend = true;
|
||||
let isFirstReceive = true;
|
||||
let configSize;
|
||||
let offset = 0;
|
||||
let configBuffer = new Buffer(0);
|
||||
let chunkSizeToRead;
|
||||
|
||||
uhk.sendUsbPacketsByCallback(() => {
|
||||
if (isFirstSend) {
|
||||
isFirstSend = false;
|
||||
return new Buffer([uhk.usbCommands.getProperty, isHardwareConfig ? uhk.systemPropertyIds.hardwareConfigSize : uhk.systemPropertyIds.userConfigSize]);
|
||||
} else {
|
||||
chunkSizeToRead = Math.min(chunkSize, configSize - offset)
|
||||
let usbCommand = isHardwareConfig ? uhk.usbCommands.readHardwareConfig : uhk.usbCommands.readUserConfig;
|
||||
let buffer = Buffer([usbCommand, chunkSizeToRead, offset & 0xff, offset >> 8]);
|
||||
let bufferOrNull = offset >= configSize ? null : buffer;
|
||||
if (!bufferOrNull) {
|
||||
fs.writeFileSync(`${configTypeString}-config.read`, configBuffer);
|
||||
}
|
||||
offset += chunkSizeToRead;
|
||||
return bufferOrNull;
|
||||
}
|
||||
});
|
||||
|
||||
uhk.registerReceiveCallback((buffer) => {
|
||||
if (isFirstReceive) {
|
||||
isFirstReceive = false;
|
||||
configSize = buffer[1] + (buffer[2]<<8);
|
||||
console.log(`${configTypeString}configSize:`, configSize);
|
||||
} else {
|
||||
configBuffer = Buffer.concat([configBuffer, new Buffer(buffer.slice(1, chunkSizeToRead+1))]);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user