mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Fix some sloppy coding from Nallath.
This commit is contained in:
parent
d91316a743
commit
40d34564c1
1 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from .avr_isp import stk500v2, ispBase
|
from .avr_isp import stk500v2, ispBase, intelHex
|
||||||
import serial
|
import serial
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
@ -158,7 +158,11 @@ class PrinterConnection(SignalEmitter):
|
||||||
for baud_rate in self._getBaudrateList(): #Cycle all baud rates (auto detect)
|
for baud_rate in self._getBaudrateList(): #Cycle all baud rates (auto detect)
|
||||||
|
|
||||||
if self._serial is None:
|
if self._serial is None:
|
||||||
self._serial = serial.Serial(str(self._serial_port), baud_rate, timeout=3, writeTimeout=10000)
|
try:
|
||||||
|
self._serial = serial.Serial(str(self._serial_port), baud_rate, timeout=3, writeTimeout=10000)
|
||||||
|
except serial.SerialException:
|
||||||
|
Logger.log('i', "Could not open port %s" % self._serial_port)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
if not self.setBaudRate(baud_rate):
|
if not self.setBaudRate(baud_rate):
|
||||||
continue #Could not set the baud rate, go to the next
|
continue #Could not set the baud rate, go to the next
|
||||||
|
@ -179,6 +183,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
self.setIsConnected(True)
|
self.setIsConnected(True)
|
||||||
Logger.log('i', "Established connection on port %s" % self._serial_port)
|
Logger.log('i', "Established connection on port %s" % self._serial_port)
|
||||||
return
|
return
|
||||||
|
self.close()
|
||||||
self.setIsConnected(False)
|
self.setIsConnected(False)
|
||||||
|
|
||||||
## Set the baud rate of the serial. This can cause exceptions, but we simply want to ignore those.
|
## Set the baud rate of the serial. This can cause exceptions, but we simply want to ignore those.
|
||||||
|
@ -211,7 +216,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
|
|
||||||
## Close the printer connection
|
## Close the printer connection
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._serial != None:
|
if self._serial is not None:
|
||||||
self._serial.close()
|
self._serial.close()
|
||||||
self.setIsConnected(False)
|
self.setIsConnected(False)
|
||||||
self._serial = None
|
self._serial = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue