Skip to content

Commit

Permalink
Close serial port when disconnected to ensure clean reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
sammdot committed Sep 28, 2023
1 parent 97cb4ed commit 0431bf1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plover/machine/base.py
Original file line number Diff line number Diff line change
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 0431bf1

Please sign in to comment.