diff --git a/Dashboard/src/PortController.ts b/Dashboard/src/PortController.ts index 44ea6be..123d86d 100644 --- a/Dashboard/src/PortController.ts +++ b/Dashboard/src/PortController.ts @@ -32,7 +32,7 @@ class PortController { this.parser = this.port.pipe(new parsers.Readline({ delimiter: "\r\n" })); } - open(callback: (error:Error | null | undefined)=>void, onCloseCallback:(error:Error)=>void) { + open(callback: (error:Error | null | undefined)=>void, onCloseCallback:(error:Error | null | undefined)=>void) { if (this.isOpen) { throw new Error("Port already open"); } diff --git a/Dashboard/src/redux/actions/asyncSerialConnectionActions.ts b/Dashboard/src/redux/actions/asyncSerialConnectionActions.ts index f241cdd..de2d6a5 100644 --- a/Dashboard/src/redux/actions/asyncSerialConnectionActions.ts +++ b/Dashboard/src/redux/actions/asyncSerialConnectionActions.ts @@ -25,9 +25,11 @@ const connect = (): ThunkResult => async (dispatch, getState) => { dispatch(connectionFailure(error)); } }, (error) => { - if (error.message === "Reading from COM port (ReadIOCompletion): Access denied") { - dispatch(connectionFailure(new Error("Device disconnected"))); - dispatch(connectionEnd()); + if (error !== null && error !== undefined) { + if (error.message === "Reading from COM port (ReadIOCompletion): Access denied") { + dispatch(connectionFailure(new Error(`Device ${state.serialConnection.port} disconnected`))); + dispatch(connectionEnd()); + } } }); };