Skip to content

Commit

Permalink
Merge pull request #1636 from sammdot/handle-serial-disconnect
Browse files Browse the repository at this point in the history
Close serial port when disconnected to ensure clean reconnection
  • Loading branch information
sammdot committed Sep 28, 2023
2 parents 15cb725 + 4075604 commit f3556d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions news.d/bugfix/1636.core.md
@@ -0,0 +1 @@
Closes serial ports upon disconnection to ensure clean reconnections.
5 changes: 5 additions & 0 deletions plover/machine/base.py
Expand Up @@ -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

Expand All @@ -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()

Expand Down

0 comments on commit f3556d0

Please sign in to comment.