where we pass the commandline to process_next_command() in. The commandline here does not contain the linenumber and the checksum anymore, so process_next_command() must not care about them.
In get_command():
Only care about the checksumm when we have a linenumber. Otherwise we can't handle a '*' inside the command.
Terminate the commandline with a '\0' at the '*' position.
strtol() has a side effect. It can return the char* just behind the last used digit as the second parameter. Use this to set command_queue_r[] when reading the linenumber.
Remove throwing the error for MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM - just ignore it.
Clean a little bug where the checksum was ignored behind a comment.
In code_has_value():
Tolerate leading spaces.
In process_next_command():
Use command_queue_r[].
Drop all that skipping of the linenumber. We did that in get_command().
Drop all that skipping the chars for the codenum to find the start of current_command_args - let strtol do the job.
Replace codenum = code_value_short(); with a direct call to strtol() to have access to the second parameter
code_is_good now depends on current_command_args - 1 that is now the last parsed digit, instead of the first.
Temporary add some debug code.
M113 parses all possible parameters and prints what was read.
We now hopefully tolerate:
any amount of spaces everywhere, including 0.
'N' as a parameter and in M117 and in pathmames
'*' in the commandline - for M117
checksumms behind a comment - no errors for missing checksumm anymore.
Happy testing.
Repetier:
Tries to parse some g-codes, adds linenumbes and checksumms, tries to sanitize the commandline.
Marlin should now understand everything RepetierHost sends - but not all we can send to Marlin is understood by RepetierHost.
Pronterface:
Does not add linenumbers and checksums, tries to parse some g-codes but does not sanitize them, can be confused by codes Marlin does understand.
Octoprint:
Just sends what you write to the send-box, adds linenumbers and checksumms when printing, seems to be very robust about what you can send.
Example debug output:
Send: N 1 M 113 A1B2C 3 D4 E.1 F.1 G. H.I1e3J1E3N13M14;Comment*10
Recv: Commandline:" N 1 M 113 A1B2C 3 D4 E.1 F.1 G. H.I1e3J1E3N13M14*10"
Recv: N1 10
Recv: Cleanedline:" M 113 A1B2C 3 D4 E.1 F.1 G. H.I1e3J1E3N13M14"
Recv: CommandCode:"M" Codenum:113 Args:"A1B2C 3 D4 E.1 F.1 G. H.I1e3J1E3N13M14"
Recv: //Codes seen (float): A1.00 B2.00 C3.00 D4.00 E0.10 F0.10 G0.00 H0.00 I1000.00 J1.00 M14.00 N13.00
Recv: //Codes seen (long): A1 B2 C3 D4 E0 F0 G0 H0 I1 J1 M14 N13
Recv: ok
Add a new array
where we pass the commandline to
process_next_command()
in. The commandline here does not contain the linenumber and the checksum anymore, soprocess_next_command()
must not care about them.In
get_command()
: Only care about the checksumm when we have a linenumber. Otherwise we can't handle a '*' inside the command.Terminate the commandline with a '\0' at the '*' position.
strtol() has a side effect. It can return the char* just behind the last used digit as the second parameter. Use this to set
command_queue_r[]
when reading the linenumber.Remove throwing the error for MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM - just ignore it.
Clean a little bug where the checksum was ignored behind a comment.
In
code_has_value()
: Tolerate leading spaces.In
process_next_command()
: Usecommand_queue_r[]
. Drop all that skipping of the linenumber. We did that inget_command()
. Drop all that skipping the chars for the codenum to find the start ofcurrent_command_args
- let strtol do the job. Replacecodenum = code_value_short();
with a direct call to strtol() to have access to the second parametercode_is_good
now depends oncurrent_command_args - 1
that is now the last parsed digit, instead of the first.Temporary add some debug code. M113 parses all possible parameters and prints what was read.
We now hopefully tolerate: any amount of spaces everywhere, including 0. 'N' as a parameter and in M117 and in pathmames '*' in the commandline - for M117 checksumms behind a comment - no errors for missing checksumm anymore.
Happy testing.
Repetier: Tries to parse some g-codes, adds linenumbes and checksumms, tries to sanitize the commandline. Marlin should now understand everything RepetierHost sends - but not all we can send to Marlin is understood by RepetierHost. Pronterface: Does not add linenumbers and checksums, tries to parse some g-codes but does not sanitize them, can be confused by codes Marlin does understand. Octoprint: Just sends what you write to the send-box, adds linenumbers and checksumms when printing, seems to be very robust about what you can send.
Example debug output: