Fix open port being discarded without closing
This commit is contained in:
parent
e1056637ab
commit
2ee4d0df48
1 changed files with 3 additions and 0 deletions
|
@ -51,6 +51,9 @@ const serialConnection: Middleware<{}, RootState> = (state) => (next) => (action
|
||||||
} else if (connectionEnd.match(action)) {
|
} else if (connectionEnd.match(action)) {
|
||||||
electron.ipcRenderer.send("asynchronous-message", "yellow");
|
electron.ipcRenderer.send("asynchronous-message", "yellow");
|
||||||
} else if (setSerialPort.match(action)) {
|
} else if (setSerialPort.match(action)) {
|
||||||
|
if (serialPort?.isOpen) {
|
||||||
|
serialPort.close();
|
||||||
|
}
|
||||||
serialPort = new PortController(action.payload);
|
serialPort = new PortController(action.payload);
|
||||||
} else if (sendMessage.match(action)) {
|
} else if (sendMessage.match(action)) {
|
||||||
serialPort?.write(action.payload);
|
serialPort?.write(action.payload);
|
||||||
|
|
Reference in a new issue