Fix exception when disconnecting
This commit is contained in:
parent
a60acb1381
commit
6c720bd8aa
2 changed files with 6 additions and 4 deletions
|
@ -32,7 +32,7 @@ class PortController {
|
||||||
this.parser = this.port.pipe(new parsers.Readline({ delimiter: "\r\n" }));
|
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) {
|
if (this.isOpen) {
|
||||||
throw new Error("Port already open");
|
throw new Error("Port already open");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,12 @@ const connect = (): ThunkResult<void> => async (dispatch, getState) => {
|
||||||
dispatch(connectionFailure(error));
|
dispatch(connectionFailure(error));
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
if (error !== null && error !== undefined) {
|
||||||
if (error.message === "Reading from COM port (ReadIOCompletion): Access denied") {
|
if (error.message === "Reading from COM port (ReadIOCompletion): Access denied") {
|
||||||
dispatch(connectionFailure(new Error("Device disconnected")));
|
dispatch(connectionFailure(new Error(`Device ${state.serialConnection.port} disconnected`)));
|
||||||
dispatch(connectionEnd());
|
dispatch(connectionEnd());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue