]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_CLI_Demos/Sample-CLI-commands.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS-Plus / Demo / Common / FreeRTOS_Plus_CLI_Demos / Sample-CLI-commands.c
index ee4b655cb66169833d243d4edb9440bf3d9eb1f9..1d98a0b72dbb5995369dff0d3edfd1a0b7d36dc7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -8,7 +8,7 @@
 \r
     FreeRTOS is free software; you can redistribute it and/or modify it under\r
     the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
 \r
     ***************************************************************************\r
     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
@@ -70,8 +70,7 @@
 \r
  /******************************************************************************\r
  *\r
- * See the following URL for information on the commands defined in this file:\r
- * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml\r
+ * http://www.FreeRTOS.org/cli\r
  *\r
  ******************************************************************************/\r
 \r
@@ -110,7 +109,9 @@ static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferL
 /*\r
  * Implements the run-time-stats command.\r
  */\r
-static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );\r
+#if( configGENERATE_RUN_TIME_STATS == 1 )\r
+       static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );\r
+#endif /* configGENERATE_RUN_TIME_STATS */\r
 \r
 /*\r
  * Implements the echo-three-parameters command.\r
@@ -136,16 +137,6 @@ static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBuf
        static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );\r
 #endif\r
 \r
-/* Structure that defines the "run-time-stats" command line command.   This\r
-generates a table that shows how much run time each task has */\r
-static const CLI_Command_Definition_t xRunTimeStats =\r
-{\r
-       "run-time-stats", /* The command string to type. */\r
-       "\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",\r
-       prvRunTimeStatsCommand, /* The function to run. */\r
-       0 /* No parameters are expected. */\r
-};\r
-\r
 /* Structure that defines the "task-stats" command line command.  This generates\r
 a table that gives information on each task in the system. */\r
 static const CLI_Command_Definition_t xTaskStats =\r
@@ -178,6 +169,18 @@ static const CLI_Command_Definition_t xParameterEcho =
        -1 /* The user can enter any number of commands. */\r
 };\r
 \r
+#if( configGENERATE_RUN_TIME_STATS == 1 )\r
+       /* Structure that defines the "run-time-stats" command line command.   This\r
+       generates a table that shows how much run time each task has */\r
+       static const CLI_Command_Definition_t xRunTimeStats =\r
+       {\r
+               "run-time-stats", /* The command string to type. */\r
+               "\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",\r
+               prvRunTimeStatsCommand, /* The function to run. */\r
+               0 /* No parameters are expected. */\r
+       };\r
+#endif /* configGENERATE_RUN_TIME_STATS */\r
+\r
 #if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )\r
        /* Structure that defines the "query_heap" command line command. */\r
        static const CLI_Command_Definition_t xQueryHeap =\r
@@ -206,11 +209,16 @@ static const CLI_Command_Definition_t xParameterEcho =
 void vRegisterSampleCLICommands( void )\r
 {\r
        /* Register all the command line commands defined immediately above. */\r
-       FreeRTOS_CLIRegisterCommand( &xTaskStats );\r
-       FreeRTOS_CLIRegisterCommand( &xRunTimeStats );\r
+       FreeRTOS_CLIRegisterCommand( &xTaskStats );     \r
        FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );\r
        FreeRTOS_CLIRegisterCommand( &xParameterEcho );\r
 \r
