Merge branch 'maintenance' into devel
Conflicts: setup.py src/octoprint/plugins/virtual_printer/virtual.py src/octoprint/printer/standard.py
This commit is contained in:
commit
28814db207
5 changed files with 53 additions and 27 deletions
|
|
@ -25,7 +25,7 @@ class VirtualPrinter(object):
|
|||
|
||||
def __init__(self, seriallog_handler=None, read_timeout=5.0, write_timeout=10.0):
|
||||
import logging
|
||||
self._logger = logging.getLogger("octoprint.plugin.virtual_printer.VirtualPrinter")
|
||||
self._logger = logging.getLogger("octoprint.plugins.virtual_printer.VirtualPrinter")
|
||||
|
||||
self._seriallog = logging.getLogger("octoprint.plugin.virtual_printer.VirtualPrinter.serial")
|
||||
self._seriallog.setLevel(logging.CRITICAL)
|
||||
|
|
@ -119,6 +119,24 @@ class VirtualPrinter(object):
|
|||
return "VIRTUAL(read_timeout={read_timeout},write_timeout={write_timeout},options={options})"\
|
||||
.format(read_timeout=self._read_timeout, write_timeout=self._write_timeout, options=settings().get(["devel", "virtualPrinter"]))
|
||||
|
||||
@property
|
||||
def timeout(self):
|
||||
return self._read_timeout
|
||||
|
||||
@timeout.setter
|
||||
def timeout(self, value):
|
||||
self._logger.debug("Setting read timeout to {}s".format(value))
|
||||
self._read_timeout = value
|
||||
|
||||
@property
|
||||
def write_timeout(self):
|
||||
return self._write_timeout
|
||||
|
||||
@write_timeout.setter
|
||||
def write_timeout(self, value):
|
||||
self._logger.debug("Setting write timeout to {}s".format(value))
|
||||
self._write_timeout = value
|
||||
|
||||
def _clearQueue(self, queue):
|
||||
try:
|
||||
while queue.get(block=False):
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ from octoprint.printer.estimation import TimeEstimationHelper
|
|||
from octoprint.settings import settings
|
||||
from octoprint.util import comm as comm
|
||||
from octoprint.util import InvariantContainer
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
|
||||
class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
|
@ -50,11 +51,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
self._temps = TemperatureHistory(cutoff=settings().getInt(["temperature", "cutoff"])*60)
|
||||
self._tempBacklog = []
|
||||
|
||||
self._latestMessage = None
|
||||
self._messages = deque([], 300)
|
||||
self._messageBacklog = []
|
||||
|
||||
self._latestLog = None
|
||||
self._log = deque([], 300)
|
||||
self._logBacklog = []
|
||||
|
||||
|
|
@ -809,10 +808,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
"messages": list(self._messages)
|
||||
})
|
||||
callback.on_printer_send_initial_data(data)
|
||||
except Exception as err:
|
||||
import sys
|
||||
sys.stderr.write("ERROR: %s\n" % str(err))
|
||||
pass
|
||||
except:
|
||||
self._logger.exception("Error while trying to send inital state update")
|
||||
|
||||
def _getStateFlags(self):
|
||||
return {
|
||||
|
|
@ -831,7 +828,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
"""
|
||||
Callback method for the comm object, called upon log output.
|
||||
"""
|
||||
self._addLog(message)
|
||||
self._addLog(to_unicode(message, "utf-8", errors="replace"))
|
||||
|
||||
def on_comm_temperature_update(self, temp, bedTemp):
|
||||
self._addTemperatureData(temp, bedTemp)
|
||||
|
|
@ -868,7 +865,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
Callback method for the comm object, called upon message exchanges via serial.
|
||||
Stores the message in the message buffer, truncates buffer to the last 300 lines.
|
||||
"""
|
||||
self._addMessage(message)
|
||||
self._addMessage(to_unicode(message, "utf-8", errors="replace"))
|
||||
|
||||
def on_comm_progress(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import time
|
|||
|
||||
import octoprint.timelapse
|
||||
import octoprint.server
|
||||
import octoprint.events
|
||||
import octoprint.plugin
|
||||
|
||||
from octoprint.events import Events
|
||||
from octoprint.settings import settings
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ default_settings = {
|
|||
"detection": 0.5,
|
||||
"connection": 10,
|
||||
"communication": 30,
|
||||
"heatup": 2,
|
||||
"temperature": 5,
|
||||
"temperatureTargetSet": 2,
|
||||
"sdStatus": 1
|
||||
|
|
|
|||
|
|
@ -949,7 +949,10 @@ class MachineCom(object):
|
|||
if line is None:
|
||||
break
|
||||
if line.strip() is not "":
|
||||
self._timeout = get_new_timeout("communication", self._timeout_intervals)
|
||||
if self._heating:
|
||||
self._timeout = get_new_timeout("heatup", self._timeout_intervals)
|
||||
else:
|
||||
self._timeout = get_new_timeout("communication", self._timeout_intervals)
|
||||
|
||||
##~~ debugging output handling
|
||||
if line.startswith("//"):
|
||||
|
|
@ -1052,8 +1055,7 @@ class MachineCom(object):
|
|||
elif ' T:' in line or line.startswith('T:') or ' T0:' in line or line.startswith('T0:') or ((' B:' in line or line.startswith('B:')) and not 'A:' in line):
|
||||
if not disable_external_heatup_detection and not line.strip().startswith("ok") and not self._heating:
|
||||
self._logger.debug("Externally triggered heatup detected")
|
||||
self._heating = True
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._track_heatup()
|
||||
self._processTemperatures(line)
|
||||
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
|
||||
|
||||
|
|
@ -1152,13 +1154,7 @@ class MachineCom(object):
|
|||
self._handle_ok()
|
||||
|
||||
##~~ Message handling
|
||||
elif line != '' \
|
||||
and not line.startswith("ok") \
|
||||
and not line.startswith("wait") \
|
||||
and not line.startswith('Resend:') \
|
||||
and line != 'echo:Unknown command:""\n' \
|
||||
and self.isOperational():
|
||||
self._callback.on_comm_message(line)
|
||||
self._callback.on_comm_message(line)
|
||||
|
||||
##~~ Parsing for feedback commands
|
||||
if feedback_controls and feedback_matcher and not "_all" in feedback_errors:
|
||||
|
|
@ -1242,10 +1238,7 @@ class MachineCom(object):
|
|||
self._currentTool = self._formerTool
|
||||
self._formerTool = None
|
||||
|
||||
if self._heatupWaitStartTime:
|
||||
self._heatupWaitTimeLost = self._heatupWaitTimeLost + (time.time() - self._heatupWaitStartTime)
|
||||
self._heatupWaitStartTime = None
|
||||
self._heating = False
|
||||
self._finish_heatup()
|
||||
|
||||
if not self._state in (self.STATE_PRINTING, self.STATE_OPERATIONAL, self.STATE_PAUSED):
|
||||
return
|
||||
|
|
@ -1274,6 +1267,10 @@ class MachineCom(object):
|
|||
self._resendSameCommand()
|
||||
self._clear_to_send.set()
|
||||
|
||||
elif self._heating:
|
||||
self._logger.debug("Timeout while in an active heatup, considering heatup to be over then")
|
||||
self._finish_heatup()
|
||||
|
||||
else:
|
||||
self._log("Communication timeout while printing, trying to trigger response from printer. " + general_message)
|
||||
self._sendCommand("M105", cmd_type="temperature")
|
||||
|
|
@ -1281,6 +1278,18 @@ class MachineCom(object):
|
|||
|
||||
return
|
||||
|
||||
def _track_heatup(self):
|
||||
self._heating = True
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._serial.timeout = settings().getFloat(["serial", "timeout", "heatup"])
|
||||
|
||||
def _finish_heatup(self):
|
||||
if self._heatupWaitStartTime:
|
||||
self._heatupWaitTimeLost = self._heatupWaitTimeLost + (time.time() - self._heatupWaitStartTime)
|
||||
self._heatupWaitStartTime = None
|
||||
self._heating = False
|
||||
self._serial.timeout = settings().getFloat(["serial", "timeout", "communication"])
|
||||
|
||||
def _continue_sending(self):
|
||||
if self._state == self.STATE_PRINTING:
|
||||
if not self._sendFromQueue() and not self.isSdPrinting():
|
||||
|
|
@ -2050,15 +2059,13 @@ class MachineCom(object):
|
|||
pass
|
||||
|
||||
def _gcode_M109_sent(self, cmd, cmd_type=None):
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._long_running_command = True
|
||||
self._heating = True
|
||||
self._track_heatup()
|
||||
self._gcode_M104_sent(cmd, cmd_type, wait=True)
|
||||
|
||||
def _gcode_M190_sent(self, cmd, cmd_type=None):
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._long_running_command = True
|
||||
self._heating = True
|
||||
self._track_heatup()
|
||||
self._gcode_M140_sent(cmd, cmd_type, wait=True)
|
||||
|
||||
def _gcode_M110_sending(self, cmd, cmd_type=None):
|
||||
|
|
|
|||
Loading…
Reference in a new issue