mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Update demos that use FreeRTOS+CLI to remove casting to int8_t * from strings.
This commit is contained in:
parent
e95b482f56
commit
42a2338f1c
9 changed files with 340 additions and 337 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
|
||||
|
@ -104,48 +104,48 @@
|
|||
/*
|
||||
* Print out information on a single file.
|
||||
*/
|
||||
static void prvCreateFileInfoString( int8_t *pcBuffer, F_FIND *pxFindStruct );
|
||||
static void prvCreateFileInfoString( char *pcBuffer, F_FIND *pxFindStruct );
|
||||
|
||||
/*
|
||||
* Copies an existing file into a newly created file.
|
||||
*/
|
||||
static portBASE_TYPE prvPerformCopy( int8_t *pcSourceFile,
|
||||
int32_t lSourceFileLength,
|
||||
int8_t *pcDestinationFile,
|
||||
int8_t *pxWriteBuffer,
|
||||
size_t xWriteBufferLen );
|
||||
static portBASE_TYPE prvPerformCopy( const char *pcSourceFile,
|
||||
int32_t lSourceFileLength,
|
||||
const char *pcDestinationFile,
|
||||
char *pxWriteBuffer,
|
||||
size_t xWriteBufferLen );
|
||||
|
||||
/*
|
||||
* Implements the DIR command.
|
||||
*/
|
||||
static portBASE_TYPE prvDIRCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvDIRCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the CD command.
|
||||
*/
|
||||
static portBASE_TYPE prvCDCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvCDCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the DEL command.
|
||||
*/
|
||||
static portBASE_TYPE prvDELCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvDELCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the TYPE command.
|
||||
*/
|
||||
static portBASE_TYPE prvTYPECommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvTYPECommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the COPY command.
|
||||
*/
|
||||
static portBASE_TYPE prvCOPYCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvCOPYCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/* Structure that defines the DIR command line command, which lists all the
|
||||
files in the current directory. */
|
||||
static const CLI_Command_Definition_t xDIR =
|
||||
{
|
||||
( const int8_t * const ) "dir", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ndir:\r\n Lists the files in the current directory\r\n",
|
||||
"dir", /* The command string to type. */
|
||||
"\r\ndir:\r\n Lists the files in the current directory\r\n",
|
||||
prvDIRCommand, /* The function to run. */
|
||||
0 /* No parameters are expected. */
|
||||
};
|
||||
|
@ -154,8 +154,8 @@ static const CLI_Command_Definition_t xDIR =
|
|||
working directory. */
|
||||
static const CLI_Command_Definition_t xCD =
|
||||
{
|
||||
( const int8_t * const ) "cd", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ncd <dir name>:\r\n Changes the working directory\r\n",
|
||||
"cd", /* The command string to type. */
|
||||
"\r\ncd <dir name>:\r\n Changes the working directory\r\n",
|
||||
prvCDCommand, /* The function to run. */
|
||||
1 /* One parameter is expected. */
|
||||
};
|
||||
|
@ -164,8 +164,8 @@ static const CLI_Command_Definition_t xCD =
|
|||
contents of a file to the console. */
|
||||
static const CLI_Command_Definition_t xTYPE =
|
||||
{
|
||||
( const int8_t * const ) "type", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ntype <filename>:\r\n Prints file contents to the terminal\r\n",
|
||||
"type", /* The command string to type. */
|
||||
"\r\ntype <filename>:\r\n Prints file contents to the terminal\r\n",
|
||||
prvTYPECommand, /* The function to run. */
|
||||
1 /* One parameter is expected. */
|
||||
};
|
||||
|
@ -173,8 +173,8 @@ static const CLI_Command_Definition_t xTYPE =
|
|||
/* Structure that defines the DEL command line command, which deletes a file. */
|
||||
static const CLI_Command_Definition_t xDEL =
|
||||
{
|
||||
( const int8_t * const ) "del", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ndel <filename>:\r\n deletes a file or directory\r\n",
|
||||
"del", /* The command string to type. */
|
||||
"\r\ndel <filename>:\r\n deletes a file or directory\r\n",
|
||||
prvDELCommand, /* The function to run. */
|
||||
1 /* One parameter is expected. */
|
||||
};
|
||||
|
@ -182,8 +182,8 @@ static const CLI_Command_Definition_t xDEL =
|
|||
/* Structure that defines the COPY command line command, which deletes a file. */
|
||||
static const CLI_Command_Definition_t xCOPY =
|
||||
{
|
||||
( const int8_t * const ) "copy", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ncopy <source file> <dest file>:\r\n Copies <source file> to <dest file>\r\n",
|
||||
"copy", /* The command string to type. */
|
||||
"\r\ncopy <source file> <dest file>:\r\n Copies <source file> to <dest file>\r\n",
|
||||
prvCOPYCommand, /* The function to run. */
|
||||
2 /* Two parameters are expected. */
|
||||
};
|
||||
|
@ -201,9 +201,9 @@ void vRegisterFileSystemCLICommands( void )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvTYPECommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvTYPECommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
const char *pcParameter;
|
||||
portBASE_TYPE xParameterStringLength, xReturn = pdTRUE;
|
||||
static F_FILE *pxFile = NULL;
|
||||
int iChar;
|
||||
|
@ -227,12 +227,12 @@ size_t xColumns = 50U;
|
|||
if( pxFile == NULL )
|
||||
{
|
||||
/* The file has not been opened yet. Find the file name. */
|
||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
pcParameter = FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
|
||||
/* Sanity check something was returned. */
|
||||
configASSERT( pcParameter );
|
||||
|
@ -257,7 +257,7 @@ size_t xColumns = 50U;
|
|||
}
|
||||
else
|
||||
{
|
||||
pcWriteBuffer[ xByte ] = ( int8_t ) iChar;
|
||||
pcWriteBuffer[ xByte ] = ( char ) iChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,51 +269,51 @@ size_t xColumns = 50U;
|
|||
xReturn = pdFALSE;
|
||||
}
|
||||
|
||||
strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );
|
||||
strcat( pcWriteBuffer, cliNEW_LINE );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvCDCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvCDCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
const char *pcParameter;
|
||||
portBASE_TYPE xParameterStringLength;
|
||||
unsigned char ucReturned;
|
||||
size_t xStringLength;
|
||||
|
||||
/* Obtain the parameter string. */
|
||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
pcParameter = FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
|
||||
/* Sanity check something was returned. */
|
||||
configASSERT( pcParameter );
|
||||
|
||||
/* Attempt to move to the requested directory. */
|
||||
ucReturned = f_chdir( ( char * ) pcParameter );
|
||||
ucReturned = f_chdir( pcParameter );
|
||||
|
||||
if( ucReturned == F_NO_ERROR )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "In: " );
|
||||
xStringLength = strlen( ( const char * ) pcWriteBuffer );
|
||||
f_getcwd( ( char * ) &( pcWriteBuffer[ xStringLength ] ), ( unsigned char ) ( xWriteBufferLen - xStringLength ) );
|
||||
sprintf( pcWriteBuffer, "In: " );
|
||||
xStringLength = strlen( pcWriteBuffer );
|
||||
f_getcwd( &( pcWriteBuffer[ xStringLength ] ), ( unsigned char ) ( xWriteBufferLen - xStringLength ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Error" );
|
||||
sprintf( pcWriteBuffer, "Error" );
|
||||
}
|
||||
|
||||
strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );
|
||||
strcat( pcWriteBuffer, cliNEW_LINE );
|
||||
|
||||
return pdFALSE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvDIRCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvDIRCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
static F_FIND *pxFindStruct = NULL;
|
||||
unsigned char ucReturned;
|
||||
|
@ -343,12 +343,12 @@ portBASE_TYPE xReturn = pdFALSE;
|
|||
}
|
||||
else
|
||||
{
|
||||
snprintf( ( char * ) pcWriteBuffer, xWriteBufferLen, "Error: f_findfirst() failed." );
|
||||
snprintf( pcWriteBuffer, xWriteBufferLen, "Error: f_findfirst() failed." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( ( char * ) pcWriteBuffer, xWriteBufferLen, "Failed to allocate RAM (using heap_4.c will prevent fragmentation)." );
|
||||
snprintf( pcWriteBuffer, xWriteBufferLen, "Failed to allocate RAM (using heap_4.c will prevent fragmentation)." );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -373,15 +373,15 @@ portBASE_TYPE xReturn = pdFALSE;
|
|||
}
|
||||
}
|
||||
|
||||
strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );
|
||||
strcat( pcWriteBuffer, cliNEW_LINE );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvDELCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvDELCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
const char *pcParameter;
|
||||
portBASE_TYPE xParameterStringLength;
|
||||
unsigned char ucReturned;
|
||||
|
||||
|
@ -389,12 +389,12 @@ unsigned char ucReturned;
|
|||
( void ) xWriteBufferLen;
|
||||
|
||||
/* Obtain the parameter string. */
|
||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
pcParameter = FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
|
||||
/* Sanity check something was returned. */
|
||||
configASSERT( pcParameter );
|
||||
|
@ -404,43 +404,44 @@ unsigned char ucReturned;
|
|||
|
||||
if( ucReturned == F_NO_ERROR )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "%s was deleted", pcParameter );
|
||||
sprintf( pcWriteBuffer, "%s was deleted", pcParameter );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Error" );
|
||||
sprintf( pcWriteBuffer, "Error" );
|
||||
}
|
||||
|
||||
strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );
|
||||
strcat( pcWriteBuffer, cliNEW_LINE );
|
||||
|
||||
return pdFALSE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvCOPYCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvCOPYCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcSourceFile, *pcDestinationFile;
|
||||
const char *pcDestinationFile;
|
||||
char *pcSourceFile;
|
||||
portBASE_TYPE xParameterStringLength;
|
||||
long lSourceLength, lDestinationLength = 0;
|
||||
|
||||
/* Obtain the name of the destination file. */
|
||||
pcDestinationFile = ( int8_t * ) FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
2, /* Return the second parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
pcDestinationFile = FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
2, /* Return the second parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
|
||||
/* Sanity check something was returned. */
|
||||
configASSERT( pcDestinationFile );
|
||||
|
||||
/* Obtain the name of the source file. */
|
||||
pcSourceFile = ( int8_t * ) FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
pcSourceFile = FreeRTOS_CLIGetParameter
|
||||
(
|
||||
pcCommandString, /* The command string itself. */
|
||||
1, /* Return the first parameter. */
|
||||
&xParameterStringLength /* Store the parameter string length. */
|
||||
);
|
||||
|
||||
/* Sanity check something was returned. */
|
||||
configASSERT( pcSourceFile );
|
||||
|
@ -449,20 +450,20 @@ long lSourceLength, lDestinationLength = 0;
|
|||
pcSourceFile[ xParameterStringLength ] = 0x00;
|
||||
|
||||
/* See if the source file exists, obtain its length if it does. */
|
||||
lSourceLength = f_filelength( ( const char * ) pcSourceFile );
|
||||
lSourceLength = f_filelength( pcSourceFile );
|
||||
|
||||
if( lSourceLength == 0 )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Source file does not exist" );
|
||||
sprintf( pcWriteBuffer, "Source file does not exist" );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* See if the destination file exists. */
|
||||
lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );
|
||||
lDestinationLength = f_filelength( pcDestinationFile );
|
||||
|
||||
if( lDestinationLength != 0 )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Error: Destination file already exists" );
|
||||
sprintf( pcWriteBuffer, "Error: Destination file already exists" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,25 +473,25 @@ long lSourceLength, lDestinationLength = 0;
|
|||
{
|
||||
if( prvPerformCopy( pcSourceFile, lSourceLength, pcDestinationFile, pcWriteBuffer, xWriteBufferLen ) == pdPASS )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Copy made" );
|
||||
sprintf( pcWriteBuffer, "Copy made" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Error during copy" );
|
||||
sprintf( pcWriteBuffer, "Error during copy" );
|
||||
}
|
||||
}
|
||||
|
||||
strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );
|
||||
strcat( pcWriteBuffer, cliNEW_LINE );
|
||||
|
||||
return pdFALSE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvPerformCopy( int8_t *pcSourceFile,
|
||||
int32_t lSourceFileLength,
|
||||
int8_t *pcDestinationFile,
|
||||
int8_t *pxWriteBuffer,
|
||||
size_t xWriteBufferLen )
|
||||
static portBASE_TYPE prvPerformCopy( const char *pcSourceFile,
|
||||
int32_t lSourceFileLength,
|
||||
const char *pcDestinationFile,
|
||||
char *pxWriteBuffer,
|
||||
size_t xWriteBufferLen )
|
||||
{
|
||||
int32_t lBytesRead = 0, lBytesToRead, lBytesRemaining;
|
||||
F_FILE *pxFile;
|
||||
|
@ -551,7 +552,7 @@ portBASE_TYPE xReturn = pdPASS;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCreateFileInfoString( int8_t *pcBuffer, F_FIND *pxFindStruct )
|
||||
static void prvCreateFileInfoString( char *pcBuffer, F_FIND *pxFindStruct )
|
||||
{
|
||||
const char *pcWritableFile = "writable file", *pcReadOnlyFile = "read only file", *pcDirectory = "directory";
|
||||
const char * pcAttrib;
|
||||
|
@ -572,5 +573,5 @@ const char * pcAttrib;
|
|||
|
||||
/* Create a string that includes the file name, the file size and the
|
||||
attributes string. */
|
||||
sprintf( ( char * ) pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, ( int ) pxFindStruct->filesize );
|
||||
sprintf( pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, ( int ) pxFindStruct->filesize );
|
||||
}
|
||||
|
|
|
@ -101,36 +101,36 @@
|
|||
/*
|
||||
* Implements the run-time-stats command.
|
||||
*/
|
||||
static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the task-stats command.
|
||||
*/
|
||||
static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the echo-three-parameters command.
|
||||
*/
|
||||
static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
|
||||
/*
|
||||
* Implements the echo-parameters command.
|
||||
*/
|
||||
static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvParameterEchoCommand( 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( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
||||
static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
||||
#endif
|
||||
|
||||
/* Structure that defines the "run-time-stats" command line command. This
|
||||
generates a table that shows how much run time each task has */
|
||||
static const CLI_Command_Definition_t xRunTimeStats =
|
||||
{
|
||||
( const int8_t * const ) "run-time-stats", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",
|
||||
"run-time-stats", /* The command string to type. */
|
||||
"\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",
|
||||
prvRunTimeStatsCommand, /* The function to run. */
|
||||
0 /* No parameters are expected. */
|
||||
};
|
||||
|
@ -139,8 +139,8 @@ static const CLI_Command_Definition_t xRunTimeStats =
|
|||
a table that gives information on each task in the system. */
|
||||
static const CLI_Command_Definition_t xTaskStats =
|
||||
{
|
||||
( const int8_t * const ) "task-stats", /* The command string to type. */
|
||||
( const int8_t * const ) "\r\ntask-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n",
|
||||
"task-stats", /* The command string to type. */
|
||||
"\r\ntask-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n",
|
||||
prvTaskStatsCommand, /* The function to run. */
|
||||
0 /* No parameters are expected. */
|
||||
};
|
||||
|
@ -150,8 +150,8 @@ takes exactly three parameters that the command simply echos back one at a
|
|||
time. */
|
||||
static const CLI_Command_Definition_t xThreeParameterEcho =
|
||||
{
|
||||
( const int8_t * const ) "echo-3-parameters",
|
||||
( const int8_t * const ) "\r\necho-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n",
|
||||
"echo-3-parameters",
|
||||
"\r\necho-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n",
|
||||
prvThreeParameterEchoCommand, /* The function to run. */
|
||||
3 /* Three parameters are expected, which can take any value. */
|
||||
};
|
||||
|
@ -161,8 +161,8 @@ takes a variable number of parameters that the command simply echos back one at
|
|||
a time. */
|
||||
static const CLI_Command_Definition_t xParameterEcho =
|
||||
{
|
||||
( const int8_t * const ) "echo-parameters",
|
||||
( const int8_t * const ) "\r\necho-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n",
|
||||
"echo-parameters",
|
||||
"\r\necho-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n",
|
||||
prvParameterEchoCommand, /* The function to run. */
|
||||
-1 /* The user can enter any number of commands. */
|
||||
};
|
||||
|
@ -172,8 +172,8 @@ static const CLI_Command_Definition_t xParameterEcho =
|
|||
parameter, which can be either "start" or "stop". */
|
||||
static const CLI_Command_Definition_t xStartStopTrace =
|
||||
{
|
||||
( const int8_t * const ) "trace",
|
||||
( const int8_t * const ) "\r\ntrace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n",
|
||||
"trace",
|
||||
"\r\ntrace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n",
|
||||
prvStartStopTraceCommand, /* The function to run. */
|
||||
1 /* One parameter is expected. Valid values are "start" and "stop". */
|
||||
};
|
||||
|
@ -197,7 +197,7 @@ void vRegisterSampleCLICommands( void )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
const char *const pcHeader = "Task State Priority Stack #\r\n************************************************\r\n";
|
||||
|
||||
|
@ -218,7 +218,7 @@ const char *const pcHeader = "Task State Priority Stack #\r\n********
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
const char * const pcHeader = "Task Abs Time % Time\r\n****************************************\r\n";
|
||||
|
||||
|
@ -239,7 +239,7 @@ const char * const pcHeader = "Task Abs Time % Time\r\n*********
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
portBASE_TYPE xParameterStringLength, xReturn;
|
||||
|
@ -306,7 +306,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
portBASE_TYPE xParameterStringLength, xReturn;
|
||||
|
@ -375,7 +375,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
|
||||
#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
|
||||
|
||||
static portBASE_TYPE prvStartStopTraceCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
||||
static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||
{
|
||||
int8_t *pcParameter;
|
||||
portBASE_TYPE lParameterStringLength;
|
||||
|
|
|
@ -101,7 +101,7 @@ static void prvUARTCommandConsoleTask( void *pvParameters );
|
|||
* Ensure a previous interrupt driven Tx has completed before sending the next
|
||||
* data block to the UART.
|
||||
*/
|
||||
static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength );
|
||||
static void prvSendBuffer( const char * pcBuffer, size_t xBufferLength );
|
||||
|
||||
/*
|
||||
* A UART is used for printf() output and CLI input and output. Configure the
|
||||
|
@ -113,9 +113,9 @@ static void prvUARTRxNotificationHandler( mss_uart_instance_t * this_uart );
|
|||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Const messages output by the command console. */
|
||||
static const uint8_t * const pcWelcomeMessage = ( uint8_t * ) "\r\n\r\nFreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
||||
static const uint8_t * const pcEndOfOutputMessage = ( uint8_t * ) "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
||||
static const uint8_t * const pcNewLine = ( uint8_t * ) "\r\n";
|
||||
static const char * const pcWelcomeMessage = "\r\n\r\nFreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
||||
static const char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
||||
static const char * const pcNewLine = "\r\n";
|
||||
|
||||
/* The UART used by the CLI. */
|
||||
#if configBUILD_FOR_DEVELOPMENT_KIT == 1
|
||||
|
@ -152,8 +152,9 @@ void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPr
|
|||
|
||||
static void prvUARTCommandConsoleTask( void *pvParameters )
|
||||
{
|
||||
int8_t cRxedChar, cInputIndex = 0, *pcOutputString;
|
||||
static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
||||
char cRxedChar, *pcOutputString;
|
||||
unsigned char cInputIndex = 0;
|
||||
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
||||
portBASE_TYPE xReturned;
|
||||
|
||||
( void ) pvParameters;
|
||||
|
@ -172,13 +173,13 @@ portBASE_TYPE xReturned;
|
|||
if( xQueueReceive( xRxedChars, &cRxedChar, portMAX_DELAY ) == pdPASS )
|
||||
{
|
||||
/* Echo the character back. */
|
||||
prvSendBuffer( ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) );
|
||||
prvSendBuffer( &cRxedChar, sizeof( cRxedChar ) );
|
||||
|
||||
/* Was it the end of the line? */
|
||||
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
||||
{
|
||||
/* Just to space the output from the input. */
|
||||
prvSendBuffer( ( uint8_t * ) pcNewLine, strlen( ( char * ) pcNewLine ) );
|
||||
prvSendBuffer( pcNewLine, strlen( ( char * ) pcNewLine ) );
|
||||
|
||||
/* See if the command is empty, indicating that the last command is
|
||||
to be executed again. */
|
||||
|
@ -198,7 +199,7 @@ portBASE_TYPE xReturned;
|
|||
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
||||
|
||||
/* Write the generated string to the UART. */
|
||||
prvSendBuffer( ( uint8_t * ) pcOutputString, strlen( ( char * ) pcOutputString ) );
|
||||
prvSendBuffer( pcOutputString, strlen( pcOutputString ) );
|
||||
|
||||
} while( xReturned != pdFALSE );
|
||||
|
||||
|
@ -210,7 +211,7 @@ portBASE_TYPE xReturned;
|
|||
cInputIndex = 0;
|
||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||
|
||||
prvSendBuffer( ( uint8_t * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
|
||||
prvSendBuffer( pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -248,13 +249,13 @@ portBASE_TYPE xReturned;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength )
|
||||
static void prvSendBuffer( const char * pcBuffer, size_t xBufferLength )
|
||||
{
|
||||
const portTickType xVeryShortDelay = 2UL;
|
||||
|
||||
if( xBufferLength > 0 )
|
||||
{
|
||||
MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, pcBuffer, xBufferLength );
|
||||
MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, ( uint8_t * ) pcBuffer, xBufferLength );
|
||||
|
||||
/* Ensure any previous transmissions have completed. The default UART
|
||||
interrupt does not provide an event based method of signally the end of a Tx
|
||||
|
@ -292,13 +293,13 @@ static void prvConfigureUART( void )
|
|||
|
||||
static void prvUARTRxNotificationHandler( mss_uart_instance_t * pxUART )
|
||||
{
|
||||
uint8_t cRxed;
|
||||
char cRxed;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken;
|
||||
|
||||
/* The command console receives data very slowly (at the speed of somebody
|
||||
typing), therefore it is ok to just handle one character at a time and use
|
||||
a queue to send the characters to the task. */
|
||||
if( MSS_UART_get_rx( pxUART, &cRxed, sizeof( cRxed ) ) == sizeof( cRxed ) )
|
||||
if( MSS_UART_get_rx( pxUART, ( uint8_t * ) &cRxed, sizeof( cRxed ) ) == sizeof( cRxed ) )
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
xQueueSendFromISR( xRxedChars, &cRxed, &xHigherPriorityTaskWoken );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue