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

Relax Parsing the Commandline #9

Closed
wants to merge 1 commit into from
Closed

Relax Parsing the Commandline #9

wants to merge 1 commit into from

Conversation

AnHardt
Copy link
Owner

@AnHardt AnHardt commented Nov 17, 2015

Add a new array

static char * command_queue_r[BUFSIZE];

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
```
static char * command_queue_r[BUFSIZE];
```
where we pass a 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.

# Conflicts:
#	Marlin/Marlin_main.cpp
@AnHardt AnHardt closed this May 15, 2016
@AnHardt AnHardt reopened this Jul 5, 2016
@AnHardt AnHardt closed this Jul 5, 2016
@AnHardt AnHardt reopened this Jul 5, 2016
@AnHardt AnHardt closed this Jul 5, 2016
@AnHardt AnHardt deleted the relax-parsing branch July 5, 2016 19:33
AnHardt pushed a commit that referenced this pull request Aug 25, 2019
# This is the 1st commit message:

Add Support for ADIMLab Granty

# The commit message #2 will be skipped:

# Update Configuration.h

# The commit message #3 will be skipped:

# Add files via upload
#
# Add Support for ADIMLab Granty

# The commit message #4 will be skipped:

# Create Configuration.h

# The commit message #5 will be skipped:

# Delete Configuration.h

# The commit message #6 will be skipped:

# Create Test.h

# The commit message #7 will be skipped:

# Add files via upload

# The commit message #8 will be skipped:

# Delete Test.h

# The commit message #9 will be skipped:

# Delete Configuration.h

# The commit message #10 will be skipped:

# Delete Configuration_adv.h

# The commit message #11 will be skipped:

# Add files via upload
#
# Add ADIMLab Pins

# The commit message #12 will be skipped:

# Add files via upload
#
# Add Bootscreen

# The commit message #13 will be skipped:

# Update Configuration.h
#
# Add Bootscreen

# The commit message #14 will be skipped:

# Update pins.h
#
# Add ADIMLab Board

# The commit message #15 will be skipped:

# Update boards.h
#
# Add ADIMLab Granty

# The commit message #16 will be skipped:

# Update Makefile
#
# Add ADIMLab Granty

# The commit message #17 will be skipped:

# Update boards.h

# The commit message #18 will be skipped:

# Update Makefile
AnHardt pushed a commit that referenced this pull request Aug 25, 2019
* # This is a combination of 18 commits.
# This is the 1st commit message:

Add Support for ADIMLab Granty

# The commit message #2 will be skipped:

# Update Configuration.h

# The commit message #3 will be skipped:

# Add files via upload
#
# Add Support for ADIMLab Granty

# The commit message #4 will be skipped:

# Create Configuration.h

# The commit message #5 will be skipped:

# Delete Configuration.h

# The commit message #6 will be skipped:

# Create Test.h

# The commit message #7 will be skipped:

# Add files via upload

# The commit message #8 will be skipped:

# Delete Test.h

# The commit message #9 will be skipped:

# Delete Configuration.h

# The commit message #10 will be skipped:

# Delete Configuration_adv.h

# The commit message #11 will be skipped:

# Add files via upload
#
# Add ADIMLab Pins

# The commit message #12 will be skipped:

# Add files via upload
#
# Add Bootscreen

# The commit message #13 will be skipped:

# Update Configuration.h
#
# Add Bootscreen

# The commit message #14 will be skipped:

# Update pins.h
#
# Add ADIMLab Board

# The commit message #15 will be skipped:

# Update boards.h
#
# Add ADIMLab Granty

# The commit message #16 will be skipped:

# Update Makefile
#
# Add ADIMLab Granty

# The commit message #17 will be skipped:

# Update boards.h

# The commit message #18 will be skipped:

# Update Makefile

* Add Support for ADIMLab Granty

* Optimize bootscreen

* Update Makefile

Updated Description

* Update boards.h

Updated Description

* Update pins_HJC2560C_REV2.h

Updated Description

* Update Configuration.h

Added Author + Custom_Machine_Name

* Create _Bootscreen.h

Add Bootscreen

* Add files via upload

Add ADIMLab Granty v1

* Update boards.h

Add ADIMLab Granty v1

* Update Makefile

Add ADIMLab Granty v1

* Update pins_HJC2560C_REV2.h

* Consolidate Granty configs

* config updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant