Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kliment/Printrun
Browse files Browse the repository at this point in the history
  • Loading branch information
maisim committed Dec 10, 2014
2 parents 3a165e6 + 5162f61 commit 5a3f450
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions printrun/printcore.py
Expand Up @@ -62,10 +62,11 @@ def disable_hup(port):
control_ttyhup(port, True)

class printcore():
def __init__(self, port = None, baud = None):
def __init__(self, port = None, baud = None, dtr=None):
"""Initializes a printcore instance. Pass the port and baud rate to
connect immediately"""
self.baud = None
self.dtr = None
self.port = None
self.analyzer = gcoder.GCode()
# Serial instance connected to the printer, should be None when
Expand Down Expand Up @@ -144,7 +145,7 @@ def disconnect(self):
self.printing = False

@locked
def connect(self, port = None, baud = None):
def connect(self, port = None, baud = None, dtr=None):
"""Set port and baudrate if given, then connect to printer
"""
if self.printer:
Expand All @@ -153,6 +154,8 @@ def connect(self, port = None, baud = None):
self.port = port
if baud is not None:
self.baud = baud
if dtr is not None:
self.dtr = dtr
if self.port is not None and self.baud is not None:
# Connect to socket if "port" is an IP, device if not
host_regexp = re.compile("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$")
Expand Down Expand Up @@ -194,6 +197,8 @@ def connect(self, port = None, baud = None):
parity = PARITY_ODD)
self.printer.close()
self.printer.parity = PARITY_NONE
if platform.system() != "Linux": #there is a bug in pySerial preventing this from working on Linux, sadly.
self.printer.setDTR(dtr);
self.printer.open()
except SerialException as e:
self.logError(_("Could not connect to %s at baudrate %s:") % (self.port, self.baud) +
Expand Down
6 changes: 3 additions & 3 deletions printrun/pronsole.py
Expand Up @@ -715,9 +715,9 @@ def parse_cmdline(self, args):
# Printer connection handling
# --------------------------------------------------------------

def connect_to_printer(self, port, baud):
def connect_to_printer(self, port, baud, dtr):
try:
self.p.connect(port, baud)
self.p.connect(port, baud, dtr)
except SerialException as e:
# Currently, there is no errno, but it should be there in the future
if e.errno == 2:
Expand Down Expand Up @@ -765,7 +765,7 @@ def do_connect(self, l):
if baud != self.settings.baudrate:
self.settings.baudrate = baud
self.save_in_rc("set baudrate", "set baudrate %d" % baud)
self.connect_to_printer(port, baud)
self.connect_to_printer(port, baud,dtr)

def help_connect(self):
self.log("Connect to printer")
Expand Down
2 changes: 1 addition & 1 deletion printrun/pronterface.py
Expand Up @@ -1055,7 +1055,7 @@ def connect(self, event = None):
self.paused = 0
if self.sdprinting:
self.p.send_now("M26 S0")
if not self.connect_to_printer(port, baud):
if not self.connect_to_printer(port, baud, self.settings.dtr):
return
if port != self.settings.port:
self.set("port", port)
Expand Down
1 change: 1 addition & 0 deletions printrun/settings.py
Expand Up @@ -263,6 +263,7 @@ def __init__(self, root):
self._add(ComboSetting("baudrate", 115200, self.__baudrate_list(), _("Baud rate"), _("Communications Speed")))
self._add(BooleanSetting("tcp_streaming_mode", False, _("TCP streaming mode"), _("When using a TCP connection to the printer, the streaming mode will not wait for acks from the printer to send new commands. This will break things such as ETA prediction, but can result in smoother prints.")), root.update_tcp_streaming_mode)
self._add(BooleanSetting("rpc_server", True, _("RPC server"), _("Enable RPC server to allow remotely querying print status")), root.update_rpc_server)
self._add(BooleanSetting("dtr", True, _("DTR"), _("Disabling DTR would prevent Arduino (RAMPS) from resetting upon connection"), "Printer"))
self._add(SpinSetting("bedtemp_abs", 110, 0, 400, _("Bed temperature for ABS"), _("Heated Build Platform temp for ABS (deg C)"), "Printer"))
self._add(SpinSetting("bedtemp_pla", 60, 0, 400, _("Bed temperature for PLA"), _("Heated Build Platform temp for PLA (deg C)"), "Printer"))
self._add(SpinSetting("temperature_abs", 230, 0, 400, _("Extruder temperature for ABS"), _("Extruder temp for ABS (deg C)"), "Printer"))
Expand Down

0 comments on commit 5a3f450

Please sign in to comment.