chore(kboot): add more logging (#1004)
This commit is contained in:
committed by
László Monda
parent
db2e14a852
commit
4d2d6d40fb
@@ -33,13 +33,14 @@ export class UsbPeripheral implements Peripheral {
|
||||
logger('Available devices');
|
||||
const device = devices()
|
||||
.map(x => {
|
||||
logger('%O', x);
|
||||
logger('%o', x);
|
||||
|
||||
return x;
|
||||
})
|
||||
.find(deviceFinder(this.options));
|
||||
|
||||
if (!device) {
|
||||
logger('USB device can not be found %o', this.options);
|
||||
throw new Error('USB device can not be found');
|
||||
}
|
||||
|
||||
@@ -80,10 +81,12 @@ export class UsbPeripheral implements Peripheral {
|
||||
|
||||
const firsCommandResponse = await this.sendCommand(command);
|
||||
if (firsCommandResponse.tag !== ResponseTags.Generic) {
|
||||
logger('Invalid write memory response! %o', firsCommandResponse);
|
||||
return reject(new Error('Invalid write memory response!'));
|
||||
}
|
||||
|
||||
if (firsCommandResponse.code !== 0) {
|
||||
logger('Non zero write memory response! %o', firsCommandResponse);
|
||||
return reject(new Error(`Non zero write memory response! Response code: ${firsCommandResponse.code}`));
|
||||
}
|
||||
|
||||
@@ -110,10 +113,12 @@ export class UsbPeripheral implements Peripheral {
|
||||
|
||||
const secondCommandResponse = await this._getNextCommandResponse();
|
||||
if (secondCommandResponse.tag !== ResponseTags.Generic) {
|
||||
logger('Invalid write memory final response %o', secondCommandResponse);
|
||||
return reject(new Error('Invalid write memory final response!'));
|
||||
}
|
||||
|
||||
if (secondCommandResponse.code !== 0) {
|
||||
logger('Non zero write memory final response %o', secondCommandResponse);
|
||||
const msg = `Non zero write memory final response! Response code: ${secondCommandResponse.code}`;
|
||||
return reject(new Error(msg));
|
||||
}
|
||||
@@ -142,10 +147,12 @@ export class UsbPeripheral implements Peripheral {
|
||||
this._resetResponseBuffer();
|
||||
const firsCommandResponse = await this.sendCommand(command);
|
||||
if (firsCommandResponse.tag !== ResponseTags.ReadMemory) {
|
||||
logger('Invalid read memory response %o', firsCommandResponse);
|
||||
return reject(new Error('Invalid read memory response!'));
|
||||
}
|
||||
|
||||
if (firsCommandResponse.code !== 0) {
|
||||
logger('Non zero read memory response %o', firsCommandResponse);
|
||||
return reject(new Error(`Non zero read memory response! Response code: ${firsCommandResponse.code}`));
|
||||
}
|
||||
|
||||
@@ -155,10 +162,12 @@ export class UsbPeripheral implements Peripheral {
|
||||
|
||||
const secondCommandResponse = await this._getNextCommandResponse();
|
||||
if (secondCommandResponse.tag !== ResponseTags.Generic) {
|
||||
logger('Invalid read memory final response %o', secondCommandResponse);
|
||||
return reject(new Error('Invalid read memory final response!'));
|
||||
}
|
||||
|
||||
if (secondCommandResponse.code !== 0) {
|
||||
logger('Non zero read memory final response %o', secondCommandResponse);
|
||||
const msg = `Non zero read memory final response! Response code: ${secondCommandResponse.code}`;
|
||||
return reject(new Error(msg));
|
||||
}
|
||||
@@ -243,6 +252,7 @@ export class UsbPeripheral implements Peripheral {
|
||||
await snooze(100);
|
||||
}
|
||||
|
||||
logger('Timeout while try to read from buffer');
|
||||
reject(new Error('Timeout while try to read from buffer'));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user