New flag to have M29 response inject "ok"

Adjusted virtual printer to allow marking of M29 as broken re sending
of ok.

Fixes #1273
This commit is contained in:
Gina Häußge 2016-03-10 15:58:59 +01:00
parent 23d2cdec76
commit 069bfdd9f8
6 changed files with 28 additions and 3 deletions

View file

@ -73,6 +73,8 @@ class VirtualPrinter():
self._echoOnM117 = settings().getBoolean(["devel", "virtualPrinter", "echoOnM117"])
self._brokenM29 = settings().getBoolean(["devel", "virtualPrinter", "brokenM29"])
self.currentLine = 0
self.lastN = 0
@ -223,6 +225,8 @@ class VirtualPrinter():
elif 'M29' in data:
if self._sdCardReady:
self._finishSdFile()
if self._brokenM29:
continue
elif 'M30' in data:
if self._sdCardReady:
filename = data.split(None, 1)[1].strip()

View file

@ -90,6 +90,7 @@ def getSettings():
"helloCommand": s.get(["serial", "helloCommand"]),
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
"triggerOkForM29": s.getBoolean(["serial", "triggerOkForM29"])
},
"folder": {
"uploads": s.getBaseFolder("uploads"),
@ -234,6 +235,7 @@ def setSettings():
if "helloCommand" in data["serial"]: s.set(["serial", "helloCommand"], data["serial"]["helloCommand"])
if "ignoreErrorsFromFirmware" in data["serial"]: s.setBoolean(["serial", "ignoreErrorsFromFirmware"], data["serial"]["ignoreErrorsFromFirmware"])
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
if "triggerOkForM29" in data["serial"]: s.setBoolean(["serial", "triggerOkForM29"], data["serial"]["triggerOkForM29"])
oldLog = s.getBoolean(["serial", "log"])
if "log" in data["serial"].keys(): s.setBoolean(["serial", "log"], data["serial"]["log"])

View file

@ -90,7 +90,10 @@ default_settings = {
"helloCommand": "M110 N0",
"disconnectOnErrors": True,
"ignoreErrorsFromFirmware": False,
"logResends": False
"logResends": False,
# command specific flags
"triggerOkForM29": True
},
"server": {
"host": "0.0.0.0",
@ -308,7 +311,8 @@ default_settings = {
"sendWait": True,
"waitInterval": 1.0,
"supportM112": True,
"echoOnM117": True
"echoOnM117": True,
"brokenM29": True
}
}
}

View file

@ -140,6 +140,7 @@ $(function() {
self.serial_helloCommand = ko.observable(undefined);
self.serial_ignoreErrorsFromFirmware = ko.observable(undefined);
self.serial_disconnectOnErrors = ko.observable(undefined);
self.serial_triggerOkForM29 = ko.observable(undefined);
self.folder_uploads = ko.observable(undefined);
self.folder_timelapse = ko.observable(undefined);
@ -458,6 +459,7 @@ $(function() {
self.serial_helloCommand(response.serial.helloCommand);
self.serial_ignoreErrorsFromFirmware(response.serial.ignoreErrorsFromFirmware);
self.serial_disconnectOnErrors(response.serial.disconnectOnErrors);
self.serial_triggerOkForM29(response.serial.triggerOkForM29);
self.folder_uploads(response.folder.uploads);
self.folder_timelapse(response.folder.timelapse);
@ -548,7 +550,8 @@ $(function() {
"checksumRequiringCommands": splitTextToArray(self.serial_checksumRequiringCommands(), ",", true),
"helloCommand": self.serial_helloCommand(),
"ignoreErrorsFromFirmware": self.serial_ignoreErrorsFromFirmware(),
"disconnectOnErrors": self.serial_disconnectOnErrors()
"disconnectOnErrors": self.serial_disconnectOnErrors(),
"triggerOkForM29": self.serial_triggerOkForM29()
},
"folder": {
"uploads": self.folder_uploads(),

View file

@ -116,6 +116,11 @@
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
</div>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_triggerOkForM29" id="settings-triggerOkForM29"> {{ _('Generate additional <code>ok</code> for <code>M29</code>') }} <span class="label">{{ _('Most Marlin < v1.1.0') }}</span>
</label>
</div>
</div>
</div>

View file

@ -230,6 +230,7 @@ class MachineCom(object):
self._timeout = None
self._hello_command = settings().get(["serial", "helloCommand"])
self._trigger_ok_for_m29 = settings().getBoolean(["serial", "triggerOkForM29"])
self._alwaysSendChecksum = settings().getBoolean(["feature", "alwaysSendChecksum"])
self._sendChecksumWithUnknownCommands = settings().getBoolean(["feature", "sendChecksumWithUnknownCommands"])
@ -1091,6 +1092,12 @@ class MachineCom(object):
pass
elif 'Done saving file' in line:
self.refreshSdFiles()
if self._trigger_ok_for_m29:
# workaround for most versions of Marlin out in the wild
# not sending an ok after saving a file
self._clear_to_send.set()
line, lower_line = convert_line("ok")
elif 'File deleted' in line and line.strip().endswith("ok"):
# buggy Marlin version that doesn't send a proper \r after the "File deleted" statement, fixed in
# current versions