Added logging to file on top of to stdout, temperature parsing now can cope with negative temperature (shouldn't normally occur but seems to happen with buggy firmware), added option to wait for "start" response from printer firmware before switching to state "operational" (defaults to previous behaviour)

master
Gina Häußge 2013-02-17 17:47:06 +01:00
parent f03056c1b2
commit cbae792dbe
3 changed files with 21 additions and 8 deletions

View File

@ -377,6 +377,14 @@ def initLogging():
"level": "DEBUG", "level": "DEBUG",
"formatter": "simple", "formatter": "simple",
"stream": "ext://sys.stdout" "stream": "ext://sys.stdout"
},
"file": {
"class": "logging.handlers.TimedRotatingFileHandler",
"level": "DEBUG",
"formatter": "simple",
"when": "D",
"backupCount": "1",
"filename": os.path.join(settings().getBaseFolder("logs"), "octoprint.log")
} }
}, },
"loggers": { "loggers": {
@ -386,7 +394,7 @@ def initLogging():
}, },
"root": { "root": {
"level": "INFO", "level": "INFO",
"handlers": ["console"] "handlers": ["console", "file"]
} }
} }
logging.config.dictConfig(config) logging.config.dictConfig(config)

View File

@ -36,10 +36,12 @@ old_default_settings = {
"folder": { "folder": {
"uploads": None, "uploads": None,
"timelapse": None, "timelapse": None,
"timelapse_tmp": None "timelapse_tmp": None,
"logs": None
}, },
"feature": { "feature": {
"gCodeVisualizer": True "gCodeVisualizer": True,
"waitForStartOnConnect": False
}, },
} }

View File

@ -62,7 +62,7 @@ class VirtualPrinter():
self.lastTempAt = time.time() self.lastTempAt = time.time()
self.bedTemp = 1.0 self.bedTemp = 1.0
self.bedTargetTemp = 1.0 self.bedTargetTemp = 1.0
def write(self, data): def write(self, data):
if self.readList is None: if self.readList is None:
return return
@ -314,6 +314,7 @@ class MachineCom(object):
#Start monitoring the serial port. #Start monitoring the serial port.
timeout = time.time() + 5 timeout = time.time() + 5
tempRequestTimeout = timeout tempRequestTimeout = timeout
startSeen = not settings().getBoolean(["feature", "waitForStartOnConnect"])
while True: while True:
line = self._readline() line = self._readline()
if line == None: if line == None:
@ -334,9 +335,9 @@ class MachineCom(object):
self._errorValue = line[6:] self._errorValue = line[6:]
self._changeState(self.STATE_ERROR) self._changeState(self.STATE_ERROR)
if ' T:' in line or line.startswith('T:'): if ' T:' in line or line.startswith('T:'):
self._temp = float(re.search("[0-9\.]*", line.split('T:')[1]).group(0)) self._temp = float(re.search("-?[0-9\.]*", line.split('T:')[1]).group(0))
if ' B:' in line: if ' B:' in line:
self._bedTemp = float(re.search("[0-9\.]*", line.split(' B:')[1]).group(0)) self._bedTemp = float(re.search("-?[0-9\.]*", line.split(' B:')[1]).group(0))
self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp) self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp)
#If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate. #If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate.
if not 'ok' in line and self._heatupWaitStartTime != 0: if not 'ok' in line and self._heatupWaitStartTime != 0:
@ -384,9 +385,11 @@ class MachineCom(object):
else: else:
self._testingBaudrate = False self._testingBaudrate = False
elif self._state == self.STATE_CONNECTING: elif self._state == self.STATE_CONNECTING:
if line == '': if line == '' and startSeen:
self._sendCommand("M105") self._sendCommand("M105")
elif 'ok' in line: elif 'start' in line:
startSeen = True
elif 'ok' in line and startSeen:
self._changeState(self.STATE_OPERATIONAL) self._changeState(self.STATE_OPERATIONAL)
elif time.time() > timeout: elif time.time() > timeout:
self.close() self.close()