2 FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
14 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
15 >>! obliged to provide the source code for proprietary components !<<
\r
16 >>! outside of the FreeRTOS kernel. !<<
\r
18 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
20 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
21 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * Having a problem? Start by reading the FAQ "My application does *
\r
28 * not run, what could be wrong?". Have you defined configASSERT()? *
\r
30 * http://www.FreeRTOS.org/FAQHelp.html *
\r
32 ***************************************************************************
\r
34 ***************************************************************************
\r
36 * FreeRTOS provides completely free yet professionally developed, *
\r
37 * robust, strictly quality controlled, supported, and cross *
\r
38 * platform software that is more than just the market leader, it *
\r
39 * is the industry's de facto standard. *
\r
41 * Help yourself get started quickly while simultaneously helping *
\r
42 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
43 * tutorial book, reference manual, or both: *
\r
44 * http://www.FreeRTOS.org/Documentation *
\r
46 ***************************************************************************
\r
48 ***************************************************************************
\r
50 * Investing in training allows your team to be as productive as *
\r
51 * possible as early as possible, lowering your overall development *
\r
52 * cost, and enabling you to bring a more robust product to market *
\r
53 * earlier than would otherwise be possible. Richard Barry is both *
\r
54 * the architect and key author of FreeRTOS, and so also the world's *
\r
55 * leading authority on what is the world's most popular real time *
\r
56 * kernel for deeply embedded MCU designs. Obtaining your training *
\r
57 * from Richard ensures your team will gain directly from his in-depth *
\r
58 * product knowledge and years of usage experience. Contact Real Time *
\r
59 * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented *
\r
60 * by Richard Barry: http://www.FreeRTOS.org/contact
\r
62 ***************************************************************************
\r
64 ***************************************************************************
\r
66 * You are receiving this top quality software for free. Please play *
\r
67 * fair and reciprocate by reporting any suspected issues and *
\r
68 * participating in the community forum: *
\r
69 * http://www.FreeRTOS.org/support *
\r
73 ***************************************************************************
\r
75 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
76 license and Real Time Engineers Ltd. contact details.
\r
78 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
79 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
80 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
82 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
83 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
85 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
86 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
87 licenses offer ticketed support, indemnification and commercial middleware.
\r
89 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
90 engineered and independently SIL3 certified version for use in safety and
\r
91 mission critical applications that require provable dependability.
\r
96 /******************************************************************************
\r
98 * See the following URL for information on the commands defined in this file:
\r
99 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml
\r
101 ******************************************************************************/
\r
104 /* FreeRTOS includes. */
\r
105 #include "FreeRTOS.h"
\r
108 /* Standard includes. */
\r
109 #include <stdint.h>
\r
111 #include <stdlib.h>
\r
113 /* FreeRTOS+CLI includes. */
\r
114 #include "FreeRTOS_CLI.h"
\r
116 /* FreeRTOS+UDP includes, just to make the stats available to the CLI
\r
118 #include "FreeRTOS_UDP_IP.h"
\r
119 #include "FreeRTOS_Sockets.h"
\r
121 #ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
\r
122 #define configINCLUDE_TRACE_RELATED_CLI_COMMANDS 0
\r
127 * Implements the run-time-stats command.
\r
129 static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
132 * Implements the task-stats command.
\r
134 static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
137 * Implements the echo-three-parameters command.
\r
139 static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
142 * Implements the echo-parameters command.
\r
144 static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
147 * Defines a command that prints out IP address information.
\r
149 static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
152 * Defines a command that prints out the gathered demo debug stats.
\r
154 static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
157 * Defines a command that sends an ICMP ping request to an IP address.
\r
159 static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
162 * Implements the "trace start" and "trace stop" commands;
\r
164 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
165 static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
\r
168 /* Structure that defines the "ip-config" command line command. */
\r
169 static const CLI_Command_Definition_t xIPConfig =
\r
172 "ip-config:\r\n Displays IP address configuration\r\n\r\n",
\r
173 prvDisplayIPConfig,
\r
177 #if configINCLUDE_DEMO_DEBUG_STATS != 0
\r
178 /* Structure that defines the "ip-debug-stats" command line command. */
\r
179 static const CLI_Command_Definition_t xIPDebugStats =
\r
181 "ip-debug-stats", /* The command string to type. */
\r
182 "ip-debug-stats:\r\n Shows some IP stack stats useful for debug - an example only.\r\n\r\n",
\r
183 prvDisplayIPDebugStats, /* The function to run. */
\r
184 0 /* No parameters are expected. */
\r
186 #endif /* configINCLUDE_DEMO_DEBUG_STATS */
\r
188 /* Structure that defines the "run-time-stats" command line command. This
\r
189 generates a table that shows how much run time each task has */
\r
190 static const CLI_Command_Definition_t xRunTimeStats =
\r
192 "run-time-stats", /* The command string to type. */
\r
193 "run-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n\r\n",
\r
194 prvRunTimeStatsCommand, /* The function to run. */
\r
195 0 /* No parameters are expected. */
\r
198 /* Structure that defines the "task-stats" command line command. This generates
\r
199 a table that gives information on each task in the system. */
\r
200 static const CLI_Command_Definition_t xTaskStats =
\r
202 "task-stats", /* The command string to type. */
\r
203 "task-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n\r\n",
\r
204 prvTaskStatsCommand, /* The function to run. */
\r
205 0 /* No parameters are expected. */
\r
208 /* Structure that defines the "echo_3_parameters" command line command. This
\r
209 takes exactly three parameters that the command simply echos back one at a
\r
211 static const CLI_Command_Definition_t xThreeParameterEcho =
\r
213 "echo-3-parameters",
\r
214 "echo-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n\r\n",
\r
215 prvThreeParameterEchoCommand, /* The function to run. */
\r
216 3 /* Three parameters are expected, which can take any value. */
\r
219 /* Structure that defines the "echo_parameters" command line command. This
\r
220 takes a variable number of parameters that the command simply echos back one at
\r
222 static const CLI_Command_Definition_t xParameterEcho =
\r
225 "echo-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n\r\n",
\r
226 prvParameterEchoCommand, /* The function to run. */
\r
227 -1 /* The user can enter any number of commands. */
\r
230 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
232 /* Structure that defines the "ping" command line command. This takes an IP
\r
233 address or host name and (optionally) the number of bytes to ping as
\r
235 static const CLI_Command_Definition_t xPing =
\r
238 "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
239 prvPingCommand, /* The function to run. */
\r
240 -1 /* Ping can take either one or two parameter, so the number of parameters has to be determined by the ping command implementation. */
\r
243 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
245 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
246 /* Structure that defines the "trace" command line command. This takes a single
\r
247 parameter, which can be either "start" or "stop". */
\r
248 static const CLI_Command_Definition_t xStartStopTrace =
\r
251 "trace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n\r\n",
\r
252 prvStartStopTraceCommand, /* The function to run. */
\r
253 1 /* One parameter is expected. Valid values are "start" and "stop". */
\r
255 #endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
\r
257 /*-----------------------------------------------------------*/
\r
259 void vRegisterCLICommands( void )
\r
261 /* Register all the command line commands defined immediately above. */
\r
262 FreeRTOS_CLIRegisterCommand( &xTaskStats );
\r
263 FreeRTOS_CLIRegisterCommand( &xRunTimeStats );
\r
264 FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );
\r
265 FreeRTOS_CLIRegisterCommand( &xParameterEcho );
\r
266 FreeRTOS_CLIRegisterCommand( &xIPDebugStats );
\r
267 FreeRTOS_CLIRegisterCommand( &xIPConfig );
\r
269 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
271 FreeRTOS_CLIRegisterCommand( &xPing );
\r
273 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
275 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
276 FreeRTOS_CLIRegisterCommand( & xStartStopTrace );
\r
279 /*-----------------------------------------------------------*/
\r
281 static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
283 const char *const pcHeader = "Task State Priority Stack #\r\n************************************************\r\n";
\r
285 /* Remove compile time warnings about unused parameters, and check the
\r
286 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
287 write buffer length is adequate, so does not check for buffer overflows. */
\r
288 ( void ) pcCommandString;
\r
289 ( void ) xWriteBufferLen;
\r
290 configASSERT( pcWriteBuffer );
\r
292 /* Generate a table of task stats. */
\r
293 strcpy( pcWriteBuffer, pcHeader );
\r
294 vTaskList( pcWriteBuffer + strlen( pcHeader ) );
\r
296 /* There is no more data to return after this single string, so return
\r
300 /*-----------------------------------------------------------*/
\r
302 static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
304 const char * const pcHeader = "Task Abs Time % Time\r\n****************************************\r\n";
\r
306 /* Remove compile time warnings about unused parameters, and check the
\r
307 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
308 write buffer length is adequate, so does not check for buffer overflows. */
\r
309 ( void ) pcCommandString;
\r
310 ( void ) xWriteBufferLen;
\r
311 configASSERT( pcWriteBuffer );
\r
313 /* Generate a table of task stats. */
\r
314 strcpy( pcWriteBuffer, pcHeader );
\r
315 vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );
\r
317 /* There is no more data to return after this single string, so return
\r
321 /*-----------------------------------------------------------*/
\r
323 static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
325 const char *pcParameter;
\r
326 BaseType_t xParameterStringLength, xReturn;
\r
327 static BaseType_t lParameterNumber = 0;
\r
329 /* Remove compile time warnings about unused parameters, and check the
\r
330 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
331 write buffer length is adequate, so does not check for buffer overflows. */
\r
332 ( void ) pcCommandString;
\r
333 ( void ) xWriteBufferLen;
\r
334 configASSERT( pcWriteBuffer );
\r
336 if( lParameterNumber == 0 )
\r
338 /* The first time the function is called after the command has been
\r
339 entered just a header string is returned. */
\r
340 sprintf( pcWriteBuffer, "The three parameters were:\r\n" );
\r
342 /* Next time the function is called the first parameter will be echoed
\r
344 lParameterNumber = 1L;
\r
346 /* There is more data to be returned as no parameters have been echoed
\r
352 /* Obtain the parameter string. */
\r
353 pcParameter = FreeRTOS_CLIGetParameter
\r
355 pcCommandString, /* The command string itself. */
\r
356 lParameterNumber, /* Return the next parameter. */
\r
357 &xParameterStringLength /* Store the parameter string length. */
\r
360 /* Sanity check something was returned. */
\r
361 configASSERT( pcParameter );
\r
363 /* Return the parameter string. */
\r
364 memset( pcWriteBuffer, 0x00, xWriteBufferLen );
\r
365 sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
\r
366 strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
\r
367 strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
\r
369 /* If this is the last of the three parameters then there are no more
\r
370 strings to return after this one. */
\r
371 if( lParameterNumber == 3L )
\r
373 /* If this is the last of the three parameters then there are no more
\r
374 strings to return after this one. */
\r
376 lParameterNumber = 0L;
\r
380 /* There are more parameters to return after this one. */
\r
382 lParameterNumber++;
\r
388 /*-----------------------------------------------------------*/
\r
390 static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
392 const char *pcParameter;
\r
393 BaseType_t xParameterStringLength, xReturn;
\r
394 static BaseType_t lParameterNumber = 0;
\r
396 /* Remove compile time warnings about unused parameters, and check the
\r
397 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
398 write buffer length is adequate, so does not check for buffer overflows. */
\r
399 ( void ) pcCommandString;
\r
400 ( void ) xWriteBufferLen;
\r
401 configASSERT( pcWriteBuffer );
\r
403 if( lParameterNumber == 0 )
\r
405 /* The first time the function is called after the command has been
\r
406 entered just a header string is returned. */
\r
407 sprintf( pcWriteBuffer, "The parameters were:\r\n" );
\r
409 /* Next time the function is called the first parameter will be echoed
\r
411 lParameterNumber = 1L;
\r
413 /* There is more data to be returned as no parameters have been echoed
\r
419 /* Obtain the parameter string. */
\r
420 pcParameter = FreeRTOS_CLIGetParameter
\r
422 pcCommandString, /* The command string itself. */
\r
423 lParameterNumber, /* Return the next parameter. */
\r
424 &xParameterStringLength /* Store the parameter string length. */
\r
427 if( pcParameter != NULL )
\r
429 /* Return the parameter string. */
\r
430 memset( pcWriteBuffer, 0x00, xWriteBufferLen );
\r
431 sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
\r
432 strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
\r
433 strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
\r
435 /* There might be more parameters to return after this one. */
\r
437 lParameterNumber++;
\r
441 /* No more parameters were found. Make sure the write buffer does
\r
442 not contain a valid string. */
\r
443 pcWriteBuffer[ 0 ] = 0x00;
\r
445 /* No more data to return. */
\r
448 /* Start over the next time this command is executed. */
\r
449 lParameterNumber = 0;
\r
455 /*-----------------------------------------------------------*/
\r
457 #if ipconfigSUPPORT_OUTGOING_PINGS == 1
\r
459 static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
461 char * pcParameter;
\r
462 BaseType_t lParameterStringLength, xReturn;
\r
463 uint32_t ulIPAddress, ulBytesToPing;
\r
464 const uint32_t ulDefaultBytesToPing = 8UL;
\r
465 char cBuffer[ 16 ];
\r
467 /* Remove compile time warnings about unused parameters, and check the
\r
468 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
469 write buffer length is adequate, so does not check for buffer overflows. */
\r
470 ( void ) pcCommandString;
\r
471 ( void ) xWriteBufferLen;
\r
472 configASSERT( pcWriteBuffer );
\r
474 /* Start with an empty string. */
\r
475 pcWriteBuffer[ 0 ] = 0x00;
\r
477 /* Obtain the number of bytes to ping. */
\r
478 pcParameter = ( char * ) FreeRTOS_CLIGetParameter
\r
480 pcCommandString, /* The command string itself. */
\r
481 2, /* Return the second parameter. */
\r
482 &lParameterStringLength /* Store the parameter string length. */
\r
485 if( pcParameter == NULL )
\r
487 /* The number of bytes was not specified, so default it. */
\r
488 ulBytesToPing = ulDefaultBytesToPing;
\r
492 ulBytesToPing = atol( pcParameter );
\r
495 /* Obtain the IP address string. */
\r
496 pcParameter = ( char * ) FreeRTOS_CLIGetParameter
\r
498 pcCommandString, /* The command string itself. */
\r
499 1, /* Return the first parameter. */
\r
500 &lParameterStringLength /* Store the parameter string length. */
\r
503 /* Sanity check something was returned. */
\r
504 configASSERT( pcParameter );
\r
506 /* Attempt to obtain the IP address. If the first character is not a
\r
507 digit, assume the host name has been passed in. */
\r
508 if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
\r
510 ulIPAddress = FreeRTOS_inet_addr( pcParameter );
\r
514 /* Terminate the host name. */
\r
515 pcParameter[ lParameterStringLength ] = 0x00;
\r
517 /* Attempt to resolve host. */
\r
518 ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
\r
521 /* Convert IP address, which may have come from a DNS lookup, to string. */
\r
522 FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
\r
524 if( ulIPAddress != 0 )
\r
526 xReturn = FreeRTOS_SendPingRequest( ulIPAddress, ( uint16_t ) ulBytesToPing, portMAX_DELAY );
\r
533 if( xReturn == pdFALSE )
\r
535 sprintf( pcWriteBuffer, "%s", "Could not send ping request\r\n" );
\r
539 sprintf( pcWriteBuffer, "Ping sent to %s with identifier %d\r\n", cBuffer, xReturn );
\r
544 /*-----------------------------------------------------------*/
\r
546 #endif /* ipconfigSUPPORT_OUTGOING_PINGS */
\r
548 #if configINCLUDE_DEMO_DEBUG_STATS != 0
\r
550 static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
552 static BaseType_t xIndex = -1;
\r
553 extern xExampleDebugStatEntry_t xIPTraceValues[];
\r
554 BaseType_t xReturn;
\r
556 /* Remove compile time warnings about unused parameters, and check the
\r
557 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
558 write buffer length is adequate, so does not check for buffer overflows. */
\r
559 ( void ) pcCommandString;
\r
560 ( void ) xWriteBufferLen;
\r
561 configASSERT( pcWriteBuffer );
\r
565 if( xIndex < xExampleDebugStatEntries() )
\r
567 sprintf( pcWriteBuffer, "%s %d\r\n", xIPTraceValues[ xIndex ].pucDescription, ( int ) xIPTraceValues[ xIndex ].ulData );
\r
572 /* Reset the index for the next time it is called. */
\r
575 /* Ensure nothing remains in the write buffer. */
\r
576 pcWriteBuffer[ 0 ] = 0x00;
\r
582 /*-----------------------------------------------------------*/
\r
584 #endif /* configINCLUDE_DEMO_DEBUG_STATS */
\r
586 static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
588 static BaseType_t xIndex = 0;
\r
589 BaseType_t xReturn;
\r
590 uint32_t ulAddress;
\r
592 /* Remove compile time warnings about unused parameters, and check the
\r
593 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
594 write buffer length is adequate, so does not check for buffer overflows. */
\r
595 ( void ) pcCommandString;
\r
596 ( void ) xWriteBufferLen;
\r
597 configASSERT( pcWriteBuffer );
\r
602 FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
\r
603 sprintf( pcWriteBuffer, "\r\nIP address " );
\r
609 FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
\r
610 sprintf( pcWriteBuffer, "\r\nNet mask " );
\r
616 FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
\r
617 sprintf( pcWriteBuffer, "\r\nGateway address " );
\r
623 FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
\r
624 sprintf( pcWriteBuffer, "\r\nDNS server address " );
\r
631 sprintf( pcWriteBuffer, "\r\n\r\n" );
\r
637 if( ulAddress != 0 )
\r
639 FreeRTOS_inet_ntoa( ulAddress, &( pcWriteBuffer[ strlen( pcWriteBuffer ) ] ) );
\r
644 /*-----------------------------------------------------------*/
\r
646 #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
\r
648 static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
\r
650 const char *pcParameter;
\r
651 BaseType_t lParameterStringLength;
\r
653 /* Remove compile time warnings about unused parameters, and check the
\r
654 write buffer is not NULL. NOTE - for simplicity, this example assumes the
\r
655 write buffer length is adequate, so does not check for buffer overflows. */
\r
656 ( void ) pcCommandString;
\r
657 ( void ) xWriteBufferLen;
\r
658 configASSERT( pcWriteBuffer );
\r
660 /* Obtain the parameter string. */
\r
661 pcParameter = FreeRTOS_CLIGetParameter
\r
663 pcCommandString, /* The command string itself. */
\r
664 1, /* Return the first parameter. */
\r
665 &lParameterStringLength /* Store the parameter string length. */
\r
668 /* Sanity check something was returned. */
\r
669 configASSERT( pcParameter );
\r
671 /* There are only two valid parameter values. */
\r
672 if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
\r
674 /* Start or restart the trace. */
\r
679 sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" );
\r
681 else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
\r
683 /* End the trace, if one is running. */
\r
685 sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" );
\r
689 sprintf( pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" );
\r
692 /* There is no more data to return after this single string, so return
\r
697 #endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
\r