mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2025-06-23 09:27:46 +08:00
Update FreeRTOS+ demos that use FreeRTOS+CLI to remove casting to int8_t * from strings.
This commit is contained in:
@ -95,48 +95,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. */
|
||||
};
|
||||
@ -145,8 +145,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. */
|
||||
};
|
||||
@ -155,8 +155,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. */
|
||||
};
|
||||
@ -164,8 +164,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. */
|
||||
};
|
||||
@ -173,8 +173,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. */
|
||||
};
|
||||
@ -193,9 +193,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;
|
||||
@ -219,12 +219,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 );
|
||||
@ -249,7 +249,7 @@ size_t xColumns = 50U;
|
||||
}
|
||||
else
|
||||
{
|
||||
pcWriteBuffer[ xByte ] = ( int8_t ) iChar;
|
||||
pcWriteBuffer[ xByte ] = ( char ) iChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,51 +261,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;
|
||||
@ -335,12 +335,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
|
||||
@ -365,15 +365,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;
|
||||
|
||||
@ -381,12 +381,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 );
|
||||
@ -396,43 +396,43 @@ 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;
|
||||
char *pcSourceFile, *pcDestinationFile;
|
||||
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 );
|
||||
@ -445,7 +445,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||
|
||||
if( lSourceLength == 0 )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Source file does not exist" );
|
||||
sprintf( pcWriteBuffer, "Source file does not exist" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -454,7 +454,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||
|
||||
if( lDestinationLength != 0 )
|
||||
{
|
||||
sprintf( ( char * ) pcWriteBuffer, "Error: Destination file already exists" );
|
||||
sprintf( pcWriteBuffer, "Error: Destination file already exists" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,25 +464,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;
|
||||
@ -543,7 +543,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;
|
||||
@ -564,5 +564,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 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user