Commit 5162f61a authored by Guillaume Seguin's avatar Guillaume Seguin

Merge pull request #598 from NeoTheFox/master

Added DTR switch
parents b2f95128 1477324f
...@@ -62,10 +62,11 @@ def disable_hup(port): ...@@ -62,10 +62,11 @@ def disable_hup(port):
control_ttyhup(port, True) control_ttyhup(port, True)
class printcore(): 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 """Initializes a printcore instance. Pass the port and baud rate to
connect immediately""" connect immediately"""
self.baud = None self.baud = None
self.dtr = None
self.port = None self.port = None
self.analyzer = gcoder.GCode() self.analyzer = gcoder.GCode()
# Serial instance connected to the printer, should be None when # Serial instance connected to the printer, should be None when
...@@ -144,7 +145,7 @@ class printcore(): ...@@ -144,7 +145,7 @@ class printcore():
self.printing = False self.printing = False
@locked @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 """Set port and baudrate if given, then connect to printer
""" """
if self.printer: if self.printer:
...@@ -153,6 +154,8 @@ class printcore(): ...@@ -153,6 +154,8 @@ class printcore():
self.port = port self.port = port
if baud is not None: if baud is not None:
self.baud = baud self.baud = baud
if dtr is not None:
self.dtr = dtr
if self.port is not None and self.baud is not None: if self.port is not None and self.baud is not None:
# Connect to socket if "port" is an IP, device if not # 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])$") 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])$")
...@@ -194,6 +197,8 @@ class printcore(): ...@@ -194,6 +197,8 @@ class printcore():
parity = PARITY_ODD) parity = PARITY_ODD)
self.printer.close() self.printer.close()
self.printer.parity = PARITY_NONE 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() self.printer.open()
except SerialException as e: except SerialException as e:
self.logError(_("Could not connect to %s at baudrate %s:") % (self.port, self.baud) + self.logError(_("Could not connect to %s at baudrate %s:") % (self.port, self.baud) +
......
...@@ -715,9 +715,9 @@ class pronsole(cmd.Cmd): ...@@ -715,9 +715,9 @@ class pronsole(cmd.Cmd):
# Printer connection handling # Printer connection handling
# -------------------------------------------------------------- # --------------------------------------------------------------
def connect_to_printer(self, port, baud): def connect_to_printer(self, port, baud, dtr):
try: try:
self.p.connect(port, baud) self.p.connect(port, baud, dtr)
except SerialException as e: except SerialException as e:
# Currently, there is no errno, but it should be there in the future # Currently, there is no errno, but it should be there in the future
if e.errno == 2: if e.errno == 2:
...@@ -765,7 +765,7 @@ class pronsole(cmd.Cmd): ...@@ -765,7 +765,7 @@ class pronsole(cmd.Cmd):
if baud != self.settings.baudrate: if baud != self.settings.baudrate:
self.settings.baudrate = baud self.settings.baudrate = baud
self.save_in_rc("set baudrate", "set baudrate %d" % 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): def help_connect(self):
self.log("Connect to printer") self.log("Connect to printer")
......
...@@ -1050,7 +1050,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1050,7 +1050,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.paused = 0 self.paused = 0
if self.sdprinting: if self.sdprinting:
self.p.send_now("M26 S0") 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 return
if port != self.settings.port: if port != self.settings.port:
self.set("port", port) self.set("port", port)
......
...@@ -263,6 +263,7 @@ class Settings(object): ...@@ -263,6 +263,7 @@ class Settings(object):
self._add(ComboSetting("baudrate", 115200, self.__baudrate_list(), _("Baud rate"), _("Communications Speed"))) 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("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("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_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("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")) self._add(SpinSetting("temperature_abs", 230, 0, 400, _("Extruder temperature for ABS"), _("Extruder temp for ABS (deg C)"), "Printer"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment