2 FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
4 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
6 ***************************************************************************
\r
8 * FreeRTOS provides completely free yet professionally developed, *
\r
9 * robust, strictly quality controlled, supported, and cross *
\r
10 * platform software that has become a de facto standard. *
\r
12 * Help yourself get started quickly and support the FreeRTOS *
\r
13 * project by purchasing a FreeRTOS tutorial book, reference *
\r
14 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
18 ***************************************************************************
\r
20 This file is part of the FreeRTOS distribution.
\r
22 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
23 the terms of the GNU General Public License (version 2) as published by the
\r
24 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
26 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
27 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
28 >>! the source code for proprietary components outside of the FreeRTOS
\r
31 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
32 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
33 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
34 link: http://www.freertos.org/a00114.html
\r
38 ***************************************************************************
\r
40 * Having a problem? Start by reading the FAQ "My application does *
\r
41 * not run, what could be wrong?" *
\r
43 * http://www.FreeRTOS.org/FAQHelp.html *
\r
45 ***************************************************************************
\r
47 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
48 license and Real Time Engineers Ltd. contact details.
\r
50 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
51 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
52 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
54 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
55 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
56 licenses offer ticketed support, indemnification and middleware.
\r
58 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
59 engineered and independently SIL3 certified version for use in safety and
\r
60 mission critical applications that require provable dependability.
\r
65 /******************************************************************************
\r
67 * See the following URL for information on the commands defined in this file:
\r
68 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml
\r
70 ******************************************************************************/
\r
73 /* FreeRTOS includes. */
\r
74 #include "FreeRTOS.h"
\r
77 /* Standard includes. */
\r
82 /* FreeRTOS+CLI includes. */
\r
83 #include "FreeRTOS_CLI.h"
\r
85 /* FreeRTOS+UDP includes, just to make the stats available to the CLI
\r
87 #include "FreeRTOS_UDP_IP.h"
\r
88 #include "FreeRTOS_Sockets.h"
\r
90 #ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
\r
91 #define configINCLUDE_TRACE_RELATED_CLI_COMMANDS 0
\r
96 * Implements the run-time-stats command.
\r
98 static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
101 * Implements the task-stats command.
\r
103 static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
106 * Implements the echo-three-parameters command.
\r
108 static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
111 * Implements the echo-parameters command.
\r
113 static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
116 * Defines a command that prints out IP address information.
\r
118 static portBASE_TYPE prvDisplayIPConfig( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
121 * Defines a command that prints out the gathered demo debug stats.
\r
123 static portBASE_TYPE prvDisplayIPDebugStats( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
126 * Defines a command that sends an ICMP ping request to an IP address.
\r
128 static portBASE_TYPE prvPingCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
131 * Implements the "trace start" and "trace stop" commands;
\r
133 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
134 static portBASE_TYPE prvStartStopTraceCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
\r
137 /* Structure that defines the "ip-config" command line command. */
\r
138 static const CLI_Command_Definition_t xIPConfig =
\r
140 ( const int8_t * const ) "ip-config",
\r
141 ( const int8_t * const ) "ip-config:\r\n Displays IP address configuration\r\n\r\n",
\r
142 prvDisplayIPConfig,
\r
146 #if configINCLUDE_DEMO_DEBUG_STATS != 0
\r
147 /* Structure that defines the "ip-debug-stats" command line command. */
\r
148 static const CLI_Command_Definition_t xIPDebugStats =
\r
150 ( const int8_t * const ) "ip-debug-stats", /* The command string to type. */
\r
151 ( const int8_t * const ) "ip-debug-stats:\r\n Shows some IP stack stats useful for debug - an example only.\r\n\r\n",
\r
152 prvDisplayIPDebugStats, /* The function to run. */
\r
153 0 /* No parameters are expected. */
\r
155 #endif /* configINCLUDE_DEMO_DEBUG_STATS */
\r
157 /* Structure that defines the "run-time-stats" command line command. This
\r
158 generates a table that shows how much run time each task has */
\r
159 static const CLI_Command_Definition_t xRunTimeStats =
\r
161 ( const int8_t * const ) "run-time-stats", /* The command string to type. */
\r
162 ( const int8_t * const ) "run-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n\r\n",
\r
163 prvRunTimeStatsCommand, /* The function to run. */
\r
164 0 /* No parameters are expected. */
\r
167 /* Structure that defines the "task-stats" command line command. This generates
\r
168 a table that gives information on each task in the system. */
\r
169 static const CLI_Command_Definition_t xTaskStats =
\r
171 ( const int8_t * const ) "task-stats", /* The command string to type. */
\r
172 ( const int8_t * const ) "task-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n\r\n",
\r
173 prvTaskStatsCommand, /* The function to run. */
\r
174 0 /* No parameters are expected. */
\r
177 /* Structure that defines the "echo_3_parameters" command line command. This
\r
178 takes exactly three parameters that the command simply echos back one at a
\r
180 static const CLI_Command_Definition_t xThreeParameterEcho =
\r
182 ( const int8_t * const ) "echo-3-parameters",
\r
183 ( const int8_t * const ) "echo-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n\r\n",
\r
184 prvThreeParameterEchoCommand, /* The function to run. */
\r
185 3 /* Three parameters are expected, which can take any value. */
\r
188 /* Structure that defines the "echo_parameters" command line command. This
\r
189 takes a variable number of parameters that the command simply echos back one at
\r
191 static const CLI_Command_Definition_t xParameterEcho =
\r
193 ( const int8_t * const ) "echo-parameters",
\r
194 ( const int8_t * const ) "echo-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n\r\n",
\r
195 prvParameterEchoCommand, /* The function to run. */
\r
196 -1 /* The user can enter any number of commands. */
\r
199 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
201 /* Structure that defines the "ping" command line command. This takes an IP
\r
202 address or host name and (optionally) the number of bytes to ping as
\r
204 static const CLI_Command_Definition_t xPing =
\r
206 ( const int8_t * const ) "ping",
\r
207 ( const int8_t * const ) "ping <ipaddress> <optional:bytes to send>:\r\n for example, ping 192.168.0.3 8, or ping www.example.com\r\n\r\n",
\r
208 prvPingCommand, /* The function to run. */
\r
209 -1 /* Ping can take either one or two parameter, so the number of parameters has to be determined by the ping command implementation. */
\r
212 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
214 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
215 /* Structure that defines the "trace" command line command. This takes a single
\r
216 parameter, which can be either "start" or "stop". */
\r
217 static const CLI_Command_Definition_t xStartStopTrace =
\r
219 ( const int8_t * const ) "trace",
\r
220 ( const int8_t * const ) "trace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n\r\n",
\r
221 prvStartStopTraceCommand, /* The function to run. */
\r
222 1 /* One parameter is expected. Valid values are "start" and "stop". */
\r
224 #endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
\r
226 /*-----------------------------------------------------------*/
\r
228 void vRegisterCLICommands( void )
\r
230 /* Register all the command line commands defined immediately above. */
\r
231 FreeRTOS_CLIRegisterCommand( &xTaskStats );
\r
232 FreeRTOS_CLIRegisterCommand( &xRunTimeStats );
\r
233 FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );
\r
234 FreeRTOS_CLIRegisterCommand( &xParameterEcho );
\r
235 FreeRTOS_CLIRegisterCommand( &xIPDebugStats );
\r
236 FreeRTOS_CLIRegisterCommand( &xIPConfig );
\r
238 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
240 FreeRTOS_CLIRegisterCommand( &xPing );
\r
242 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
244 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
245 FreeRTOS_CLIRegisterCommand( & xStartStopTrace );
\r
248 /*-----------------------------------------------------------*/
\r
250 static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
252 const int8_t *const pcHeader = ( int8_t * ) "Task State Priority Stack #\r\n************************************************\r\n";
\r
254 /* Remove compile time warnings about unused parameters, and check the
\r
255 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
256 write buffer length is adequate, so does not check for buffer overflows. */
\r
257 ( void ) pcCommandString;
\r
258 ( void ) xWriteBufferLen;
\r
259 configASSERT( pcWriteBuffer );
\r
261 /* Generate a table of task stats. */
\r
262 strcpy( ( char * ) pcWriteBuffer, ( char * ) pcHeader );
\r
263 vTaskList( pcWriteBuffer + strlen( ( char * ) pcHeader ) );
\r
265 /* There is no more data to return after this single string, so return
\r
269 /*-----------------------------------------------------------*/
\r
271 static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
273 const int8_t * const pcHeader = ( int8_t * ) "Task Abs Time % Time\r\n****************************************\r\n";
\r
275 /* Remove compile time warnings about unused parameters, and check the
\r
276 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
277 write buffer length is adequate, so does not check for buffer overflows. */
\r
278 ( void ) pcCommandString;
\r
279 ( void ) xWriteBufferLen;
\r
280 configASSERT( pcWriteBuffer );
\r
282 /* Generate a table of task stats. */
\r
283 strcpy( ( char * ) pcWriteBuffer, ( char * ) pcHeader );
\r
284 vTaskGetRunTimeStats( pcWriteBuffer + strlen( ( char * ) pcHeader ) );
\r
286 /* There is no more data to return after this single string, so return
\r
290 /*-----------------------------------------------------------*/
\r
292 static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
294 int8_t *pcParameter;
\r
295 portBASE_TYPE xParameterStringLength, xReturn;
\r
296 static portBASE_TYPE lParameterNumber = 0;
\r
298 /* Remove compile time warnings about unused parameters, and check the
\r
299 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
300 write buffer length is adequate, so does not check for buffer overflows. */
\r
301 ( void ) pcCommandString;
\r
302 ( void ) xWriteBufferLen;
\r
303 configASSERT( pcWriteBuffer );
\r
305 if( lParameterNumber == 0 )
\r
307 /* The first time the function is called after the command has been
\r
308 entered just a header string is returned. */
\r
309 sprintf( ( char * ) pcWriteBuffer, "The three parameters were:\r\n" );
\r
311 /* Next time the function is called the first parameter will be echoed
\r
313 lParameterNumber = 1L;
\r
315 /* There is more data to be returned as no parameters have been echoed
\r
321 /* Obtain the parameter string. */
\r
322 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
\r
324 pcCommandString, /* The command string itself. */
\r
325 lParameterNumber, /* Return the next parameter. */
\r
326 &xParameterStringLength /* Store the parameter string length. */
\r
329 /* Sanity check something was returned. */
\r
330 configASSERT( pcParameter );
\r
332 /* Return the parameter string. */
\r
333 memset( pcWriteBuffer, 0x00, xWriteBufferLen );
\r
334 sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
\r
335 strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
\r
336 strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
\r
338 /* If this is the last of the three parameters then there are no more
\r
339 strings to return after this one. */
\r
340 if( lParameterNumber == 3L )
\r
342 /* If this is the last of the three parameters then there are no more
\r
343 strings to return after this one. */
\r
345 lParameterNumber = 0L;
\r
349 /* There are more parameters to return after this one. */
\r
351 lParameterNumber++;
\r
357 /*-----------------------------------------------------------*/
\r
359 static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
361 int8_t *pcParameter;
\r
362 portBASE_TYPE xParameterStringLength, xReturn;
\r
363 static portBASE_TYPE lParameterNumber = 0;
\r
365 /* Remove compile time warnings about unused parameters, and check the
\r
366 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
367 write buffer length is adequate, so does not check for buffer overflows. */
\r
368 ( void ) pcCommandString;
\r
369 ( void ) xWriteBufferLen;
\r
370 configASSERT( pcWriteBuffer );
\r
372 if( lParameterNumber == 0 )
\r
374 /* The first time the function is called after the command has been
\r
375 entered just a header string is returned. */
\r
376 sprintf( ( char * ) pcWriteBuffer, "The parameters were:\r\n" );
\r
378 /* Next time the function is called the first parameter will be echoed
\r
380 lParameterNumber = 1L;
\r
382 /* There is more data to be returned as no parameters have been echoed
\r
388 /* Obtain the parameter string. */
\r
389 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
\r
391 pcCommandString, /* The command string itself. */
\r
392 lParameterNumber, /* Return the next parameter. */
\r
393 &xParameterStringLength /* Store the parameter string length. */
\r
396 if( pcParameter != NULL )
\r
398 /* Return the parameter string. */
\r
399 memset( pcWriteBuffer, 0x00, xWriteBufferLen );
\r
400 sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
\r
401 strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
\r
402 strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
\r
404 /* There might be more parameters to return after this one. */
\r
406 lParameterNumber++;
\r
410 /* No more parameters were found. Make sure the write buffer does
\r
411 not contain a valid string. */
\r
412 pcWriteBuffer[ 0 ] = 0x00;
\r
414 /* No more data to return. */
\r
417 /* Start over the next time this command is executed. */
\r
418 lParameterNumber = 0;
\r
424 /*-----------------------------------------------------------*/
\r
426 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
428 static portBASE_TYPE prvPingCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
430 int8_t * pcParameter;
\r
431 portBASE_TYPE lParameterStringLength, xReturn;
\r
432 uint32_t ulIPAddress, ulBytesToPing;
\r
433 const uint32_t ulDefaultBytesToPing = 8UL;
\r
434 int8_t cBuffer[ 16 ];
\r
436 /* Remove compile time warnings about unused parameters, and check the
\r
437 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
438 write buffer length is adequate, so does not check for buffer overflows. */
\r
439 ( void ) pcCommandString;
\r
440 ( void ) xWriteBufferLen;
\r
441 configASSERT( pcWriteBuffer );
\r
443 /* Start with an empty string. */
\r
444 pcWriteBuffer[ 0 ] = 0x00;
\r
446 /* Obtain the number of bytes to ping. */
\r
447 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
\r
449 pcCommandString, /* The command string itself. */
\r
450 2, /* Return the second parameter. */
\r
451 &lParameterStringLength /* Store the parameter string length. */
\r
454 if( pcParameter == NULL )
\r
456 /* The number of bytes was not specified, so default it. */
\r
457 ulBytesToPing = ulDefaultBytesToPing;
\r
461 ulBytesToPing = atol( ( const char * ) pcParameter );
\r
464 /* Obtain the IP address string. */
\r
465 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
\r
467 pcCommandString, /* The command string itself. */
\r
468 1, /* Return the first parameter. */
\r
469 &lParameterStringLength /* Store the parameter string length. */
\r
472 /* Sanity check something was returned. */
\r
473 configASSERT( pcParameter );
\r
475 /* Attempt to obtain the IP address. If the first character is not a
\r
476 digit, assume the host name has been passed in. */
\r
477 if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
\r
479 ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
\r
483 /* Terminate the host name. */
\r
484 pcParameter[ lParameterStringLength ] = 0x00;
\r
486 /* Attempt to resolve host. */
\r
487 ulIPAddress = FreeRTOS_gethostbyname( ( uint8_t * ) pcParameter );
\r
490 /* Convert IP address, which may have come from a DNS lookup, to string. */
\r
491 FreeRTOS_inet_ntoa( ulIPAddress, ( char * ) cBuffer );
\r
493 if( ulIPAddress != 0 )
\r
495 xReturn = FreeRTOS_SendPingRequest( ulIPAddress, ( uint16_t ) ulBytesToPing, portMAX_DELAY );
\r
502 if( xReturn == pdFALSE )
\r
504 sprintf( ( char * ) pcWriteBuffer, "%s", "Could not send ping request\r\n" );
\r
508 sprintf( ( char * ) pcWriteBuffer, "Ping sent to %s with identifier %d\r\n", cBuffer, xReturn );
\r
513 /*-----------------------------------------------------------*/
\r
515 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
517 #if configINCLUDE_DEMO_DEBUG_STATS != 0
\r
519 static portBASE_TYPE prvDisplayIPDebugStats( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
521 static portBASE_TYPE xIndex = -1;
\r
522 extern xExampleDebugStatEntry_t xIPTraceValues[];
\r
523 portBASE_TYPE xReturn;
\r
525 /* Remove compile time warnings about unused parameters, and check the
\r
526 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
527 write buffer length is adequate, so does not check for buffer overflows. */
\r
528 ( void ) pcCommandString;
\r
529 ( void ) xWriteBufferLen;
\r
530 configASSERT( pcWriteBuffer );
\r
534 if( xIndex < xExampleDebugStatEntries() )
\r
536 sprintf( ( char * ) pcWriteBuffer, "%s %d\r\n", ( char * ) xIPTraceValues[ xIndex ].pucDescription, ( int ) xIPTraceValues[ xIndex ].ulData );
\r
541 /* Reset the index for the next time it is called. */
\r
544 /* Ensure nothing remains in the write buffer. */
\r
545 pcWriteBuffer[ 0 ] = 0x00;
\r
551 /*-----------------------------------------------------------*/
\r
553 #endif /* configINCLUDE_DEMO_DEBUG_STATS */
\r
555 static portBASE_TYPE prvDisplayIPConfig( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
557 static portBASE_TYPE xIndex = 0;
\r
558 portBASE_TYPE xReturn;
\r
559 uint32_t ulAddress;
\r
561 /* Remove compile time warnings about unused parameters, and check the
\r
562 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
563 write buffer length is adequate, so does not check for buffer overflows. */
\r
564 ( void ) pcCommandString;
\r
565 ( void ) xWriteBufferLen;
\r
566 configASSERT( pcWriteBuffer );
\r
571 FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
\r
572 sprintf( ( char * ) pcWriteBuffer, "\r\nIP address " );
\r
578 FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
\r
579 sprintf( ( char * ) pcWriteBuffer, "\r\nNet mask " );
\r
585 FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
\r
586 sprintf( ( char * ) pcWriteBuffer, "\r\nGateway address " );
\r
592 FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
\r
593 sprintf( ( char * ) pcWriteBuffer, "\r\nDNS server address " );
\r
600 sprintf( ( char * ) pcWriteBuffer, "\r\n\r\n" );
\r
606 if( ulAddress != 0 )
\r
608 FreeRTOS_inet_ntoa( ulAddress, ( ( char * ) &( pcWriteBuffer[ strlen( ( char * ) pcWriteBuffer ) ] ) ) );
\r
613 /*-----------------------------------------------------------*/
\r
615 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
617 static portBASE_TYPE prvStartStopTraceCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
\r
619 int8_t *pcParameter;
\r
620 portBASE_TYPE lParameterStringLength;
\r
622 /* Remove compile time warnings about unused parameters, and check the
\r
623 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
624 write buffer length is adequate, so does not check for buffer overflows. */
\r
625 ( void ) pcCommandString;
\r
626 ( void ) xWriteBufferLen;
\r
627 configASSERT( pcWriteBuffer );
\r
629 /* Obtain the parameter string. */
\r
630 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
\r
632 pcCommandString, /* The command string itself. */
\r
633 1, /* Return the first parameter. */
\r
634 &lParameterStringLength /* Store the parameter string length. */
\r
637 /* Sanity check something was returned. */
\r
638 configASSERT( pcParameter );
\r
640 /* There are only two valid parameter values. */
\r
641 if( strncmp( ( const char * ) pcParameter, "start", strlen( "start" ) ) == 0 )
\r
643 /* Start or restart the trace. */
\r
648 sprintf( ( char * ) pcWriteBuffer, "Trace recording (re)started.\r\n" );
\r
650 else if( strncmp( ( const char * ) pcParameter, "stop", strlen( "stop" ) ) == 0 )
\r
652 /* End the trace, if one is running. */
\r
654 sprintf( ( char * ) pcWriteBuffer, "Stopping trace recording.\r\n" );
\r
658 sprintf( ( char * ) pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" );
\r
661 /* There is no more data to return after this single string, so return
\r
666 #endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
\r