-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
I've realized another potential bug in this approach: the server will block all calls to This may not be a big issue since the reprap wiki shows good support the An alternative approach is to force the first command to be A few caveats with this approach, if the option is set to True:
There is no change to the existing behaviour if this option is set to False. You can see my implementation of this on my fix/4493-assume-extended-m20-option branch . Thoughts are appreciated. |
I was about to test if no capabilities would result in an issue. If there's one thing that's certain, it's that you are always uncertain on what might happen with printer communication - random things break all the time. Creality 2x temp reporting for example, that's quite an unexpected break. I like the idea of sending an M20 L command as soon as the capability report comes in - it's fairly robust. The issue then becomes when to send a regular M20, if the capability is not received. With the assumption method you have there, I think the option would be more at home in the serial connection settings than the printer profile. Yes, I agree that it could change on a printer-by-printer basis, but none of the other serial settings are part of a profile - unless they are all migrated then I think it should stick with the rest of them. The only thing I am worried about is some firmware variants complaining about an 'Unknown parameter' - I have tested my printer (Marlin 2.0.8.2), it doesn't (the simulator crashed). One I would like to see is Prusa, since that has had some of the strangest protocol behaviour before (aside from Creality). To summarise the options - all have one downside that I can see.
I don't like this kind of dilemma... |
I was thinking this would be the way to go, but that's under the assumption that the unknown parameter would just be ignored. Gina may have more insight when she gets back from vacation in regard to that. Pretty sure Marlin is pretty forgiving with stuff like that, but not sure on other firmwares. |
Have reached out on Discord to some PrusaFirmware users to see what happens when |
adding responses from PrusaFirmware. |
Thanks for the feedback. Thinking more about this, I may prefer the 'Assume LFN Support' option because it doesn't modify the original command order or timing. A fourth option is:
Then the user could override it to always be The only potential issue I see right now is how to handle adding the I've also updated my original implementation so that there's a setting to enable the feature, default is disabled. |
I like both these as optional settings, deferring file list loading and what command to use to list sd files. After thinking about it though, the later would technically resolve both allowing the user to manually override the command being sent initially prior to the capability report being read/loaded. |
maybe default the setting to M20 and on capabilities report read programmatically update the setting automatically? Basically make it part of the firmware discovery process, which I think is used for other settings IIRC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The capability report detection logic should really be implemented analog to the firmware information detection logic. So, add another boolean flag self._firmware_capabilities_received
next to the declaration of self._firmware_info_received
. A capability report is ongoing if self._firmware_capabilities
has at least one entry (one cap:
line was read and parsed into it). So adding some check like this in the monitor loop:
if self._firmware_capabilities and not self._firmware_capabilities_received and not lower_line.startswith("cap:"):
self._firmware_capabilities_received = True
# fire off an event?
if self._defer_sd_list:
# SD listing was delayed, do it now
self.refreshSdFiles()
should track nicely whether we have received the full capability report. self._defer_sd_list
should be set to settings().getBoolean(["serial", "waitToLoadSdFileList"])
once in the constructor, similar to most of the other config parameters.
Thanks for the input, I've refactored my code to better match the firmware_info implementation and added an event hook. I also created a quick test plugin for the hook: https://github.com/kForth/OctoPrint-AfterReportTest Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic looks sound now, thank you! Only issue I have now is the name of the new hook 😅
after_report
is a bit to generic. capabilities
is already taken for the individual capability lines, but I think octoprint.comm.protocol.firmware.capability_report
would be fairly self descriptive without any ambiguity as to what report we are talking about.
In hindsight it would admittedly have been better to parse the full report first, then call plugins, instead of introducing this individual capabilities
hook in the first place, but well, we are stuck with that now.
edit Also please make sure you have pre-commit installed on your end, your changes currently don't pass its checks due to a typo as seen in the CI results.
@kForth please request a new review once you deem this PR ready for one |
FYI, seen the review request, it's on my TODO list, but I'm currently fully focused on 1.8.3. |
Thank you for the PR, and thank you for your patience while I was busy with 1.8.x :) |
What does this PR do and why is it necessary?
This is a proposed fix for issue #4493.
This PR tracks the start and end of the first capability report and defers any
M20
commands until it's done.The first
M20
command is queued before the response fromM115
is processed, meaning long filenames are not shown in the file list until it's refreshed.How was it tested? How can it be tested by the reviewer?
M20
command is sent before the capability report is doneM20
command is sent shortly after the capability report finishesL
parameter ifEXTENDED_M20
is supportedWhat are the relevant tickets if any?
This is a fix for issue #4493.
Screenshots (if appropriate)
Not really screenshots but close enough.
Terminal Output Before
Terminal Output After
Further notes
I'm unsure how likely/possible it is for the 'cap:' lines to be interrupted, but it could cause the M20 to be sent before the
EXTENDED_M20
capability is reported.An alternative solution is to refresh the list as soon as the
EXTENDED_M20
capability is reported (like below), but that will double report the file list.Thoughts are appreciated.