-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Improve CommandProcessing library #2748
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Avoids duplicating storage of name.
Remove `currentEOL` and deprecate associated methods. Since either `\r` or `\n` are accepted not sure there's any need for this?
Assume intention was `isVerbose`
mikee47
force-pushed
the
feature/cmdproc-rewrite
branch
2 times, most recently
from
March 26, 2024 20:19
bc01e9d
to
2086535
Compare
mikee47
force-pushed
the
feature/cmdproc-rewrite
branch
from
March 26, 2024 20:29
2086535
to
6fc1969
Compare
mikee47
changed the title
[WIP] Improve CommandProcessing library
Improve CommandProcessing library
Mar 27, 2024
slaff
approved these changes
Mar 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's a PR with a few suggestions to improve the CommandProcessing library.
Handling line endings is inconsistent
Running the
CommandLine
sample on Host we get this:On Esp8266 it looks different:
This is what it should be:
The
currentEOL
and associated methods seem redundantThe LineBuffer handles "\r", "\n", "\n\r" and "\r\n" the same way, so we can just use that.
command name is stored twice
Using a
HashMap
means the command name is stored both as a key, and in theCommand
object.Let's just use a
Vector
instead.localEcho
Private member variable set to true and never changed. Assume intention was
isVerbose
.Consuming RAM for string storage
Since
name
,help
andgroup
strings never change, we should keep them in flash and save some RAM.Best way I've found is storing them all in a single flash block, which requires only 4 bytes in the
Command
object.This requires use of a
CMDP_STRINGS
macro when callingregisterCommand
.To minimise disruption for existing code this can be enabled using
CMDPROC_FLASHSTRINGS=1
.When using regular Strings, there's also a small saving to be had by storing these together in a CStringArray.
For comparison, here's what
system_get_free_heap_size()
reports for theCommandLine
sample application.The call is made at the end of
init()
.Welcome message not used
This was used by original TelnetServer sample application. Have restored display of welcome message to connecting clients.
Also getting junk on display because of TELNET escape sequences, so filtered those out too.