serialhdl: Make sure to close the serial port on disconnect()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
0f70b420f2
commit
b0329465ec
|
@ -80,8 +80,6 @@ class SerialReader:
|
||||||
if identify_data is None:
|
if identify_data is None:
|
||||||
logging.warn("Timeout on serial connect")
|
logging.warn("Timeout on serial connect")
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.ser.close()
|
|
||||||
self.ser = None
|
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
msgparser = msgproto.MessageParser()
|
msgparser = msgproto.MessageParser()
|
||||||
|
@ -121,13 +119,15 @@ class SerialReader:
|
||||||
self.serialqueue, self.est_clock, self.last_ack_time
|
self.serialqueue, self.est_clock, self.last_ack_time
|
||||||
, self.last_ack_clock)
|
, self.last_ack_clock)
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
if self.serialqueue is None:
|
if self.serialqueue is not None:
|
||||||
return
|
|
||||||
self.ffi_lib.serialqueue_exit(self.serialqueue)
|
self.ffi_lib.serialqueue_exit(self.serialqueue)
|
||||||
if self.background_thread is not None:
|
if self.background_thread is not None:
|
||||||
self.background_thread.join()
|
self.background_thread.join()
|
||||||
self.ffi_lib.serialqueue_free(self.serialqueue)
|
self.ffi_lib.serialqueue_free(self.serialqueue)
|
||||||
self.background_thread = self.serialqueue = None
|
self.background_thread = self.serialqueue = None
|
||||||
|
if self.ser is not None:
|
||||||
|
self.ser.close()
|
||||||
|
self.ser = None
|
||||||
def stats(self, eventtime):
|
def stats(self, eventtime):
|
||||||
if self.serialqueue is None:
|
if self.serialqueue is None:
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Reference in New Issue