detect serial disconnect

This commit is contained in:
liamcottle 2025-02-11 23:36:49 +13:00
parent 995e740347
commit af6403bf6a
2 changed files with 12 additions and 0 deletions

View file

@ -15,6 +15,11 @@ class SerialConnection extends Connection {
this.readBuffer = [];
this.readLoop();
// listen for disconnect
this.serialPort.addEventListener("disconnect", () => {
this.emit("disconnected");
});
// fire connected callback after constructor has returned
setTimeout(() => {
this.onConnected();