|
@@ -178,7 +178,7 @@ portBASE_TYPE FreeRTOS_CLIProcessCommand( const int8_t * const pcCommandInput, i
|
|
{
|
|
{
|
|
/* The command was found, but the number of parameters with the command
|
|
/* The command was found, but the number of parameters with the command
|
|
was incorrect. */
|
|
was incorrect. */
|
|
- strncpy( ( char * ) pcWriteBuffer, "Incorrect command parameter(s). Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen );
|
|
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, "Неправильно введены параметры команды. Введите \"help\" для просмотра списка поддерживаемых команд.\r\n\r\n", xWriteBufferLen );
|
|
pxCommand = NULL;
|
|
pxCommand = NULL;
|
|
}
|
|
}
|
|
else if( pxCommand != NULL )
|
|
else if( pxCommand != NULL )
|
|
@@ -197,7 +197,7 @@ portBASE_TYPE FreeRTOS_CLIProcessCommand( const int8_t * const pcCommandInput, i
|
|
else
|
|
else
|
|
{
|
|
{
|
|
/* pxCommand was NULL, the command was not found. */
|
|
/* pxCommand was NULL, the command was not found. */
|
|
- strncpy( ( char * ) pcWriteBuffer, ( const char * const ) "Command not recognised. Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen );
|
|
|
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * const ) "Команда не поддерживается. Введите \"help\" для просмотра списка поддерживаемых команд.\r\n\r\n", xWriteBufferLen );
|
|
xReturn = pdFALSE;
|
|
xReturn = pdFALSE;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -338,3 +338,83 @@ portBASE_TYPE xLastCharacterWasSpace = pdFALSE;
|
|
return cParameters;
|
|
return cParameters;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*-----------------------------------------------------------*/
|
|
|
|
+
|
|
|
|
+portBASE_TYPE FreeRTOS_CLICompleteCMDCommand( const int8_t * const pcCommandInput, int8_t * pcWriteBuffer)
|
|
|
|
+{
|
|
|
|
+ const CLI_Definition_List_Item_t *pxCommand = NULL;
|
|
|
|
+ portBASE_TYPE xReturn = pdFALSE;
|
|
|
|
+ const int8_t *pcRegisteredCommandString;
|
|
|
|
+ size_t xCommandStringLength;
|
|
|
|
+ int8_t args = 0;
|
|
|
|
+ char* compl_world;
|
|
|
|
+ uint8_t cnt_complete = 0 ;
|
|
|
|
+ uint8_t len = 0;
|
|
|
|
+ char* end_compl_word;
|
|
|
|
+ char* end_compl_word2;
|
|
|
|
+
|
|
|
|
+ args = prvGetNumberOfParameters(pcCommandInput);
|
|
|
|
+
|
|
|
|
+ memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);
|
|
|
|
+
|
|
|
|
+ if(args == 0){
|
|
|
|
+ for( pxCommand = &xRegisteredCommands; pxCommand != NULL; pxCommand = pxCommand->pxNext )
|
|
|
|
+ {
|
|
|
|
+ if (strstr ((char *)pxCommand->pxCommandLineDefinition->pcCommand, (char *)pcCommandInput) == (char *)pxCommand->pxCommandLineDefinition->pcCommand) {
|
|
|
|
+ compl_world = (char *)pxCommand->pxCommandLineDefinition->pcCommand;
|
|
|
|
+ compl_world += strlen((char *)pcCommandInput);
|
|
|
|
+ len = strlen(compl_world);
|
|
|
|
+ cnt_complete ++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ /* Search for the command string in the list of registered commands. */
|
|
|
|
+ for( pxCommand = &xRegisteredCommands; pxCommand != NULL; pxCommand = pxCommand->pxNext )
|
|
|
|
+ {
|
|
|
|
+ len = 0;
|
|
|
|
+ pcRegisteredCommandString = pxCommand->pxCommandLineDefinition->pcCommand;
|
|
|
|
+ xCommandStringLength = strlen( ( const char * ) pcRegisteredCommandString );
|
|
|
|
+
|
|
|
|
+ /* To ensure the string lengths match exactly, so as not to pick up
|
|
|
|
+ a sub-string of a longer command, check the byte after the expected
|
|
|
|
+ end of the string is either the end of the string or a space before
|
|
|
|
+ a parameter. */
|
|
|
|
+ if( ( pcCommandInput[ xCommandStringLength ] == ' ' ) || ( pcCommandInput[ xCommandStringLength ] == 0x00 ) )
|
|
|
|
+ {
|
|
|
|
+ if( strncmp( ( const char * ) pcCommandInput, ( const char * ) pcRegisteredCommandString, xCommandStringLength ) == 0 )
|
|
|
|
+ {
|
|
|
|
+ compl_world = strstr ((char *)pxCommand->pxCommandLineDefinition->pcHelpString, (char *)pcCommandInput);
|
|
|
|
+ while (compl_world != NULL) {
|
|
|
|
+ compl_world += (strlen((char *)pcCommandInput) - 1 );
|
|
|
|
+ end_compl_word = strstr(compl_world, ":");
|
|
|
|
+ if(end_compl_word != NULL){
|
|
|
|
+ end_compl_word2 = strstr(compl_world, " ");
|
|
|
|
+
|
|
|
|
+ if(end_compl_word2 == NULL){
|
|
|
|
+ if(end_compl_word2 < end_compl_word){
|
|
|
|
+ if(end_compl_word2[1] != '<'){
|
|
|
|
+ len = end_compl_word2 - compl_world;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ if(strstr(compl_world, ">") == NULL)
|
|
|
|
+ len = end_compl_word - compl_world;
|
|
|
|
+ }
|
|
|
|
+ compl_world = strstr ((char *)pxCommand->pxCommandLineDefinition->pcHelpString, compl_world);
|
|
|
|
+ cnt_complete ++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(cnt_complete == 1 && len != 0){
|
|
|
|
+ strncat((char *)pcWriteBuffer, compl_world, len);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return xReturn;
|
|
|
|
+}
|
|
|
|
+
|