From df612df9443852c70c7825c62e6f454250c75ded Mon Sep 17 00:00:00 2001 From: rtel Date: Mon, 30 Dec 2013 14:06:57 +0000 Subject: [PATCH] Update demos that use FreeRTOS+CLI to remove casting to int8_t * from strings. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2153 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../Full-Demo/File-releated-CLI-commands.c | 154 +++++++-------- .../Source/Full-Demo/Sample-CLI-commands.c | 92 ++++----- .../Source/Full-Demo/UARTCommandConsole.c | 20 +- .../Source/Full-Demo/serial.c | 10 +- .../RTOSDemo/src/Sample-CLI-commands.c | 112 +++++------ .../RTOSDemo/src/UARTCommandConsole.c | 41 ++-- .../Full-Demo/File-releated-CLI-commands.c | 179 +++++++++--------- .../RTOSDemo/Full-Demo/Sample-CLI-commands.c | 40 ++-- .../RTOSDemo/Full-Demo/UARTCommandConsole.c | 29 +-- 9 files changed, 340 insertions(+), 337 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/File-releated-CLI-commands.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/File-releated-CLI-commands.c index 66215974b..a902846c3 100644 --- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/File-releated-CLI-commands.c +++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/File-releated-CLI-commands.c @@ -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,41 +104,41 @@ /* * 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( char *pcSourceFile, + int32_t lSourceFileLength, + 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 ); /* * Registers the CLI commands that are specific to the files system with the @@ -207,9 +207,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; @@ -233,12 +233,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 ); @@ -263,7 +263,7 @@ size_t xColumns = 50U; } else { - pcWriteBuffer[ xByte ] = ( int8_t ) iChar; + pcWriteBuffer[ xByte ] = ( char ) iChar; } } } @@ -275,51 +275,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; @@ -349,12 +349,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 @@ -379,15 +379,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; @@ -395,12 +395,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 ); @@ -410,43 +410,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 = ( char * ) 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 = ( char * ) 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 ); @@ -459,7 +459,7 @@ long lSourceLength, lDestinationLength = 0; if( lSourceLength == 0 ) { - sprintf( ( char * ) pcWriteBuffer, "Source file does not exist" ); + sprintf( pcWriteBuffer, "Source file does not exist" ); } else { @@ -468,7 +468,7 @@ long lSourceLength, lDestinationLength = 0; if( lDestinationLength != 0 ) { - sprintf( ( char * ) pcWriteBuffer, "Error: Destination file already exists" ); + sprintf( pcWriteBuffer, "Error: Destination file already exists" ); } } @@ -478,25 +478,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( char *pcSourceFile, + int32_t lSourceFileLength, + char *pcDestinationFile, + char *pxWriteBuffer, + size_t xWriteBufferLen ) { int32_t lBytesRead = 0, lBytesToRead, lBytesRemaining; F_FILE *pxFile; @@ -557,7 +557,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; @@ -578,5 +578,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, pxFindStruct->filesize ); + sprintf( pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, pxFindStruct->filesize ); } diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/Sample-CLI-commands.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/Sample-CLI-commands.c index 561f886e4..32d56895e 100644 --- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/Sample-CLI-commands.c +++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/Sample-CLI-commands.c @@ -101,22 +101,22 @@ /* * 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 ); /* * Registers the CLI commands defined within this file with the FreeRTOS+CLI @@ -128,7 +128,7 @@ void vRegisterSampleCLICommands( void ); * 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 @@ -203,7 +203,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"; @@ -215,8 +215,8 @@ const char *const pcHeader = "Task State Priority Stack #\r\n******** configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ - strcpy( ( char * ) pcWriteBuffer, pcHeader ); - vTaskList( ( char * ) pcWriteBuffer + strlen( pcHeader ) ); + strcpy( pcWriteBuffer, pcHeader ); + vTaskList( pcWriteBuffer + strlen( pcHeader ) ); /* There is no more data to return after this single string, so return pdFALSE. */ @@ -224,7 +224,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"; @@ -236,8 +236,8 @@ const char * const pcHeader = "Task Abs Time % Time\r\n********* configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ - strcpy( ( char * ) pcWriteBuffer, pcHeader ); - vTaskGetRunTimeStats( ( ( char * ) pcWriteBuffer ) + strlen( pcHeader ) ); + strcpy( pcWriteBuffer, pcHeader ); + vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) ); /* There is no more data to return after this single string, so return pdFALSE. */ @@ -245,9 +245,9 @@ 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; +const char *pcParameter; portBASE_TYPE xParameterStringLength, xReturn; static portBASE_TYPE lParameterNumber = 0; @@ -262,7 +262,7 @@ static portBASE_TYPE lParameterNumber = 0; { /* The first time the function is called after the command has been entered just a header string is returned. */ - sprintf( ( char * ) pcWriteBuffer, "The three parameters were:\r\n" ); + sprintf( pcWriteBuffer, "The three parameters were:\r\n" ); /* Next time the function is called the first parameter will be echoed back. */ @@ -275,21 +275,21 @@ static portBASE_TYPE lParameterNumber = 0; else { /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - lParameterNumber, /* Return the next parameter. */ - &xParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + lParameterNumber, /* Return the next parameter. */ + &xParameterStringLength /* Store the parameter string length. */ + ); /* Sanity check something was returned. */ configASSERT( pcParameter ); /* Return the parameter string. */ memset( pcWriteBuffer, 0x00, xWriteBufferLen ); - sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); - strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength ); - strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); + sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); + strncat( pcWriteBuffer, pcParameter, xParameterStringLength ); + strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); /* If this is the last of the three parameters then there are no more strings to return after this one. */ @@ -312,9 +312,9 @@ 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; +const char *pcParameter; portBASE_TYPE xParameterStringLength, xReturn; static portBASE_TYPE lParameterNumber = 0; @@ -329,7 +329,7 @@ static portBASE_TYPE lParameterNumber = 0; { /* The first time the function is called after the command has been entered just a header string is returned. */ - sprintf( ( char * ) pcWriteBuffer, "The parameters were:\r\n" ); + sprintf( pcWriteBuffer, "The parameters were:\r\n" ); /* Next time the function is called the first parameter will be echoed back. */ @@ -342,20 +342,20 @@ static portBASE_TYPE lParameterNumber = 0; else { /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - lParameterNumber, /* Return the next parameter. */ - &xParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + lParameterNumber, /* Return the next parameter. */ + &xParameterStringLength /* Store the parameter string length. */ + ); if( pcParameter != NULL ) { /* Return the parameter string. */ memset( pcWriteBuffer, 0x00, xWriteBufferLen ); - sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); - strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength ); - strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); + sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); + strncat( pcWriteBuffer, pcParameter, xParameterStringLength ); + strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); /* There might be more parameters to return after this one. */ xReturn = pdTRUE; @@ -381,9 +381,9 @@ 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; + char *pcParameter; portBASE_TYPE lParameterStringLength; /* Remove compile time warnings about unused parameters, and check the @@ -394,12 +394,12 @@ static portBASE_TYPE lParameterNumber = 0; configASSERT( pcWriteBuffer ); /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - 1, /* Return the first parameter. */ - &lParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + 1, /* Return the first parameter. */ + &lParameterStringLength /* Store the parameter string length. */ + ); /* Sanity check something was returned. */ configASSERT( pcParameter ); @@ -412,17 +412,17 @@ static portBASE_TYPE lParameterNumber = 0; vTraceClear(); vTraceStart(); - sprintf( ( char * ) pcWriteBuffer, "Trace recording (re)started.\r\n" ); + sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" ); } else if( strncmp( ( const char * ) pcParameter, "stop", strlen( "stop" ) ) == 0 ) { /* End the trace, if one is running. */ vTraceStop(); - sprintf( ( char * ) pcWriteBuffer, "Stopping trace recording.\r\n" ); + sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" ); } else { - sprintf( ( char * ) pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" ); + sprintf( pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" ); } /* There is no more data to return after this single string, so return diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/UARTCommandConsole.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/UARTCommandConsole.c index ac17672bd..dff842fdb 100644 --- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/UARTCommandConsole.c +++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/UARTCommandConsole.c @@ -84,9 +84,9 @@ static void prvUARTCommandConsoleTask( void *pvParameters ); /*-----------------------------------------------------------*/ /* Const messages output by the command console. */ -static const signed char * const pcWelcomeMessage = "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>"; -static const signed char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>"; -static const signed char * const pcNewLine = "\r\n"; +static const char * const pcWelcomeMessage = "FreeRTOS 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"; /*-----------------------------------------------------------*/ @@ -104,8 +104,8 @@ 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, cInputIndex = 0, *pcOutputString; +static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ]; portBASE_TYPE xReturned; ( void ) pvParameters; @@ -116,12 +116,12 @@ portBASE_TYPE xReturned; pcOutputString = FreeRTOS_CLIGetOutputBuffer(); /* Send the welcome message. */ - vSerialPutString( NULL, pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) ); + vSerialPutString( NULL, ( const signed char * ) pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) ); for( ;; ) { /* Only interested in reading one character at a time. */ - while( xSerialGetChar( NULL, &cRxedChar, portMAX_DELAY ) == pdFALSE ); + while( xSerialGetChar( NULL, ( signed char * ) &cRxedChar, portMAX_DELAY ) == pdFALSE ); /* Echo the character back. */ xSerialPutChar( NULL, cRxedChar, portMAX_DELAY ); @@ -130,7 +130,7 @@ portBASE_TYPE xReturned; if( cRxedChar == '\n' || cRxedChar == '\r' ) { /* Just to space the output from the input. */ - vSerialPutString( NULL, pcNewLine, strlen( ( char * ) pcNewLine ) ); + vSerialPutString( NULL, ( const signed char * ) pcNewLine, strlen( ( char * ) pcNewLine ) ); /* See if the command is empty, indicating that the last command is to be executed again. */ @@ -150,7 +150,7 @@ portBASE_TYPE xReturned; xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE ); /* Write the generated string to the UART. */ - vSerialPutString( NULL, pcOutputString, strlen( ( char * ) pcOutputString ) ); + vSerialPutString( NULL, ( const signed char * ) pcOutputString, strlen( ( char * ) pcOutputString ) ); } while( xReturned != pdFALSE ); @@ -161,7 +161,7 @@ portBASE_TYPE xReturned; strcpy( ( char * ) cLastInputString, ( char * ) cInputString ); cInputIndex = 0; memset( cInputString, 0x00, cmdMAX_INPUT_SIZE ); - vSerialPutString( NULL, pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) ); + vSerialPutString( NULL, ( const signed char * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) ); } else { diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/serial.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/serial.c index b9257c814..9e39bb3de 100644 --- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/serial.c +++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/serial.c @@ -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 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -122,8 +122,8 @@ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned port /* Create the queues used to hold Rx/Tx characters. Note the comments at the top of this file regarding the use of queues in this manner. */ - xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); - xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); + xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( char ) ); + xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( char ) ); /* If the queues were created correctly then setup the serial port hardware. */ @@ -177,14 +177,14 @@ signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedC void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength ) { -signed char *pxNext; +char *pxNext; /* A couple of parameters that this port does not use. */ ( void ) usStringLength; ( void ) pxPort; /* Send each character in the string, one at a time. */ - pxNext = ( signed char * ) pcString; + pxNext = ( char * ) pcString; while( *pxNext ) { xSerialPutChar( pxPort, *pxNext, portMAX_DELAY ); diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c index f70a208c4..bce7c40dd 100644 --- a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c +++ b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c @@ -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 :\r\n Expects three parameters, echos each in turn\r\n", + "echo-3-parameters", + "\r\necho-3-parameters :\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"; @@ -209,8 +209,8 @@ const char *const pcHeader = "Task State Priority Stack #\r\n******** configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ - strcpy( ( char * ) pcWriteBuffer, pcHeader ); - vTaskList( ( char * ) pcWriteBuffer + strlen( ( char * ) pcHeader ) ); + strcpy( pcWriteBuffer, pcHeader ); + vTaskList( pcWriteBuffer + strlen( pcHeader ) ); /* There is no more data to return after this single string, so return pdFALSE. */ @@ -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"; @@ -230,8 +230,8 @@ const char * const pcHeader = "Task Abs Time % Time\r\n********* configASSERT( pcWriteBuffer ); /* Generate a table of task stats. */ - strcpy( ( char * ) pcWriteBuffer, ( char * ) pcHeader ); - vTaskGetRunTimeStats( ( char * ) pcWriteBuffer + strlen( ( char * ) pcHeader ) ); + strcpy( pcWriteBuffer, pcHeader ); + vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) ); /* There is no more data to return after this single string, so return pdFALSE. */ @@ -239,9 +239,9 @@ 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; +const char *pcParameter; portBASE_TYPE xParameterStringLength, xReturn; static portBASE_TYPE lParameterNumber = 0; @@ -256,7 +256,7 @@ static portBASE_TYPE lParameterNumber = 0; { /* The first time the function is called after the command has been entered just a header string is returned. */ - sprintf( ( char * ) pcWriteBuffer, "The three parameters were:\r\n" ); + sprintf( pcWriteBuffer, "The three parameters were:\r\n" ); /* Next time the function is called the first parameter will be echoed back. */ @@ -269,21 +269,21 @@ static portBASE_TYPE lParameterNumber = 0; else { /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - lParameterNumber, /* Return the next parameter. */ - &xParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + lParameterNumber, /* Return the next parameter. */ + &xParameterStringLength /* Store the parameter string length. */ + ); /* Sanity check something was returned. */ configASSERT( pcParameter ); /* Return the parameter string. */ memset( pcWriteBuffer, 0x00, xWriteBufferLen ); - sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); - strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength ); - strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); + sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); + strncat( pcWriteBuffer, pcParameter, xParameterStringLength ); + strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); /* If this is the last of the three parameters then there are no more strings to return after this one. */ @@ -306,9 +306,9 @@ 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; +const char *pcParameter; portBASE_TYPE xParameterStringLength, xReturn; static portBASE_TYPE lParameterNumber = 0; @@ -323,7 +323,7 @@ static portBASE_TYPE lParameterNumber = 0; { /* The first time the function is called after the command has been entered just a header string is returned. */ - sprintf( ( char * ) pcWriteBuffer, "The parameters were:\r\n" ); + sprintf( pcWriteBuffer, "The parameters were:\r\n" ); /* Next time the function is called the first parameter will be echoed back. */ @@ -336,20 +336,20 @@ static portBASE_TYPE lParameterNumber = 0; else { /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - lParameterNumber, /* Return the next parameter. */ - &xParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + lParameterNumber, /* Return the next parameter. */ + &xParameterStringLength /* Store the parameter string length. */ + ); if( pcParameter != NULL ) { /* Return the parameter string. */ memset( pcWriteBuffer, 0x00, xWriteBufferLen ); - sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); - strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength ); - strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); + sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber ); + strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength ); + strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) ); /* There might be more parameters to return after this one. */ xReturn = pdTRUE; @@ -375,9 +375,9 @@ 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; + const char *pcParameter; portBASE_TYPE lParameterStringLength; /* Remove compile time warnings about unused parameters, and check the @@ -388,12 +388,12 @@ static portBASE_TYPE lParameterNumber = 0; configASSERT( pcWriteBuffer ); /* Obtain the parameter string. */ - pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter - ( - pcCommandString, /* The command string itself. */ - 1, /* Return the first parameter. */ - &lParameterStringLength /* Store the parameter string length. */ - ); + pcParameter = FreeRTOS_CLIGetParameter + ( + pcCommandString, /* The command string itself. */ + 1, /* Return the first parameter. */ + &lParameterStringLength /* Store the parameter string length. */ + ); /* Sanity check something was returned. */ configASSERT( pcParameter ); @@ -406,17 +406,17 @@ static portBASE_TYPE lParameterNumber = 0; vTraceClear(); vTraceStart(); - sprintf( ( char * ) pcWriteBuffer, "Trace recording (re)started.\r\n" ); + sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" ); } else if( strncmp( ( const char * ) pcParameter, "stop", strlen( "stop" ) ) == 0 ) { /* End the trace, if one is running. */ vTraceStop(); - sprintf( ( char * ) pcWriteBuffer, "Stopping trace recording.\r\n" ); + sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" ); } else { - sprintf( ( char * ) pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" ); + sprintf( pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" ); } /* There is no more data to return after this single string, so return diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c index e561b9c4b..b488d016e 100644 --- a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c +++ b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c @@ -105,7 +105,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( struct usart_module *pxCDCUsart, uint8_t * pcBuffer, size_t xBufferLength ); +static void prvSendBuffer( struct usart_module *pxCDCUsart, const char * pcBuffer, size_t xBufferLength ); /* * Register the 'standard' sample CLI commands with FreeRTOS+CLI. @@ -129,9 +129,9 @@ static void prvUARTRxNotificationHandler( const struct usart_module *const pxUSA /*-----------------------------------------------------------*/ /* Const messages output by the command console. */ -static 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 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"; /* This semaphore is used to allow the task to wait for a Tx to complete without wasting any CPU time. */ @@ -159,8 +159,9 @@ void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPr static void prvUARTCommandConsoleTask( void *pvParameters ) { -uint8_t ucRxedChar, ucInputIndex = 0, *pucOutputString; -static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ]; +char cRxedChar, *pcOutputString; +uint8_t ucInputIndex = 0; +static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ]; portBASE_TYPE xReturned; static struct usart_module xCDCUsart; /* Static so it doesn't take up too much stack. */ @@ -174,7 +175,7 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s /* Obtain the address of the output buffer. Note there is no mutual exclusion on this buffer as it is assumed only one command console interface will be used at any one time. */ - pucOutputString = ( uint8_t * ) FreeRTOS_CLIGetOutputBuffer(); + pcOutputString = FreeRTOS_CLIGetOutputBuffer(); /* Send the welcome message. */ prvSendBuffer( &xCDCUsart, pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) ); @@ -183,17 +184,17 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s { /* Wait for the next character to arrive. A semaphore is used to ensure no CPU time is used until data has arrived. */ - usart_read_buffer_job( &xCDCUsart, &ucRxedChar, sizeof( ucRxedChar ) ); + usart_read_buffer_job( &xCDCUsart, ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) ); if( xSemaphoreTake( xRxCompleteSemaphore, portMAX_DELAY ) == pdPASS ) { /* Echo the character back. */ - prvSendBuffer( &xCDCUsart, ( uint8_t * ) &ucRxedChar, sizeof( ucRxedChar ) ); + prvSendBuffer( &xCDCUsart, &cRxedChar, sizeof( cRxedChar ) ); /* Was it the end of the line? */ - if( ucRxedChar == '\n' || ucRxedChar == '\r' ) + if( cRxedChar == '\n' || cRxedChar == '\r' ) { /* Just to space the output from the input. */ - prvSendBuffer( &xCDCUsart, ( uint8_t * ) pcNewLine, strlen( ( char * ) pcNewLine ) ); + prvSendBuffer( &xCDCUsart, pcNewLine, strlen( pcNewLine ) ); /* See if the command is empty, indicating that the last command is to be executed again. */ @@ -210,10 +211,10 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s do { /* Get the next output string from the command interpreter. */ - xReturned = FreeRTOS_CLIProcessCommand( cInputString, ( int8_t * ) pucOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE ); + xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE ); /* Write the generated string to the UART. */ - prvSendBuffer( &xCDCUsart, ( uint8_t * ) pucOutputString, strlen( ( char * ) pucOutputString ) ); + prvSendBuffer( &xCDCUsart, pcOutputString, strlen( pcOutputString ) ); } while( xReturned != pdFALSE ); @@ -225,15 +226,15 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s ucInputIndex = 0; memset( cInputString, 0x00, cmdMAX_INPUT_SIZE ); - prvSendBuffer( &xCDCUsart, ( uint8_t * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) ); + prvSendBuffer( &xCDCUsart, pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) ); } else { - if( ucRxedChar == '\r' ) + if( cRxedChar == '\r' ) { /* Ignore the character. */ } - else if( ( ucRxedChar == '\b' ) || ( ucRxedChar == cmdASCII_DEL ) ) + else if( ( cRxedChar == '\b' ) || ( cRxedChar == cmdASCII_DEL ) ) { /* Backspace was pressed. Erase the last character in the string - if any. */ @@ -248,11 +249,11 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s /* A character was entered. Add it to the string entered so far. When a \n is entered the complete string will be passed to the command interpreter. */ - if( ( ucRxedChar >= ' ' ) && ( ucRxedChar <= '~' ) ) + if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) ) { if( ucInputIndex < cmdMAX_INPUT_SIZE ) { - cInputString[ ucInputIndex ] = ucRxedChar; + cInputString[ ucInputIndex ] = cRxedChar; ucInputIndex++; } } @@ -263,13 +264,13 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s } /*-----------------------------------------------------------*/ -static void prvSendBuffer( struct usart_module *pxCDCUsart, uint8_t * pcBuffer, size_t xBufferLength ) +static void prvSendBuffer( struct usart_module *pxCDCUsart, const char * pcBuffer, size_t xBufferLength ) { const portTickType xBlockMax100ms = 100UL / portTICK_RATE_MS; if( xBufferLength > 0 ) { - usart_write_buffer_job( pxCDCUsart, pcBuffer, xBufferLength ); + usart_write_buffer_job( pxCDCUsart, ( uint8_t * ) pcBuffer, xBufferLength ); /* Wait for the Tx to complete so the buffer can be reused without corrupting the data that is being sent. */ diff --git a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c index e99e57528..13d5e1bdb 100644 --- a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c +++ b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c @@ -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 :\r\n Changes the working directory\r\n", + "cd", /* The command string to type. */ + "\r\ncd :\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 :\r\n Prints file contents to the terminal\r\n", + "type", /* The command string to type. */ + "\r\ntype :\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 :\r\n deletes a file or directory\r\n", + "del", /* The command string to type. */ + "\r\ndel :\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 :\r\n Copies to \r\n", + "copy", /* The command string to type. */ + "\r\ncopy :\r\n Copies to \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 ); } diff --git a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/Sample-CLI-commands.c b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/Sample-CLI-commands.c index 9fd423f8a..1df4ab16f 100644 --- a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/Sample-CLI-commands.c +++ b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/Sample-CLI-commands.c @@ -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 :\r\n Expects three parameters, echos each in turn\r\n", + "echo-3-parameters", + "\r\necho-3-parameters :\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; diff --git a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c index 6f0cab30a..c5555eff3 100644 --- a/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c +++ b/FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c @@ -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 ); -- 2.39.2