Arduino-CmdMessenger
Arduino-CmdMessenger copied to clipboard
The available() should return Current!=null;
For variable number of arguments, this code will not work:
while (cmdMessenger.available())
{
int curNo=cmdMessenger.readInt16Arg();
// Do something with this number.
}
It will skip 1 parameter at a time. Was this function intended for this?
Honestly, if forgett why I available goes to the next parameter. I do not see samples using it. I will think on your suggestion.
I find this "feature" annoying, too... :-P
Me too.
Instead of:
if( cmdMessenger.available() ) { value1 = cm.readInt32Arg(); if( cmdMessenger.available() ) value2 = cm.readInt32Arg(); }
One have to do it this way:
ui32 = cm.readInt32Arg(); if( cm.isArgOk() ) { value1 = ui32; ui32 = cm.readInt32Arg(); if( cm.isArgOk() ) ui32 = cm.readInt32Arg(); }
If I send the command string (command-id=0): 0,1,2,3,4,5;
The first example catches: value1=2 and value2=4
The second example catches: value1=1 and value2=2 as expected.