Allow M23 "File opened" response with no filename

This commit is contained in:
Mark Walker 2015-12-30 14:25:58 -07:00
parent 257c4ed8aa
commit ba4b7c09bf
2 changed files with 8 additions and 4 deletions

View file

@ -300,7 +300,7 @@ default_settings = {
"okWithLinenumber": False, "okWithLinenumber": False,
"numExtruders": 1, "numExtruders": 1,
"includeCurrentToolInTemps": True, "includeCurrentToolInTemps": True,
"includeFilenameOnOpened": True, "includeFilenameInOpened": True,
"movementSpeed": { "movementSpeed": {
"x": 6000, "x": 6000,
"y": 6000, "y": 6000,

View file

@ -1140,12 +1140,16 @@ class MachineCom(object):
elif 'File opened' in line and not self._ignore_select: elif 'File opened' in line and not self._ignore_select:
# answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d" # answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d"
match = regex_sdFileOpened.search(line) match = regex_sdFileOpened.search(line)
if match:
name = match.group("name")
size = int(match.group("size"))
else:
name = "Unknown"
size = 0
if self._sdFileToSelect: if self._sdFileToSelect:
name = self._sdFileToSelect name = self._sdFileToSelect
self._sdFileToSelect = None self._sdFileToSelect = None
else: self._currentFile = PrintingSdFileInformation(name, size)
name = match.group("name")
self._currentFile = PrintingSdFileInformation(name, int(match.group("size")))
elif 'File selected' in line: elif 'File selected' in line:
if self._ignore_select: if self._ignore_select:
self._ignore_select = False self._ignore_select = False