Update FreeRTOS+ more demos that use FreeRTOS+CLI to remove casting to int8_t * from strings.

This commit is contained in:
Richard Barry 2013-12-30 19:32:29 +00:00
parent 31609c7c3e
commit 38e7554138
32 changed files with 304 additions and 297 deletions

View file

@ -230,7 +230,7 @@ size_t xColumns = 50U;
configASSERT( pcParameter );
/* Attempt to open the requested file. */
pxFile = f_open( ( const char * ) pcParameter, "r" );
pxFile = f_open( pcParameter, "r" );
}
if( pxFile != NULL )
@ -392,7 +392,7 @@ unsigned char ucReturned;
configASSERT( pcParameter );
/* Attempt to delete the file. */
ucReturned = f_delete( ( const char * ) pcParameter );
ucReturned = f_delete( pcParameter );
if( ucReturned == F_NO_ERROR )
{
@ -416,23 +416,23 @@ portBASE_TYPE xParameterStringLength;
long lSourceLength, lDestinationLength = 0;
/* Obtain the name of the destination file. */
pcDestinationFile = 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 = 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 );
@ -441,7 +441,7 @@ 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 )
{
@ -450,7 +450,7 @@ long lSourceLength, lDestinationLength = 0;
else
{
/* See if the destination file exists. */
lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );
lDestinationLength = f_filelength( pcDestinationFile );
if( lDestinationLength != 0 )
{
@ -509,7 +509,7 @@ portBASE_TYPE xReturn = pdPASS;
/* Open the source file, seek past the data that has already been
read from the file, read the next block of data, then close the
file again so the destination file can be opened. */
pxFile = f_open( ( const char * ) pcSourceFile, "r" );
pxFile = f_open( pcSourceFile, "r" );
if( pxFile != NULL )
{
f_seek( pxFile, lBytesRead, F_SEEK_SET );
@ -524,7 +524,7 @@ portBASE_TYPE xReturn = pdPASS;
/* Open the destination file and write the block of data to the end of
the file. */
pxFile = f_open( ( const char * ) pcDestinationFile, "a" );
pxFile = f_open( pcDestinationFile, "a" );
if( pxFile != NULL )
{
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );

View file

@ -274,7 +274,7 @@ static portBASE_TYPE lParameterNumber = 0;
/* Return the parameter string. */
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
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
@ -340,7 +340,7 @@ static portBASE_TYPE lParameterNumber = 0;
/* Return the parameter string. */
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
/* There might be more parameters to return after this one. */
@ -391,7 +391,7 @@ static portBASE_TYPE lParameterNumber = 0;
configASSERT( pcParameter );
/* There are only two valid parameter values. */
if( strncmp( ( const char * ) pcParameter, "start", strlen( "start" ) ) == 0 )
if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
{
/* Start or restart the trace. */
vTraceStop();
@ -400,7 +400,7 @@ static portBASE_TYPE lParameterNumber = 0;
sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" );
}
else if( strncmp( ( const char * ) pcParameter, "stop", strlen( "stop" ) ) == 0 )
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
{
/* End the trace, if one is running. */
vTraceStop();

View file

@ -164,7 +164,7 @@ void vRegisterUDPCLICommands( void )
static portBASE_TYPE prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
{
const char * pcParameter;
char * pcParameter;
portBASE_TYPE lParameterStringLength, xReturn;
uint32_t ulIPAddress, ulBytesToPing;
const uint32_t ulDefaultBytesToPing = 8UL;
@ -181,12 +181,12 @@ void vRegisterUDPCLICommands( void )
pcWriteBuffer[ 0 ] = 0x00;
/* Obtain the number of bytes to ping. */
pcParameter = FreeRTOS_CLIGetParameter
(
pcCommandString, /* The command string itself. */
2, /* Return the second parameter. */
&lParameterStringLength /* Store the parameter string length. */
);
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
(
pcCommandString, /* The command string itself. */
2, /* Return the second parameter. */
&lParameterStringLength /* Store the parameter string length. */
);
if( pcParameter == NULL )
{
@ -195,16 +195,16 @@ void vRegisterUDPCLICommands( void )
}
else
{
ulBytesToPing = atol( ( const char * ) pcParameter );
ulBytesToPing = atol( pcParameter );
}
/* Obtain the IP address string. */
pcParameter = FreeRTOS_CLIGetParameter
(
pcCommandString, /* The command string itself. */
1, /* Return the first parameter. */
&lParameterStringLength /* Store the parameter string length. */
);
pcParameter = ( char * ) 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 );
@ -213,7 +213,7 @@ void vRegisterUDPCLICommands( void )
digit, assume the host name has been passed in. */
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
{
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
}
else
{
@ -221,7 +221,7 @@ void vRegisterUDPCLICommands( void )
pcParameter[ lParameterStringLength ] = 0x00;
/* Attempt to resolve host. */
ulIPAddress = FreeRTOS_gethostbyname( ( uint8_t * ) pcParameter );
ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
}
/* Convert IP address, which may have come from a DNS lookup, to string. */

View file

@ -285,7 +285,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
/* Obtain and print out the working directory. */
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
/* Generate the file name. */
sprintf( cFileName, "%s.txt", pcDirectory2 );
@ -311,7 +311,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
/* Obtain and print out the working directory. */
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcRoot ) == 0 );
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
}
/*-----------------------------------------------------------*/
@ -328,7 +328,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
/* Obtain and print out the working directory. */
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
/* Generate the file name. */
sprintf( cFileName, "%s.txt", pcDirectory2 );

View file

@ -333,7 +333,7 @@ static portBASE_TYPE lParameterNumber = 0;
/* Return the parameter string. */
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
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
@ -399,7 +399,7 @@ static portBASE_TYPE lParameterNumber = 0;
/* Return the parameter string. */
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
/* There might be more parameters to return after this one. */
@ -459,7 +459,7 @@ static portBASE_TYPE lParameterNumber = 0;
}
else
{
ulBytesToPing = atol( ( const char * ) pcParameter );
ulBytesToPing = atol( pcParameter );
}
/* Obtain the IP address string. */
@ -477,7 +477,7 @@ static portBASE_TYPE lParameterNumber = 0;
digit, assume the host name has been passed in. */
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
{
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
}
else
{
@ -485,7 +485,7 @@ static portBASE_TYPE lParameterNumber = 0;
pcParameter[ lParameterStringLength ] = 0x00;
/* Attempt to resolve host. */
ulIPAddress = FreeRTOS_gethostbyname( ( uint8_t * ) pcParameter );
ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
}
/* Convert IP address, which may have come from a DNS lookup, to string. */
@ -639,7 +639,7 @@ uint32_t ulAddress;
configASSERT( pcParameter );
/* There are only two valid parameter values. */
if( strncmp( ( const char * ) pcParameter, "start", strlen( "start" ) ) == 0 )
if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
{
/* Start or restart the trace. */
vTraceStop();

View file

@ -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.
@ -108,7 +108,7 @@ void vStartUDPCommandInterpreterTask( uint16_t usStackSize, uint32_t ulPort, uns
}
/*-----------------------------------------------------------*/
/*
/*
* Task that provides the input and output for the FreeRTOS+CLI command
* interpreter. In this case a UDP port is used. See the URL in the comments
* within main.c for the location of the online documentation.
@ -117,7 +117,7 @@ void vUDPCommandInterpreterTask( void *pvParameters )
{
long lBytes, lByte;
signed char cInChar, cInputIndex = 0;
static signed char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ], cLocalBuffer[ cmdSOCKET_INPUT_BUFFER_SIZE ];
static char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ], cLocalBuffer[ cmdSOCKET_INPUT_BUFFER_SIZE ];
portBASE_TYPE xMoreDataToFollow;
struct freertos_sockaddr xClient;
socklen_t xClientAddressLength = 0; /* This is required as a parameter to maintain the sendto() Berkeley sockets API - but it is not actually used so can take any value. */
@ -152,25 +152,25 @@ xSocket_t xSocket;
string. */
if( cInChar == '\n' )
{
/* Process the input string received prior to the
/* Process the input string received prior to the
newline. */
do
{
/* Pass the string to FreeRTOS+CLI. */
xMoreDataToFollow = FreeRTOS_CLIProcessCommand( cInputString, cOutputString, cmdMAX_OUTPUT_SIZE );
/* Send the output generated by the command's
implementation. */
FreeRTOS_sendto( xSocket, cOutputString, strlen( ( const char * ) cOutputString ), 0, &xClient, xClientAddressLength );
FreeRTOS_sendto( xSocket, cOutputString, strlen( cOutputString ), 0, &xClient, xClientAddressLength );
} while( xMoreDataToFollow != pdFALSE ); /* Until the command does not generate any more output. */
/* All the strings generated by the command processing
have been sent. Clear the input string ready to receive
/* All the strings generated by the command processing
have been sent. Clear the input string ready to receive
the next command. */
cInputIndex = 0;
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
/* Transmit a spacer, just to make the command console
easier to read. */
FreeRTOS_sendto( xSocket, "\r\n", strlen( "\r\n" ), 0, &xClient, xClientAddressLength );
@ -179,12 +179,12 @@ xSocket_t xSocket;
{
if( cInChar == '\r' )
{
/* Ignore the character. Newlines are used to
/* Ignore the character. Newlines are used to
detect the end of the input string. */
}
else if( cInChar == '\b' )
{
/* Backspace was pressed. Erase the last character
/* Backspace was pressed. Erase the last character
in the string - if any. */
if( cInputIndex > 0 )
{
@ -206,7 +206,7 @@ xSocket_t xSocket;
}
}
}
}
}
}
else
{
@ -232,7 +232,7 @@ xSocket_t xSocket = FREERTOS_INVALID_SOCKET;
/* Bind the address to the socket. */
if( FreeRTOS_bind( xSocket, &xServer, sizeof( xServer ) ) == -1 )
{
{
FreeRTOS_closesocket( xSocket );
xSocket = FREERTOS_INVALID_SOCKET;
}

View file

@ -156,7 +156,7 @@ static void prvEchoClientTask( void *pvParameters )
{
xSocket_t xSocket;
struct freertos_sockaddr xEchoServerAddress;
int8_t cTxString[ 25 ], cRxString[ 25 ]; /* Make sure the stack is large enough to hold these. Turn on stack overflow checking during debug to be sure. */
char cTxString[ 25 ], cRxString[ 25 ]; /* Make sure the stack is large enough to hold these. Turn on stack overflow checking during debug to be sure. */
int32_t lLoopCount = 0UL;
const int32_t lMaxLoopCount = 50;
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
@ -188,7 +188,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
for( lLoopCount = 0; lLoopCount < lMaxLoopCount; lLoopCount++ )
{
/* Create the string that is sent to the echo server. */
sprintf( ( char * ) cTxString, "Message number %u\r\n", ( unsigned int ) ulTxCount );
sprintf( cTxString, "Message number %u\r\n", ( unsigned int ) ulTxCount );
/* Send the string to the socket. ulFlags is set to 0, so the zero
copy interface is not used. That means the data from cTxString is
@ -197,7 +197,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
to ensure the NULL string terminator is sent as part of the message. */
FreeRTOS_sendto( xSocket, /* The socket being sent to. */
( void * ) cTxString, /* The data being sent. */
strlen( ( const char * ) cTxString ) + 1, /* The length of the data being sent. */
strlen( cTxString ) + 1,/* The length of the data being sent. */
0, /* ulFlags with the FREERTOS_ZERO_COPY bit clear. */
&xEchoServerAddress, /* The destination address. */
sizeof( xEchoServerAddress ) );
@ -223,7 +223,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
&xAddressLength );
/* Compare the transmitted string to the received string. */
if( strcmp( ( char * ) cRxString, ( char * ) cTxString ) == 0 )
if( strcmp( cRxString, cTxString ) == 0 )
{
/* The echo reply was received without error. */
ulRxCount++;
@ -244,7 +244,7 @@ static void prvZeroCopyEchoClientTask( void *pvParameters )
{
xSocket_t xSocket;
struct freertos_sockaddr xEchoServerAddress;
static int8_t cTxString[ 40 ];
static char cTxString[ 40 ];
int32_t lLoopCount = 0UL;
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
uint32_t xAddressLength = sizeof( xEchoServerAddress );
@ -252,9 +252,9 @@ int32_t lReturned;
uint8_t *pucUDPPayloadBuffer;
const int32_t lMaxLoopCount = 50;
const uint8_t * const pucStringToSend = ( const uint8_t * const ) "Zero copy message number";
const char * const pcStringToSend = "Zero copy message number";
/* The buffer is large enough to hold the string, a number, and the string terminator. */
const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
const size_t xBufferLength = strlen( pcStringToSend ) + 15;
#if ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1
{
@ -309,11 +309,11 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
/* A buffer was successfully obtained. Create the string that is
sent to the echo server. Note the string is written directly
into the buffer obtained from the IP stack. */
sprintf( ( char * ) pucUDPPayloadBuffer, "%s %u\r\n", ( const char * ) "Zero copy message number", ( unsigned int ) ulTxCount );
sprintf( ( char * ) pucUDPPayloadBuffer, "%s %u\r\n", "Zero copy message number", ( unsigned int ) ulTxCount );
/* Also copy the string into a local buffer so it can be compared
with the string that is later received back from the echo server. */
strcpy( ( char * ) cTxString, ( char * ) pucUDPPayloadBuffer );
strcpy( cTxString, ( char * ) pucUDPPayloadBuffer );
/* Pass the buffer into the send function. ulFlags has the
FREERTOS_ZERO_COPY bit set so the IP stack will take control of
@ -321,7 +321,7 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
echoMARK_SEND_IN_TRACE_BUFFER( xZeroCopySendEvent );
lReturned = FreeRTOS_sendto( xSocket, /* The socket being sent to. */
( void * ) pucUDPPayloadBuffer, /* The buffer being passed into the IP stack. */
strlen( ( const char * ) cTxString ) + 1, /* The length of the data being sent. Plus 1 to ensure the null terminator is part of the data. */
strlen( cTxString ) + 1, /* The length of the data being sent. Plus 1 to ensure the null terminator is part of the data. */
FREERTOS_ZERO_COPY, /* ulFlags with the zero copy bit is set. */
&xEchoServerAddress, /* Where the data is being sent. */
sizeof( xEchoServerAddress ) );
@ -372,7 +372,7 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
{
/* Compare the string sent to the echo server with the string
received back from the echo server. */
if( strcmp( ( char * ) pucUDPPayloadBuffer, ( char * ) cTxString ) == 0 )
if( strcmp( ( char * ) pucUDPPayloadBuffer, cTxString ) == 0 )
{
/* The strings matched. */
ulRxCount++;