-
-
Notifications
You must be signed in to change notification settings - Fork 19.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
Fix: current_command_args contains command #3027
Fix: current_command_args contains command #3027
Conversation
@thinkyhead Hi Scott, your code from a0f362c@thinkyhead is great, but you forgot to skip the command. Symptom `M117 Test`shows `M117 Test` on LCD instead of `Test`. see also MarlinFirmware@a0f362c735401ebbcd95de3f 6f8e3c2f17ecc770 lines 941, 2851 and so on Greetings and welcome back Jochen
@CONSULitAS OMG you're right, haha! Thanks for this fix. It should go into MarlinDev too. By the way, have you looked at the way GCode is interpreted in Matt Roberts' RepRap firmware? It's really quite smart. I might try to use his approach for a future revision. And… it's good to be back! So much to catch up on… |
Fix: current_command_args contains command
The recent GCode parser changes were intended to make it more space-tolerant, so even a command as ugly as this should still work:
So I think actually this needs to be changed further. From this: current_command_args = current_command + 2; // skip first letter and following character
while (*current_command_args >= '0' && *current_command_args <= '9') ++current_command_args;
while (*current_command_args == ' ') ++current_command_args; …to this… current_command_args = current_command + 1; // skip the code letter
while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9'))
++current_command_args; It only skips one character because the command could be something like Agh, actually I see the |
@thinkyhead You are welcome. :-) Could you please explain what to do with GitHub to migrate this to MarlinDev? Thanks Your suggestion for the parser is interesting. We should indeed make no assumptions about the GCODE we get. And I like code which is error tolerant specially for foreign input data. But I think, the condition is hardly readable and not easy to maintain. Additionally we have other similar code parts on other places in Marlin_main. So we should make it clearer and easier to maintain. From your:
to
but even better
with this The Macros don't change the size of the code except BTW: Inspiration for this is partly from arduino/Arduino@cd9a6ec which has been merged to Arduino two weeks ago. Great code! |
Well, you know how I love macros. 😁 I always wonder if the compiler optimizer is smart enough to tell that Some processing may be obviated by having a parser that works a bit differently – collecting all the argument values into an array up-front, avoiding calling any library functions to parse numbers, and avoiding floats. (Using code like We can explore that further in the next iteration. Meanwhile the macros may help… As for migrating fixes to MarlinDev, well I've got this one. See MarlinFirmware/MarlinDev#352. Basically, I just keep a working copy of this and of MarlinDev, so I can always create a new branch, apply changes, and submit a PR pretty quickly. I just keep my |
As far as i know, there is no general optimisation for this. The compiler is not smart enough to see that So in general testing a == ' ' positive is less likely than testing a != 0. (several ' ' in a string but only one end (all but one not 0)) |
@thinkyhead
Hi Scott,
your code from a0f362c@thinkyhead is great, but you forgot to skip the
command.
Symptom
M117 Test
showsM117 Test
on LCD instead ofTest
.see also
a0f362c735401ebbcd95de3f
6f8e3c2f17ecc770 lines 941, 2851 and so on
Greetings and welcome back
Jochen