通过使用CommandProcessing框架的Telnet_TCPServer_TCPClient示例,我已经将UART设置为使用SMING库接收和处理命令。
以下是相关代码;
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.
}当我将这个字符串appheap ,off发送到UART时,命令被正确解析。
但是,当我将这个字符串appheap,off发送到UART时,命令没有被正确解析。返回的消息为Command not found, cmd = 'appheap,off'。
如果一切顺利,字符串appheap ,off和appheap,off应该都能正常工作。
发布于 2015-12-14 19:59:03
命令处理库无法检测到带有逗号的命令。它检测带有空格的命令。您可以使用CommandDelegate("command_name","Usage", ...)创建命令列表。
在您的上下文中,appheap,off没有空格,因此您会得到一条消息Command not found, cmd = 'appheap,off'。调用该命令的正确方法是appheap off。
https://stackoverflow.com/questions/34261923
复制相似问题