+       #if( configGENERATE_RUN_TIME_STATS == 1 )\r
+       {\r
+               FreeRTOS_CLIRegisterCommand( &xRunTimeStats );\r
+       }\r
+       #endif\r
+       \r
        #if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )\r
        {\r
                FreeRTOS_CLIRegisterCommand( &xQueryHeap );\r
@@ -283,50 +291,54 @@ BaseType_t xSpacePadding;
 #endif /* configINCLUDE_QUERY_HEAP */\r
 /*-----------------------------------------------------------*/\r
 \r
-static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )\r
-{\r
-const char * const pcHeader = "  Abs Time      % Time\r\n****************************************\r\n";\r
-BaseType_t xSpacePadding;\r
+#if( configGENERATE_RUN_TIME_STATS == 1 )\r
+       \r
+       static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )\r
+       {\r
+       const char * const pcHeader = "  Abs Time      % Time\r\n****************************************\r\n";\r
+       BaseType_t xSpacePadding;\r
 \r
-       /* Remove compile time warnings about unused parameters, and check the\r
-       write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
-       write buffer length is adequate, so does not check for buffer overflows. */\r
-       ( void ) pcCommandString;\r
-       ( void ) xWriteBufferLen;\r
-       configASSERT( pcWriteBuffer );\r
+               /* Remove compile time warnings about unused parameters, and check the\r
+               write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+               write buffer length is adequate, so does not check for buffer overflows. */\r
+               ( void ) pcCommandString;\r
+               ( void ) xWriteBufferLen;\r
+               configASSERT( pcWriteBuffer );\r
 \r
-       /* Generate a table of task stats. */\r
-       strcpy( pcWriteBuffer, "Task" );\r
-       pcWriteBuffer += strlen( pcWriteBuffer );\r
+               /* Generate a table of task stats. */\r
+               strcpy( pcWriteBuffer, "Task" );\r
+               pcWriteBuffer += strlen( pcWriteBuffer );\r
 \r
-       /* Pad the string "task" with however many bytes necessary to make it the\r
-       length of a task name.  Minus three for the null terminator and half the\r
-       number of characters in "Task" so the column lines up with the centre of\r
-       the heading. */\r
-       for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )\r
-       {\r
-               /* Add a space to align columns after the task's name. */\r
-               *pcWriteBuffer = ' ';\r
-               pcWriteBuffer++;\r
+               /* Pad the string "task" with however many bytes necessary to make it the\r
+               length of a task name.  Minus three for the null terminator and half the\r
+               number of characters in "Task" so the column lines up with the centre of\r
+               the heading. */\r
+               for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )\r
+               {\r
+                       /* Add a space to align columns after the task's name. */\r
+                       *pcWriteBuffer = ' ';\r
+                       pcWriteBuffer++;\r
 \r
-               /* Ensure always terminated. */\r
-               *pcWriteBuffer = 0x00;\r
-       }\r
+                       /* Ensure always terminated. */\r
+                       *pcWriteBuffer = 0x00;\r
+               }\r
 \r
-       strcpy( pcWriteBuffer, pcHeader );\r
-       vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );\r
+               strcpy( pcWriteBuffer, pcHeader );\r
+               vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );\r
 \r
-       /* There is no more data to return after this single string, so return\r
-       pdFALSE. */\r
-       return pdFALSE;\r
-}\r
+               /* There is no more data to return after this single string, so return\r
+               pdFALSE. */\r
+               return pdFALSE;\r
+       }\r
+       \r
+#endif /* configGENERATE_RUN_TIME_STATS */\r
 /*-----------------------------------------------------------*/\r
 \r
 static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )\r
 {\r
 const char *pcParameter;\r
 BaseType_t xParameterStringLength, xReturn;\r
-static BaseType_t lParameterNumber = 0;\r
+static UBaseType_t uxParameterNumber = 0;\r
 \r
        /* Remove compile time warnings about unused parameters, and check the\r
        write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
@@ -335,7 +347,7 @@ static BaseType_t lParameterNumber = 0;
        ( void ) xWriteBufferLen;\r
        configASSERT( pcWriteBuffer );\r
 \r
-       if( lParameterNumber == 0 )\r
+       if( uxParameterNumber == 0 )\r
        {\r
                /* The first time the function is called after the command has been\r
                entered just a header string is returned. */\r
@@ -343,7 +355,7 @@ static BaseType_t lParameterNumber = 0;
 \r
                /* Next time the function is called the first parameter will be echoed\r
                back. */\r
-               lParameterNumber = 1L;\r
+               uxParameterNumber = 1U;\r
 \r
                /* There is more data to be returned as no parameters have been echoed\r
                back yet. */\r
@@ -355,7 +367,7 @@ static BaseType_t lParameterNumber = 0;
                pcParameter = FreeRTOS_CLIGetParameter\r
                                                (\r
                                                        pcCommandString,                /* The command string itself. */\r
-                                                       lParameterNumber,               /* Return the next parameter. */\r
+                                                       uxParameterNumber,              /* Return the next parameter. */\r
                                                        &xParameterStringLength /* Store the parameter string length. */\r
                                                );\r
 \r
@@ -364,24 +376,24 @@ static BaseType_t lParameterNumber = 0;
 \r
                /* Return the parameter string. */\r
                memset( pcWriteBuffer, 0x00, xWriteBufferLen );\r
-               sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );\r
-               strncat( pcWriteBuffer, pcParameter, xParameterStringLength );\r
+               sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );\r
+               strncat( pcWriteBuffer, pcParameter, ( size_t ) xParameterStringLength );\r
                strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );\r
 \r
                /* If this is the last of the three parameters then there are no more\r
                strings to return after this one. */\r
-               if( lParameterNumber == 3L )\r
+               if( uxParameterNumber == 3U )\r
                {\r
                        /* If this is the last of the three parameters then there are no more\r
                        strings to return after this one. */\r
                        xReturn = pdFALSE;\r
-                       lParameterNumber = 0L;\r
+                       uxParameterNumber = 0;\r
                }\r
                else\r
                {\r
                        /* There are more parameters to return after this one. */\r
                        xReturn = pdTRUE;\r
-                       lParameterNumber++;\r
+                       uxParameterNumber++;\r
                }\r
        }\r
 \r
@@ -393,7 +405,7 @@ static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBuf
 {\r
 const char *pcParameter;\r
 BaseType_t xParameterStringLength, xReturn;\r
-static BaseType_t lParameterNumber = 0;\r
+static UBaseType_t uxParameterNumber = 0;\r
 \r
        /* Remove compile time warnings about unused parameters, and check the\r
        write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
@@ -402,7 +414,7 @@ static BaseType_t lParameterNumber = 0;
        ( void ) xWriteBufferLen;\r
        configASSERT( pcWriteBuffer );\r
 \r
-       if( lParameterNumber == 0 )\r
+       if( uxParameterNumber == 0 )\r
        {\r
                /* The first time the function is called after the command has been\r
                entered just a header string is returned. */\r
@@ -410,7 +422,7 @@ static BaseType_t lParameterNumber = 0;
 \r
                /* Next time the function is called the first parameter will be echoed\r
                back. */\r
-               lParameterNumber = 1L;\r
+               uxParameterNumber = 1U;\r
 \r
                /* There is more data to be returned as no parameters have been echoed\r
                back yet. */\r
@@ -422,7 +434,7 @@ static BaseType_t lParameterNumber = 0;
                pcParameter = FreeRTOS_CLIGetParameter\r
                                                (\r
                                                        pcCommandString,                /* The command string itself. */\r
-                                                       lParameterNumber,               /* Return the next parameter. */\r
+                                                       uxParameterNumber,              /* Return the next parameter. */\r
                                                        &xParameterStringLength /* Store the parameter string length. */\r
                                                );\r
 \r
@@ -430,13 +442,13 @@ static BaseType_t lParameterNumber = 0;
                {\r
                        /* Return the parameter string. */\r
                        memset( pcWriteBuffer, 0x00, xWriteBufferLen );\r
-                       sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );\r
-                       strncat( pcWriteBuffer, pcParameter, xParameterStringLength );\r
+                       sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );\r
+                       strncat( pcWriteBuffer, ( char * ) pcParameter, ( size_t ) xParameterStringLength );\r
                        strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );\r
 \r
                        /* There might be more parameters to return after this one. */\r
                        xReturn = pdTRUE;\r
-                       lParameterNumber++;\r
+                       uxParameterNumber++;\r
                }\r
                else\r
                {\r
@@ -448,7 +460,7 @@ static BaseType_t lParameterNumber = 0;
                        xReturn = pdFALSE;\r
 \r
                        /* Start over the next time this command is executed. */\r
-                       lParameterNumber = 0;\r
+                       uxParameterNumber = 0;\r
                }\r
        }\r
 \r