fix(usb-deployer): review fixes — reset pumpRunning on exit, clear buffer on readExact timeout
WARN-1: pumpRunning now reset to false when the pump loop exits via
{done} or error, so future startPump() isn't a silent no-op.
WARN-3: readExact clears rxBuffer on timeout to avoid stale bytes
leaking into the next non-retried STK500 command.
This commit is contained in:
parent
6f2f9c589a
commit
98adc0b860
|
|
@ -374,6 +374,8 @@ export class USBHardwareDeployer implements HardwareDeployer {
|
|||
break;
|
||||
}
|
||||
}
|
||||
/* Keep state accurate even if loop exits via {done} or error. */
|
||||
this.pumpRunning = false;
|
||||
})();
|
||||
}
|
||||
|
||||
|
|
@ -503,6 +505,9 @@ export class USBHardwareDeployer implements HardwareDeployer {
|
|||
} catch (e) {
|
||||
const got = this.rxBuffer.length;
|
||||
console.log(`[USB] readExact failed (${got} buffered): ${(e as Error).message}`);
|
||||
/* Drop any partial/stale bytes so the next command starts clean.
|
||||
The port baud hasn't changed here, so a clear is safe. */
|
||||
this.rxBuffer.clear();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue