From 0431bf1954c2c10f01139ea347566a1a286c7b7b Mon Sep 17 00:00:00 2001 From: Sammi De Guzman Date: Thu, 28 Sep 2023 10:56:53 -0700 Subject: [PATCH 1/2] Close serial port when disconnected to ensure clean reconnection --- plover/machine/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plover/machine/base.py b/plover/machine/base.py index 4841c5e36..7f287d35c 100644 --- a/plover/machine/base.py +++ b/plover/machine/base.py @@ -212,6 +212,7 @@ def __init__(self, serial_params): """ ThreadedStenotypeBase.__init__(self) + self._on_unhandled_exception(self._handle_disconnect) self.serial_port = None self.serial_params = serial_params @@ -221,6 +222,10 @@ def _close_port(self): self.serial_port.close() self.serial_port = None + def _handle_disconnect(self): + self._close_port() + self._error() + def start_capture(self): self._close_port() From 407560436e2c1fa29e508021ee3b03a00578cbde Mon Sep 17 00:00:00 2001 From: Sammi De Guzman Date: Thu, 28 Sep 2023 11:03:50 -0700 Subject: [PATCH 2/2] Add news blurb for #1636 --- news.d/bugfix/1636.core.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news.d/bugfix/1636.core.md diff --git a/news.d/bugfix/1636.core.md b/news.d/bugfix/1636.core.md new file mode 100644 index 000000000..3ccacdeed --- /dev/null +++ b/news.d/bugfix/1636.core.md @@ -0,0 +1 @@ +Closes serial ports upon disconnection to ensure clean reconnections.