feat(device): Read user config from eeprom (#413)

* feat(device): Read user config from eeprom

* read data from eeprom

* fix user config serialization

* fix device connected detection

* not allow override default config is eeprom is empty

* add error handling to eeprom parsing

* colorize log output

* add USB[T] feature

* add class name to USB[T] log

* remove redundant error log msg

* Add USB[T] to Apply user config
This commit is contained in:
Róbert Kiss
2017-09-17 14:45:20 +02:00
committed by László Monda
parent d621b1e5e6
commit 96e968729d
11 changed files with 185 additions and 33 deletions

View File

@@ -4,10 +4,27 @@ import * as util from 'util';
import { LogService } from 'uhk-common';
const transferRegExp = /USB\[T]:/;
const writeRegExp = /USB\[W]:/;
const readRegExp = /USB\[R]: 00/;
const errorRegExp = /(?:(USB\[R]: ([^0]|0[^0])))/;
// https://github.com/megahertz/electron-log/issues/44
// console.debug starting with Chromium 58 this method is a no-op on Chromium browsers.
if (console.debug) {
console.debug = console.log;
console.debug = (...args: any[]): void => {
if (writeRegExp.test(args[0])) {
console.log('%c' + args[0], 'color:blue');
} else if (readRegExp.test(args[0])) {
console.log('%c' + args[0], 'color:green');
} else if (errorRegExp.test(args[0])) {
console.log('%c' + args[0], 'color:red');
}else if (transferRegExp.test(args[0])) {
console.log('%c' + args[0], 'color:orange');
} else {
console.log(...args);
}
};
}
/**
@@ -21,7 +38,7 @@ if (console.debug) {
*/
@Injectable()
export class ElectronLogService implements LogService {
private static getErrorText(args: any) {
public static getErrorText(args: any) {
return util.inspect(args);
}