Page 1 of 1

Command Parameters

Posted: Sat Dec 26, 2020 3:02 am
by leon
Firstly, merry xmas.
I have several text boxs on the UI and I want to pass the values to Arduino using Serial Command.
The issue is that a person can type text within a text box that includes spaces. eg John Citizen
When data is passed to Arduino, it see this as two separate parameters.
For example !SaveProjectData John Citizen Male

. . . . .
void Cmd_SaveProjectData(CommandParameter &Parameters){
_sName = Parameters.NextParameter();
_sSex = Parameters.NextParameter();
. . . . .

In the code above, _sName would be assigned John and _sSex would be assigned Citizen

Referring to the documentation

Working with Command Parameters
Parameters are the optional part of a command which follow the command name. There is 1 space between the command and the first parameter; each parameter is separated by 1 space.

I would value either being able to specify a delimiter eg "|" in the Arduino code or being able to add an escape character wrap around the text from the UI.

If there is a work around, would appreciate some guidance.

Re: Command Parameters

Posted: Sat Dec 26, 2020 3:46 am
by philr
I think if you put sex first then use .RemainingParameters() that will grab all remaining and that would include both names.


Re: Command Parameters

Posted: Sun Dec 27, 2020 4:57 am
by leon
Thanks for the quick reply Phil.
I am using .RemainingParameters() as suggested and formatting the message in the UI with key pair values separated by a delimiter.
The template for "CommandHandler" has been modified to increase the buffer size to allow for the longer message.
Will see how I go.