diff --git a/Dashboard/src/redux/middlewares/serialConnection.ts b/Dashboard/src/redux/middlewares/serialConnection.ts index 6a9ae39..6b5f032 100644 --- a/Dashboard/src/redux/middlewares/serialConnection.ts +++ b/Dashboard/src/redux/middlewares/serialConnection.ts @@ -51,6 +51,9 @@ const serialConnection: Middleware<{}, RootState> = (state) => (next) => (action } else if (connectionEnd.match(action)) { electron.ipcRenderer.send("asynchronous-message", "yellow"); } else if (setSerialPort.match(action)) { + if (serialPort?.isOpen) { + serialPort.close(); + } serialPort = new PortController(action.payload); } else if (sendMessage.match(action)) { serialPort?.write(action.payload);