Arduino-CmdMessenger icon indicating copy to clipboard operation
Arduino-CmdMessenger copied to clipboard

The available() should return Current!=null;

Open MikeBlueIce opened this issue 8 years ago • 3 comments

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?

MikeBlueIce avatar Oct 31 '16 20:10 MikeBlueIce

Honestly, if forgett why I available goes to the next parameter. I do not see samples using it. I will think on your suggestion.

thijse avatar Jan 12 '17 14:01 thijse

I find this "feature" annoying, too... :-P

Palatis avatar Feb 05 '17 18:02 Palatis

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.

sigmaeo avatar Mar 13 '18 20:03 sigmaeo