Minor serial connection improvement
parent
ffd655d85f
commit
b4cc74f877
|
@ -74,7 +74,7 @@ class printcore():
|
||||||
if baud is not None:
|
if baud is not None:
|
||||||
self.baud=baud
|
self.baud=baud
|
||||||
if self.port is not None and self.baud is not None:
|
if self.port is not None and self.baud is not None:
|
||||||
self.printer=Serial(self.port,self.baud,timeout=5)
|
self.printer=Serial(port = self.port, baudrate = self.baud, timeout = 5)
|
||||||
Thread(target=self._listen).start()
|
Thread(target=self._listen).start()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -89,8 +89,11 @@ class printcore():
|
||||||
"""This function acts on messages from the firmware
|
"""This function acts on messages from the firmware
|
||||||
"""
|
"""
|
||||||
self.clear=True
|
self.clear=True
|
||||||
time.sleep(1.0)
|
if self.printer.inWaiting(): # flush receive buffer
|
||||||
if (not self.online and not self.printing):
|
self.printer.read(self.printer.inWaiting())
|
||||||
|
while not self.printer.inWaiting(): # wait for new data to read
|
||||||
|
time.sleep(0.5)
|
||||||
|
if (not self.online and not self.printing): # send M105 to initiate connection
|
||||||
self._send("M105")
|
self._send("M105")
|
||||||
while(True):
|
while(True):
|
||||||
if(not self.printer or not self.printer.isOpen):
|
if(not self.printer or not self.printer.isOpen):
|
||||||
|
|
Loading…
Reference in New Issue