/* This function implements the behaviour of a command, so must have the correct prototype. */ static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, constchar *pcCommandString ) { /* 为简单起见,此函数假设输出缓冲区足够大,可以容纳执行vTaskList() API函数生成的 所有文本,因此不使用xWriteBufferLen参数。 */ ( void ) xWriteBufferLen;
/* This function implements the behaviour of a command, so must have the correct prototype. */ static BaseType_t prvHelpCommand( char *pcWriteBuffer, size_t xWriteBufferLen, constchar *pcCommandString ) { /* 执行“help”命令将生成多行文本,但此函数一次只输出一行。因此,要多次调用该函数来完成对 单个“help”命令的处理。这意味着它必须记住哪些帮助字符串已经输出,哪些还有待输出。 静态pxCommand变量用于指向需要输出的下一个帮助字符串。*/ staticconst xCommandLineInputListItem *pxCommand = NULL; signed BaseType_t xReturn;
/* This function implements the behaviour of a command, so must have the correct prototype. */ static BaseType_t prvCopyCommand( char *pcWriteBuffer, size_t xWriteBufferLen, constchar *pcCommandString ) { char *pcParameter1, *pcParameter2; BaseType_t xParameter1StringLength, xParameter2StringLength, xResult;
示例 4 演示了如何创建和实现一个接受可变数量参数的命令。 FreeRTOS-Plus-CLI 不会检查所提供的参数的数量, 命令的执行只是简单的回传参数,一次一个。例如,如果分配的命令字符串为 “echo_parameters”, 则当用户输入echo_parameters one two three four时生成以下输出结果:
1 2 3 4 5
The parameters were: 1: one 2: two 3: three 4: four