X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS-Plus%2FDemo%2FCommon%2FFreeRTOS_Plus_UDP_Demos%2FCLICommands%2FCLI-commands.c;h=fafef1713657a175c7b20ce4fe6ca619cd963bd0;hb=c80eb320d67bdeb11a219173ecec1fd38b269589;hp=09ee5905d630473e27b1e4c34b839c7cc34b8946;hpb=bb2faca82c580d60469d268594bdc3cb26a632b3;p=freertos diff --git a/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands/CLI-commands.c b/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands/CLI-commands.c index 09ee5905d..fafef1713 100644 --- a/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands/CLI-commands.c +++ b/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands/CLI-commands.c @@ -1,23 +1,9 @@ /* - FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd. + FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that has become a de facto standard. * - * * - * Help yourself get started quickly and support the FreeRTOS * - * project by purchasing a FreeRTOS tutorial book, reference * - * manual, or both from: http://www.FreeRTOS.org/Documentation * - * * - * Thank you! * - * * - *************************************************************************** - This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under @@ -31,7 +17,7 @@ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available from the following + FOR A PARTICULAR PURPOSE. Full license text is available on the following link: http://www.freertos.org/a00114.html 1 tab == 4 spaces! @@ -39,12 +25,53 @@ *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * + * not run, what could be wrong?". Have you defined configASSERT()? * * * * http://www.FreeRTOS.org/FAQHelp.html * * * *************************************************************************** + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + *************************************************************************** + * * + * Investing in training allows your team to be as productive as * + * possible as early as possible, lowering your overall development * + * cost, and enabling you to bring a more robust product to market * + * earlier than would otherwise be possible. Richard Barry is both * + * the architect and key author of FreeRTOS, and so also the world's * + * leading authority on what is the world's most popular real time * + * kernel for deeply embedded MCU designs. Obtaining your training * + * from Richard ensures your team will gain directly from his in-depth * + * product knowledge and years of usage experience. Contact Real Time * + * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented * + * by Richard Barry: http://www.FreeRTOS.org/contact + * * + *************************************************************************** + + *************************************************************************** + * * + * You are receiving this top quality software for free. Please play * + * fair and reciprocate by reporting any suspected issues and * + * participating in the community forum: * + * http://www.FreeRTOS.org/support * + * * + * Thank you! * + * * + *************************************************************************** + http://www.FreeRTOS.org - Documentation, books, training, latest versions, license and Real Time Engineers Ltd. contact details. @@ -52,9 +79,12 @@ including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and middleware. + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and @@ -96,43 +126,43 @@ commands. */ /* * Implements the run-time-stats command. */ -static portBASE_TYPE prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Implements the task-stats command. */ -static portBASE_TYPE prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Implements the echo-three-parameters command. */ -static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Implements the echo-parameters command. */ -static portBASE_TYPE prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Defines a command that prints out IP address information. */ -static portBASE_TYPE prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Defines a command that prints out the gathered demo debug stats. */ -static portBASE_TYPE prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Defines a command that sends an ICMP ping request to an IP address. */ -static portBASE_TYPE prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); +static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); /* * Implements the "trace start" and "trace stop" commands; */ #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 - static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); + static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); #endif /* Structure that defines the "ip-config" command line command. */ @@ -248,9 +278,10 @@ void vRegisterCLICommands( void ) } /*-----------------------------------------------------------*/ -static portBASE_TYPE prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) +static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { -const char *const pcHeader = "Task State Priority Stack #\r\n************************************************\r\n"; +const char *const pcHeader = " State\tPriority\tStack\t#\r\n************************************************\r\n"; +BaseType_t xSpacePadding; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the @@ -260,6 +291,22 @@ const char *const pcHeader = "Task State Priority Stack #\r\n******** configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ + strcpy( pcWriteBuffer, "Task" ); + pcWriteBuffer += strlen( pcWriteBuffer ); + + /* Pad the string "task" with however many bytes necessary to make it the + length of a task name. Minus three for the null terminator and half the + number of characters in "Task" so the column lines up with the centre of + the heading. */ + for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ ) + { + /* Add a space to align columns after the task's name. */ + *pcWriteBuffer = ' '; + pcWriteBuffer++; + + /* Ensure always terminated. */ + *pcWriteBuffer = 0x00; + } strcpy( pcWriteBuffer, pcHeader ); vTaskList( pcWriteBuffer + strlen( pcHeader ) ); @@ -269,9 +316,10 @@ const char *const pcHeader = "Task State Priority Stack #\r\n******** } /*-----------------------------------------------------------*/ -static portBASE_TYPE prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) +static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { -const char * const pcHeader = "Task Abs Time % Time\r\n****************************************\r\n"; +const char * const pcHeader = " Abs Time % Time\r\n****************************************\r\n"; +BaseType_t xSpacePadding; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the @@ -281,6 +329,23 @@ const char * const pcHeader = "Task Abs Time % Time\r\n********* configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ + strcpy( pcWriteBuffer, "Task" ); + pcWriteBuffer += strlen( pcWriteBuffer ); + + /* Pad the string "task" with however many bytes necessary to make it the + length of a task name. Minus three for the null terminator and half the + number of characters in "Task" so the column lines up with the centre of + the heading. */ + for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ ) + { + /* Add a space to align columns after the task's name. */ + *pcWriteBuffer = ' '; + pcWriteBuffer++; + + /* Ensure always terminated. */ + *pcWriteBuffer = 0x00; + } + strcpy( pcWriteBuffer, pcHeader ); vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) ); @@ -290,11 +355,11 @@ const char * const pcHeader = "Task Abs Time % Time\r\n********* } /*-----------------------------------------------------------*/ -static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) +static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { const char *pcParameter; -portBASE_TYPE xParameterStringLength, xReturn; -static portBASE_TYPE lParameterNumber = 0; +BaseType_t xParameterStringLength, xReturn; +static BaseType_t lParameterNumber = 0; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the @@ -357,11 +422,11 @@ static portBASE_TYPE lParameterNumber = 0; } /*-----------------------------------------------------------*/ -static portBASE_TYPE prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) +static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { const char *pcParameter; -portBASE_TYPE xParameterStringLength, xReturn; -static portBASE_TYPE lParameterNumber = 0; +BaseType_t xParameterStringLength, xReturn; +static BaseType_t lParameterNumber = 0; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the @@ -426,10 +491,10 @@ static portBASE_TYPE lParameterNumber = 0; #if ipconfigSUPPORT_OUTGOING_PINGS == 1 - static portBASE_TYPE prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) + static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { char * pcParameter; - portBASE_TYPE lParameterStringLength, xReturn; + BaseType_t lParameterStringLength, xReturn; uint32_t ulIPAddress, ulBytesToPing; const uint32_t ulDefaultBytesToPing = 8UL; char cBuffer[ 16 ]; @@ -517,11 +582,11 @@ static portBASE_TYPE lParameterNumber = 0; #if configINCLUDE_DEMO_DEBUG_STATS != 0 - static portBASE_TYPE prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) + static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { - static portBASE_TYPE xIndex = -1; + static BaseType_t xIndex = -1; extern xExampleDebugStatEntry_t xIPTraceValues[]; - portBASE_TYPE xReturn; + BaseType_t xReturn; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the @@ -553,10 +618,10 @@ static portBASE_TYPE lParameterNumber = 0; #endif /* configINCLUDE_DEMO_DEBUG_STATS */ -static portBASE_TYPE prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) +static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { -static portBASE_TYPE xIndex = 0; -portBASE_TYPE xReturn; +static BaseType_t xIndex = 0; +BaseType_t xReturn; uint32_t ulAddress; /* Remove compile time warnings about unused parameters, and check the @@ -615,10 +680,10 @@ uint32_t ulAddress; #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 - static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) + static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) { const char *pcParameter; - portBASE_TYPE lParameterStringLength; + BaseType_t lParameterStringLength; /* Remove compile time warnings about unused parameters, and check the write buffer is not NULL. NOTE - for simplicity, this example assumes the