Commit 1477324f authored by NeoTheFox's avatar NeoTheFox

added DTR switch

parent b2f95128
......@@ -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
......@@ -144,7 +145,7 @@ class printcore():
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:
......@@ -153,6 +154,8 @@ class printcore():
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])$")
......@@ -194,6 +197,8 @@ class printcore():
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) +
......
......@@ -715,9 +715,9 @@ class pronsole(cmd.Cmd):
# 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:
......@@ -765,7 +765,7 @@ class pronsole(cmd.Cmd):
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")
......
......@@ -1050,7 +1050,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
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)
......
......@@ -263,6 +263,7 @@ class Settings(object):
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"))
......
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