Skip to content

Conversation

@jan-r
Copy link

@jan-r jan-r commented May 25, 2017

New versions of the Arduino IDE throw a compiler warning
if you pass a const char * aka string literal ("hello world") to
a char * function argument. This commit changes the prototype to
take a const char *.

jan-r added 2 commits May 25, 2017 10:01
New versions of the Arduino IDE throw a compiler warning
if you pass a const char * aka string literal ("hello world") to
a char * function argument. This commit changes the prototype to
take a const char *.
The examples did not compile since cmdInit was changed to
accept a Stream reference instead of a serial port speed. This
change fixes all examples. It also adds a new function
cmdGetStream(). This allows command functions to get access to
the same stream that is used by the command interpreter itself.
If you change a sketch from using the serial port to using a
different stream, you can simply change the initialisation of the
cmd module and all command functions can remain unchanged.

The commit also contains a fix to ignore \n characters as they
are usually not part of a valid command. This way, the code works
with all terminals, no matter if they send \r or \r\n line endings.
@jan-r
Copy link
Author

jan-r commented May 25, 2017

I've added one more commit to fix the examples. Hope this is useful for you.

@jan-r jan-r changed the title Fix prototype of cmdAdd to remove Compiler warning Remove compiler warning, fix examples May 25, 2017
@joshmarinacci joshmarinacci merged commit fedd8f2 into joshmarinacci:master Jun 5, 2017
@joshmarinacci
Copy link
Owner

Thank you so much. I appreciate the fix!

@jan-r jan-r deleted the bugfix/ConstCorrectness branch June 5, 2017 19:57
@jan-r
Copy link
Author

jan-r commented Jun 5, 2017

You're welcome. I can contribute more changes in the future, but they will most likely break compatibility (like re-enabling the dot as an allowed input character, because I need the possibility to pass floating point numbers as command arguments).

@joshmarinacci
Copy link
Owner

I don't think many people use it, so I'm happy to have you add new features even if it breaks compatibility. Just be sure to add a explanatory note in the readme

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.

2 participants