Improve shutdown time of Controller Handler.
This commit is contained in:
parent
02137a3948
commit
1e77f337b1
1 changed files with 29 additions and 26 deletions
|
@ -68,7 +68,9 @@ class MattchBox(Controller):
|
||||||
if port:
|
if port:
|
||||||
# connect to serial port
|
# connect to serial port
|
||||||
self.ser = serial.serial_for_url(port, do_not_open=True)
|
self.ser = serial.serial_for_url(port, do_not_open=True)
|
||||||
|
if self.ser:
|
||||||
self.ser.baudrate = 2400
|
self.ser.baudrate = 2400
|
||||||
|
self.ser.timeout = 0.1 # Speed up waiting for a byte.
|
||||||
try:
|
try:
|
||||||
self.ser.open()
|
self.ser.open()
|
||||||
self.logger.log.info("Connected to serial port {}".format(port))
|
self.logger.log.info("Connected to serial port {}".format(port))
|
||||||
|
@ -88,6 +90,7 @@ class MattchBox(Controller):
|
||||||
self.ser and self.ser.is_open and self.port
|
self.ser and self.ser.is_open and self.port
|
||||||
): # If self.port is changing (via state_handler), we should stop.
|
): # If self.port is changing (via state_handler), we should stop.
|
||||||
try:
|
try:
|
||||||
|
if self.ser.in_waiting > 0:
|
||||||
line = int.from_bytes(
|
line = int.from_bytes(
|
||||||
self.ser.read(1), "big"
|
self.ser.read(1), "big"
|
||||||
) # Endianness doesn't matter for 1 byte.
|
) # Endianness doesn't matter for 1 byte.
|
||||||
|
|
Loading…
Reference in a new issue