Browse Source

Fix some flashing bugs

pull/110/head
Malte Grimm 3 years ago
parent
commit
b284a3fad1
  1. 3
      src/components/Dashboard.tsx
  2. 60
      src/core/flashing/Flasher.ts

3
src/components/Dashboard.tsx

@ -140,7 +140,7 @@ const DeviceList = ({devices, rootConfig, totalConfigCount}: {devices: Device[],
disabled={totalConfigCount == 0 || overallFlashingState.state == "busy"} disabled={totalConfigCount == 0 || overallFlashingState.state == "busy"}
onClick={async () => { onClick={async () => {
// rootConfig.children[0].getFinalConfig(); // FIXME // rootConfig.children[0].getFinalConfig(); // FIXME
if(overallFlashingState.state == "idle") if(overallFlashingState.state == "idle") {
setOverallFlashingState({ state: "busy" }); setOverallFlashingState({ state: "busy" });
let actualFirmware = firmware; let actualFirmware = firmware;
debugger; debugger;
@ -167,6 +167,7 @@ const DeviceList = ({devices, rootConfig, totalConfigCount}: {devices: Device[],
setOverallFlashingState({state, progress}); setOverallFlashingState({state, progress});
}); });
}
nextBatch(devices, nextBatch(devices,
deviceSelectedToFlash, /* EXTREMELY HACKY -- FIX THIS */ deviceSelectedToFlash, /* EXTREMELY HACKY -- FIX THIS */
(f)=> { (f)=> {

60
src/core/flashing/Flasher.ts

@ -45,7 +45,8 @@ export async function setup(configs: ConfigPreset[], deviceModelName: string, fi
} }
export async function nextBatch(devices: Device[], flashStates: FlashState[], deviceCallback: (flashState: FlashOperation) => void) { export async function nextBatch(devices: Device[], flashStates: FlashState[], deviceCallback: (flashState: FlashOperation) => void) {
callback("busy"); callback("busy");
debugger;
devices = devices.filter((d, i) => flashStates[i].state == "doFlash"); devices = devices.filter((d, i) => flashStates[i].state == "doFlash");
flashStates = flashStates.filter(f => f.state == "doFlash"); flashStates = flashStates.filter(f => f.state == "doFlash");
if(devices.length > configQueue.length) { if(devices.length > configQueue.length) {
@ -285,33 +286,38 @@ export class FlashOperation {
await this.loader!.disconnect(); await this.loader!.disconnect();
} }
this.setState("config"); try {
await port!.setSignals({requestToSend: true}); this.setState("config");
await new Promise(r => setTimeout(r, 100)); await port!.setSignals({requestToSend: true});
await port!.setSignals({requestToSend: false}); await new Promise(r => setTimeout(r, 100));
await port!.close(); await port!.setSignals({requestToSend: false});
const connection = (this.device.connection! as ISerialConnection); await port!.close();
await connection.connect({ const connection = (this.device.connection! as ISerialConnection);
port, await connection.connect({
baudRate: undefined, port,
concurrentLogOutput: true baudRate: undefined,
}); concurrentLogOutput: true
});
const newConfig = new Protobuf.Config({
payloadVariant: { const newConfig = new Protobuf.Config({
case: "device", payloadVariant: {
value: this.config.device! case: "device",
} value: this.config.device!
}); }
const promise = connection.setConfig(newConfig).then(() => });
connection.commitEditSettings().then(() => console.log("FLASHER: Config saved")) const promise = connection.setConfig(newConfig).then(() =>
); connection.commitEditSettings().then(() => console.log("FLASHER: Config saved"))
).catch(e => console.error(e));
// We won't get an answer if serial output has been disabled in the new config
if(this.config.device!.serialEnabled) // We won't get an answer if serial output has been disabled in the new config
await promise; if(this.config.device!.serialEnabled)
await promise;
this.setState("done"); this.setState("done");
}
catch(e) {
this.setState("failed");
}
} }
public async cancel() { public async cancel() {

Loading…
Cancel
Save