Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/4493 - Defer M20 commands until initial capability report is done #4577

Merged
merged 8 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Defer M20 commands until initial capability report is done
  • Loading branch information
kForth committed Jul 14, 2022
commit 521bc267baea0d64989ff1ac772ec559f2fef4e7
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ date of first contribution):
* [Zack Lewis](https://github.com/lima3w)
* [Billy Richardson](https://github.com/richardsondev)
* [Christian Bianchini](https://github.com/max246)
* [Kestin Goforth](https://github.com/kforth)

OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
[Daid Braam](https://github.com/daid). Parts of its communication layer and
Expand Down
41 changes: 36 additions & 5 deletions src/octoprint/util/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,11 @@ def __init__(
self._sdFileToSelectUser = None
self._ignore_select = False
self._manualStreaming = False

# Capability report tracking
self._first_cap_report_pending = False
self._first_cap_report_started = False
self._m20_pending_cap_report = False

self.last_temperature = TemperatureRecord()
self.pause_temperature = TemperatureRecord()
Expand Down Expand Up @@ -2003,6 +2008,11 @@ def refreshSdFiles(self, tags=None):
if not self.isOperational() or self.isBusy():
return

if self._first_cap_report_pending:
self._m20_pending_cap_report = True
self._logger.info("Deferring sd file refresh until capability report done")
return

if tags is None:
tags = set()

Expand Down Expand Up @@ -2581,6 +2591,23 @@ def convert_line(line):
):
continue

# track the start and end of the first capability reporting (from M115)
if self._first_cap_report_pending:
# capability report in progress
if lower_line.startswith("cap:"):
self._first_cap_report_started = True

# capability report done
elif self._first_cap_report_started:
self._first_cap_report_pending = False
self._first_cap_report_started = False

# refresh sd files now if it was deferred while waiting for report
if self._m20_pending_cap_report:
self._m20_pending_cap_report = False
self._logger.info("Performing deferred sd file refresh")
kForth marked this conversation as resolved.
Show resolved Hide resolved
self.refreshSdFiles()

##~~ position report processing
if "X:" in line and "Y:" in line and "Z:" in line:
parsed = parse_position_line(line)
Expand Down Expand Up @@ -2730,6 +2757,12 @@ def convert_line(line):
self._logger.info(
"Firmware states that it supports emergency GCODEs to be sent without waiting for an acknowledgement first"
)
elif (
capability == self.CAPABILITY_EXTENDED_M20 and enabled
):
self._logger.info(
kForth marked this conversation as resolved.
Show resolved Hide resolved
"Firmware states that it supports long filenames"
)

# notify plugins
for name, hook in self._firmware_info_hooks[
Expand Down Expand Up @@ -3627,13 +3660,11 @@ def _onConnected(self):
"trigger:comm.on_connected",
},
)
self._first_cap_report_pending = True
self._first_cap_report_started = False

if self._sdAvailable:
self.refreshSdFiles(
tags={
"trigger:comm.on_connected",
}
)
self.refreshSdFiles(tags={"trigger:comm.on_connected"})
else:
self.initSdCard(tags={"trigger:comm.on_connected"})

Expand Down