-->
Page 1 of 1

Possible bug in CommandProcessing

PostPosted: Mon Dec 14, 2015 2:38 am
by helpme
I have set up the UART to receive and process commands using the CommandProcessing library by using the Telnet_TCPServer_TCPClient example.

Here are the relevant code;

Code: Select allvoid init()
{
   Serial.begin(SERIAL_BAUD_RATE);
        Serial.commandProcessing(true);
   commandHandler.registerCommand(CommandDelegate("appheap","Usage appheap on/off/now for     
                                                                                         heapdisplay\r\n","testGroup", appheapCommand));
   memoryTimer.initializeMs(250,checkHeap).start();
}

void appheapCommand(String commandLine  ,CommandOutput* commandOutput)
{
   Vector<String> commandToken;
   int numToken = splitString(commandLine, ',' , commandToken);
        //The rest are same as inside sample code.
}


When I send this string `appheap ,off` to the UART, the command is parsed properly.

However, when I send this string `appheap,off` to the UART, the command is not parsed properly. The message returned is `Command not found, cmd = 'appheap,off'`.

If things are going fine, both strings `appheap ,off` and `appheap,off`should work fine.

Re: Possible bug in CommandProcessing

PostPosted: Mon Dec 14, 2015 3:04 am
by hreintke
The commandprocessor "detects" the command to be processed based on the occurrence if the first space or end-of line and comparing that withe the commandlist created by the (CommandDelegate("appheap","Usage ..... commands.

in your example "appheap" in the list "appheap,off" on the command line -> unknown command

If you enter "appheap off" the appheapCommand function will be called.

Re: Possible bug in CommandProcessing

PostPosted: Mon Dec 14, 2015 3:38 am
by helpme
Thanks for your reply. Things are clearer now.

In my command handler,
Code: Select allvoid appheapCommand(String commandLine  ,CommandOutput* commandOutput)
{
   Vector<String> commandToken;
   int numToken = splitString(commandLine, ',' , commandToken);
        //The rest are same as inside sample code.
}

The string `commandLine` is for the string after `appheap`, right? In other words, if the command received is `appheap on,1`, then `commandLine` string will be `on,1` , correct?

Re: Possible bug in CommandProcessing

PostPosted: Mon Dec 14, 2015 6:01 am
by hreintke
No, the commandLine is the full inputline. Thus in your example will be `appheap on,1`
This is to make it possible that multiple commands can be handled by one delegate.

So you could have f.e.
CommandDelegate("appheap",.....,appheapCommand)
and
CommandDelegate("appheapMax",.....,appheapCommand)