-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
virtual_sdcard: Allow spaces in file path for M23 #5319
Conversation
The virtual SD Card allows files with spaces, and both |
klippy/extras/virtual_sdcard.py
Outdated
@@ -160,7 +160,7 @@ def cmd_M23(self, gcmd): | |||
self._reset_file() | |||
try: | |||
orig = gcmd.get_commandline() | |||
filename = orig[orig.find("M23") + 4:].split()[0].strip() | |||
filename = orig.split(None, 1)[1].strip() |
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.
If the original command contains a line number then I suspect that this will produce an invalid filename. I suspect that what you desire could be accomplished by adding maxsplit=1
to the original line, ie:
filename = orig[orig.find("M23") + 4:].split(maxsplit=1)[0].strip()
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.
Thanks, I was unaware that gcode line numbers were a thing or that Klipper supported them.
That stated, one thing I forgot to mention was that the current code breaks if the M23
is renamed to anything other than M23\d
(where \d
is a single digit). I didn't realize that until after I posted the PR, but I assume it's a bug worth fixing as well, so I would have to tweak your suggestion a bit to just skip a line number (if present).
@Arksine, I updated to skip line numbers and noted in the commit message that it makes M23 work normally with |
I just took a quick look at this, but wouldn't it be safer to update |
Good point, I should have used That stated, I don't see a reason for Either way, I've updated the PR to use |
Well, that's because Just a thought, but you might want to double-check that you can override
|
Yup, did that before pushing the updated PR. I 've been using this macro to verify that everything works with a renamed
|
Overall it looks good to me. I would think that it is no longer necessary to remove the checksum since |
Yeah, I saw that |
Indeed, I think the checksum part on the filename can be safely removed. As for the code in |
I agree that the checksum check should be removed. Otherwise, it looks fine to me. It is my understanding that a checksum is only valid if a line number is present. (Otherwise, commands like M117 wouldn't be able to display an Separately, it is my understanding is that a line number may be present without a checksum - ah the fun of g-code. -Kevin |
Also makes M23 work normally with rename_existing. Signed-off-by: Justin Schuh <[email protected]>
Okay, removed the checksum bit and pushed the updated file. Should be good to go. |
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.
LGTM
Ah, good point about the checksum and M117. This looks good to me as well. |
Thanks. -Kevin |
Ignore me... I'm running Klipper with Python 3 and seems the issue is only visible in Python 2. |
Signed-off-by: Justin Schuh [email protected]