guagay_wk
guagay_wk

Reputation: 28060

Command not parsed properly in ESP8266 SMING example

I have set up the UART to receive and process commands using the CommandProcessing library by using the Telnet_TCPServer_TCPClient example of the SMING framework.

Here are the relevant code;

void 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,offshould work fine.

Upvotes: 0

Views: 184

Answers (1)

guagay_wk
guagay_wk

Reputation: 28060

The Command Processing library cannot detect the command with a comma. It detects the command with a space. You create a command list with CommandDelegate("command_name","Usage", ...).

In your context, appheap,off does not have a space, so you get a message Command not found, cmd = 'appheap,off'. The correct way to call the command is appheap off.

Upvotes: 1

Related Questions