mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-22 14:31:59 -04:00
Update FreeRTOS+ more demos that use FreeRTOS+CLI to remove casting to int8_t * from strings.
This commit is contained in:
parent
31609c7c3e
commit
38e7554138
|
@ -230,7 +230,7 @@ size_t xColumns = 50U;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to open the requested file. */
|
/* Attempt to open the requested file. */
|
||||||
pxFile = f_open( ( const char * ) pcParameter, "r" );
|
pxFile = f_open( pcParameter, "r" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
|
@ -392,7 +392,7 @@ unsigned char ucReturned;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to delete the file. */
|
/* Attempt to delete the file. */
|
||||||
ucReturned = f_delete( ( const char * ) pcParameter );
|
ucReturned = f_delete( pcParameter );
|
||||||
|
|
||||||
if( ucReturned == F_NO_ERROR )
|
if( ucReturned == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
|
@ -416,7 +416,7 @@ portBASE_TYPE xParameterStringLength;
|
||||||
long lSourceLength, lDestinationLength = 0;
|
long lSourceLength, lDestinationLength = 0;
|
||||||
|
|
||||||
/* Obtain the name of the destination file. */
|
/* Obtain the name of the destination file. */
|
||||||
pcDestinationFile = FreeRTOS_CLIGetParameter
|
pcDestinationFile = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
2, /* Return the second parameter. */
|
2, /* Return the second parameter. */
|
||||||
|
@ -427,7 +427,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
configASSERT( pcDestinationFile );
|
configASSERT( pcDestinationFile );
|
||||||
|
|
||||||
/* Obtain the name of the source file. */
|
/* Obtain the name of the source file. */
|
||||||
pcSourceFile = FreeRTOS_CLIGetParameter
|
pcSourceFile = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
1, /* Return the first parameter. */
|
1, /* Return the first parameter. */
|
||||||
|
@ -441,7 +441,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
pcSourceFile[ xParameterStringLength ] = 0x00;
|
pcSourceFile[ xParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* See if the source file exists, obtain its length if it does. */
|
/* 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 )
|
if( lSourceLength == 0 )
|
||||||
{
|
{
|
||||||
|
@ -450,7 +450,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* See if the destination file exists. */
|
/* See if the destination file exists. */
|
||||||
lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );
|
lDestinationLength = f_filelength( pcDestinationFile );
|
||||||
|
|
||||||
if( lDestinationLength != 0 )
|
if( lDestinationLength != 0 )
|
||||||
{
|
{
|
||||||
|
@ -509,7 +509,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
/* Open the source file, seek past the data that has already been
|
/* 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
|
read from the file, read the next block of data, then close the
|
||||||
file again so the destination file can be opened. */
|
file again so the destination file can be opened. */
|
||||||
pxFile = f_open( ( const char * ) pcSourceFile, "r" );
|
pxFile = f_open( pcSourceFile, "r" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
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
|
/* Open the destination file and write the block of data to the end of
|
||||||
the file. */
|
the file. */
|
||||||
pxFile = f_open( ( const char * ) pcDestinationFile, "a" );
|
pxFile = f_open( pcDestinationFile, "a" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
||||||
|
|
|
@ -274,7 +274,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* 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. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -391,7 +391,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
@ -400,7 +400,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
sprintf( 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 )
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* End the trace, if one is running. */
|
/* End the trace, if one is running. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -164,7 +164,7 @@ void vRegisterUDPCLICommands( void )
|
||||||
|
|
||||||
static portBASE_TYPE prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
static portBASE_TYPE prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||||
{
|
{
|
||||||
const char * pcParameter;
|
char * pcParameter;
|
||||||
portBASE_TYPE lParameterStringLength, xReturn;
|
portBASE_TYPE lParameterStringLength, xReturn;
|
||||||
uint32_t ulIPAddress, ulBytesToPing;
|
uint32_t ulIPAddress, ulBytesToPing;
|
||||||
const uint32_t ulDefaultBytesToPing = 8UL;
|
const uint32_t ulDefaultBytesToPing = 8UL;
|
||||||
|
@ -181,7 +181,7 @@ void vRegisterUDPCLICommands( void )
|
||||||
pcWriteBuffer[ 0 ] = 0x00;
|
pcWriteBuffer[ 0 ] = 0x00;
|
||||||
|
|
||||||
/* Obtain the number of bytes to ping. */
|
/* Obtain the number of bytes to ping. */
|
||||||
pcParameter = FreeRTOS_CLIGetParameter
|
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
2, /* Return the second parameter. */
|
2, /* Return the second parameter. */
|
||||||
|
@ -195,11 +195,11 @@ void vRegisterUDPCLICommands( void )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ulBytesToPing = atol( ( const char * ) pcParameter );
|
ulBytesToPing = atol( pcParameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obtain the IP address string. */
|
/* Obtain the IP address string. */
|
||||||
pcParameter = FreeRTOS_CLIGetParameter
|
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
1, /* Return the first parameter. */
|
1, /* Return the first parameter. */
|
||||||
|
@ -213,7 +213,7 @@ void vRegisterUDPCLICommands( void )
|
||||||
digit, assume the host name has been passed in. */
|
digit, assume the host name has been passed in. */
|
||||||
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
|
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ void vRegisterUDPCLICommands( void )
|
||||||
pcParameter[ lParameterStringLength ] = 0x00;
|
pcParameter[ lParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* Attempt to resolve host. */
|
/* 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. */
|
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
||||||
|
|
|
@ -285,7 +285,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
@ -311,7 +311,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
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. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
|
@ -333,7 +333,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* 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. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -459,7 +459,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ulBytesToPing = atol( ( const char * ) pcParameter );
|
ulBytesToPing = atol( pcParameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obtain the IP address string. */
|
/* Obtain the IP address string. */
|
||||||
|
@ -477,7 +477,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
digit, assume the host name has been passed in. */
|
digit, assume the host name has been passed in. */
|
||||||
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
|
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -485,7 +485,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
pcParameter[ lParameterStringLength ] = 0x00;
|
pcParameter[ lParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* Attempt to resolve host. */
|
/* 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. */
|
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
||||||
|
@ -639,7 +639,7 @@ uint32_t ulAddress;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -117,7 +117,7 @@ void vUDPCommandInterpreterTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
long lBytes, lByte;
|
long lBytes, lByte;
|
||||||
signed char cInChar, cInputIndex = 0;
|
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;
|
portBASE_TYPE xMoreDataToFollow;
|
||||||
struct freertos_sockaddr xClient;
|
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. */
|
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. */
|
||||||
|
@ -161,7 +161,7 @@ xSocket_t xSocket;
|
||||||
|
|
||||||
/* Send the output generated by the command's
|
/* Send the output generated by the command's
|
||||||
implementation. */
|
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. */
|
} while( xMoreDataToFollow != pdFALSE ); /* Until the command does not generate any more output. */
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ static void prvEchoClientTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
xSocket_t xSocket;
|
xSocket_t xSocket;
|
||||||
struct freertos_sockaddr xEchoServerAddress;
|
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;
|
int32_t lLoopCount = 0UL;
|
||||||
const int32_t lMaxLoopCount = 50;
|
const int32_t lMaxLoopCount = 50;
|
||||||
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
||||||
|
@ -188,7 +188,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
||||||
for( lLoopCount = 0; lLoopCount < lMaxLoopCount; lLoopCount++ )
|
for( lLoopCount = 0; lLoopCount < lMaxLoopCount; lLoopCount++ )
|
||||||
{
|
{
|
||||||
/* Create the string that is sent to the echo server. */
|
/* 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
|
/* 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
|
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. */
|
to ensure the NULL string terminator is sent as part of the message. */
|
||||||
FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
||||||
( void * ) cTxString, /* The data being sent. */
|
( 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. */
|
0, /* ulFlags with the FREERTOS_ZERO_COPY bit clear. */
|
||||||
&xEchoServerAddress, /* The destination address. */
|
&xEchoServerAddress, /* The destination address. */
|
||||||
sizeof( xEchoServerAddress ) );
|
sizeof( xEchoServerAddress ) );
|
||||||
|
@ -223,7 +223,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
||||||
&xAddressLength );
|
&xAddressLength );
|
||||||
|
|
||||||
/* Compare the transmitted string to the received string. */
|
/* 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. */
|
/* The echo reply was received without error. */
|
||||||
ulRxCount++;
|
ulRxCount++;
|
||||||
|
@ -244,7 +244,7 @@ static void prvZeroCopyEchoClientTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
xSocket_t xSocket;
|
xSocket_t xSocket;
|
||||||
struct freertos_sockaddr xEchoServerAddress;
|
struct freertos_sockaddr xEchoServerAddress;
|
||||||
static int8_t cTxString[ 40 ];
|
static char cTxString[ 40 ];
|
||||||
int32_t lLoopCount = 0UL;
|
int32_t lLoopCount = 0UL;
|
||||||
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
||||||
uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
||||||
|
@ -252,9 +252,9 @@ int32_t lReturned;
|
||||||
uint8_t *pucUDPPayloadBuffer;
|
uint8_t *pucUDPPayloadBuffer;
|
||||||
|
|
||||||
const int32_t lMaxLoopCount = 50;
|
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. */
|
/* 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
|
#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
|
/* A buffer was successfully obtained. Create the string that is
|
||||||
sent to the echo server. Note the string is written directly
|
sent to the echo server. Note the string is written directly
|
||||||
into the buffer obtained from the IP stack. */
|
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
|
/* 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. */
|
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
|
/* Pass the buffer into the send function. ulFlags has the
|
||||||
FREERTOS_ZERO_COPY bit set so the IP stack will take control of
|
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 );
|
echoMARK_SEND_IN_TRACE_BUFFER( xZeroCopySendEvent );
|
||||||
lReturned = FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
lReturned = FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
||||||
( void * ) pucUDPPayloadBuffer, /* The buffer being passed into the IP stack. */
|
( 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. */
|
FREERTOS_ZERO_COPY, /* ulFlags with the zero copy bit is set. */
|
||||||
&xEchoServerAddress, /* Where the data is being sent. */
|
&xEchoServerAddress, /* Where the data is being sent. */
|
||||||
sizeof( xEchoServerAddress ) );
|
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
|
/* Compare the string sent to the echo server with the string
|
||||||
received back from the echo server. */
|
received back from the echo server. */
|
||||||
if( strcmp( ( char * ) pucUDPPayloadBuffer, ( char * ) cTxString ) == 0 )
|
if( strcmp( ( char * ) pucUDPPayloadBuffer, cTxString ) == 0 )
|
||||||
{
|
{
|
||||||
/* The strings matched. */
|
/* The strings matched. */
|
||||||
ulRxCount++;
|
ulRxCount++;
|
||||||
|
|
|
@ -257,7 +257,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, lParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, lParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* If this is the last of the three parameters then there are no more
|
||||||
|
@ -323,7 +323,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, lParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, lParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -372,7 +372,7 @@ portBASE_TYPE lParameterStringLength;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
@ -381,7 +381,7 @@ portBASE_TYPE lParameterStringLength;
|
||||||
|
|
||||||
sprintf( 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 )
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* End the trace, if one is running. */
|
/* End the trace, if one is running. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct sockaddr_in xConnection;
|
||||||
CYASSL* xCyaSSL_Object;
|
CYASSL* xCyaSSL_Object;
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
WSADATA xWSAData;
|
WSADATA xWSAData;
|
||||||
uint8_t cString[ 50 ];
|
char cString[ 50 ];
|
||||||
portBASE_TYPE lReturned;
|
portBASE_TYPE lReturned;
|
||||||
uint32_t ulCount = 0UL;
|
uint32_t ulCount = 0UL;
|
||||||
|
|
||||||
|
@ -146,12 +146,12 @@ uint32_t ulCount = 0UL;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Create the string that is sent to the secure server. */
|
/* Create the string that is sent to the secure server. */
|
||||||
sprintf( ( char * ) cString, "Message number %lu\r\n", ulCount );
|
sprintf( cString, "Message number %lu\r\n", ulCount );
|
||||||
|
|
||||||
/* The next line is the secure equivalent of the standard
|
/* The next line is the secure equivalent of the standard
|
||||||
sockets call:
|
sockets call:
|
||||||
lReturned = send( xClientSocket, cString, strlen( cString ) + 1, 0 ); */
|
lReturned = send( xClientSocket, cString, strlen( cString ) + 1, 0 ); */
|
||||||
lReturned = CyaSSL_write( xCyaSSL_Object, ( const char * ) cString, strlen( ( const char * ) cString ) + 1 );
|
lReturned = CyaSSL_write( xCyaSSL_Object, cString, strlen( cString ) + 1 );
|
||||||
|
|
||||||
|
|
||||||
/* Short delay to prevent the messages streaming up the
|
/* Short delay to prevent the messages streaming up the
|
||||||
|
|
|
@ -244,7 +244,7 @@ size_t xColumns = 50U;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to open the requested file. */
|
/* Attempt to open the requested file. */
|
||||||
pxFile = f_open( ( const char * ) pcParameter, "r" );
|
pxFile = f_open( pcParameter, "r" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
|
@ -305,7 +305,7 @@ size_t xStringLength;
|
||||||
if( ucReturned == F_NO_ERROR )
|
if( ucReturned == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
sprintf( pcWriteBuffer, "In: " );
|
sprintf( pcWriteBuffer, "In: " );
|
||||||
xStringLength = strlen( ( const char * ) pcWriteBuffer );
|
xStringLength = strlen( pcWriteBuffer );
|
||||||
f_getcwd( &( pcWriteBuffer[ xStringLength ] ), ( unsigned char ) ( xWriteBufferLen - xStringLength ) );
|
f_getcwd( &( pcWriteBuffer[ xStringLength ] ), ( unsigned char ) ( xWriteBufferLen - xStringLength ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -406,7 +406,7 @@ unsigned char ucReturned;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to delete the file. */
|
/* Attempt to delete the file. */
|
||||||
ucReturned = f_delete( ( const char * ) pcParameter );
|
ucReturned = f_delete( pcParameter );
|
||||||
|
|
||||||
if( ucReturned == F_NO_ERROR )
|
if( ucReturned == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
|
@ -483,7 +483,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
pcSourceFile[ xParameterStringLength ] = 0x00;
|
pcSourceFile[ xParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* See if the source file exists, obtain its length if it does. */
|
/* 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 )
|
if( lSourceLength == 0 )
|
||||||
{
|
{
|
||||||
|
@ -492,7 +492,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* See if the destination file exists. */
|
/* See if the destination file exists. */
|
||||||
lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );
|
lDestinationLength = f_filelength( pcDestinationFile );
|
||||||
|
|
||||||
if( lDestinationLength != 0 )
|
if( lDestinationLength != 0 )
|
||||||
{
|
{
|
||||||
|
@ -551,7 +551,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
/* Open the source file, seek past the data that has already been
|
/* 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
|
read from the file, read the next block of data, then close the
|
||||||
file again so the destination file can be opened. */
|
file again so the destination file can be opened. */
|
||||||
pxFile = f_open( ( const char * ) pcSourceFile, "r" );
|
pxFile = f_open( pcSourceFile, "r" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
||||||
|
@ -566,7 +566,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
|
|
||||||
/* Open the destination file and write the block of data to the end of
|
/* Open the destination file and write the block of data to the end of
|
||||||
the file. */
|
the file. */
|
||||||
pxFile = f_open( ( const char * ) pcDestinationFile, "a" );
|
pxFile = f_open( pcDestinationFile, "a" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
||||||
|
|
|
@ -289,7 +289,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "In directory %s\r\n", cRAMBuffer );
|
printf( "In directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
@ -318,7 +318,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcRoot ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in directory %s\r\n", cRAMBuffer );
|
printf( "Back in directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
|
@ -272,7 +272,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* If this is the last of the three parameters then there are no more
|
||||||
|
@ -338,7 +338,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -389,7 +389,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -333,7 +333,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* 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. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -477,7 +477,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
digit, assume the host name has been passed in. */
|
digit, assume the host name has been passed in. */
|
||||||
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
||||||
{
|
{
|
||||||
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
|
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -485,7 +485,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
pcParameter[ lParameterStringLength ] = 0x00;
|
pcParameter[ lParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* Attempt to resolve host. */
|
/* 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. */
|
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
||||||
|
@ -639,7 +639,7 @@ uint32_t ulAddress;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -91,7 +91,7 @@ static void prvCDCCommandConsoleTask( void *pvParameters );
|
||||||
* Obtain a character from the CDC input. The calling task will be held in the
|
* Obtain a character from the CDC input. The calling task will be held in the
|
||||||
* Blocked state (so other tasks can execute) until a character is avilable.
|
* Blocked state (so other tasks can execute) until a character is avilable.
|
||||||
*/
|
*/
|
||||||
int8_t cGetCDCChar( void );
|
char cGetCDCChar( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise the third party virtual comport files driver
|
* Initialise the third party virtual comport files driver
|
||||||
|
@ -109,9 +109,9 @@ task. */
|
||||||
static xSemaphoreHandle xCDCMutex = NULL;
|
static xSemaphoreHandle xCDCMutex = NULL;
|
||||||
|
|
||||||
/* Const messages output by the command console. */
|
/* Const messages output by the command console. */
|
||||||
static const uint8_t * const pcWelcomeMessage = ( uint8_t * ) "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\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 uint8_t * const pcEndOfOutputMessage = ( uint8_t * ) "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
static const char * const pcEndOfOutputMessage = "\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 pcNewLine = "\r\n";
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -140,8 +140,10 @@ void vCDCCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPri
|
||||||
|
|
||||||
static void prvCDCCommandConsoleTask( void *pvParameters )
|
static void prvCDCCommandConsoleTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
int8_t cRxedChar, cInputIndex = 0, *pcOutputString;
|
char cRxedChar;
|
||||||
static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
uint8_t ucInputIndex = 0;
|
||||||
|
char *pcOutputString;
|
||||||
|
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
||||||
portBASE_TYPE xReturned;
|
portBASE_TYPE xReturned;
|
||||||
|
|
||||||
( void ) pvParameters;
|
( void ) pvParameters;
|
||||||
|
@ -156,7 +158,7 @@ portBASE_TYPE xReturned;
|
||||||
|
|
||||||
/* Send the welcome message. This probably won't be seen as the console
|
/* Send the welcome message. This probably won't be seen as the console
|
||||||
will not have been connected yet. */
|
will not have been connected yet. */
|
||||||
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcWelcomeMessage, strlen( ( const char * ) pcWelcomeMessage ) );
|
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcWelcomeMessage, strlen( pcWelcomeMessage ) );
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
|
@ -175,14 +177,14 @@ portBASE_TYPE xReturned;
|
||||||
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
||||||
{
|
{
|
||||||
/* Just to space the output from the input. */
|
/* Just to space the output from the input. */
|
||||||
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcNewLine, strlen( ( const char * ) pcNewLine ) );
|
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcNewLine, strlen( pcNewLine ) );
|
||||||
|
|
||||||
/* See if the command is empty, indicating that the last command is
|
/* See if the command is empty, indicating that the last command is
|
||||||
to be executed again. */
|
to be executed again. */
|
||||||
if( cInputIndex == 0 )
|
if( ucInputIndex == 0 )
|
||||||
{
|
{
|
||||||
/* Copy the last command back into the input string. */
|
/* Copy the last command back into the input string. */
|
||||||
strcpy( ( char * ) cInputString, ( char * ) cLastInputString );
|
strcpy( cInputString, cLastInputString );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass the received command to the command interpreter. The
|
/* Pass the received command to the command interpreter. The
|
||||||
|
@ -195,7 +197,7 @@ portBASE_TYPE xReturned;
|
||||||
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
||||||
|
|
||||||
/* Write the generated string to the CDC. */
|
/* Write the generated string to the CDC. */
|
||||||
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcOutputString, strlen( ( const char * ) pcOutputString ) );
|
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcOutputString, strlen( pcOutputString ) );
|
||||||
vTaskDelay( 1 );
|
vTaskDelay( 1 );
|
||||||
|
|
||||||
} while( xReturned != pdFALSE );
|
} while( xReturned != pdFALSE );
|
||||||
|
@ -204,11 +206,11 @@ portBASE_TYPE xReturned;
|
||||||
Clear the input string ready to receive the next command. Remember
|
Clear the input string ready to receive the next command. Remember
|
||||||
the command that was just processed first in case it is to be
|
the command that was just processed first in case it is to be
|
||||||
processed again. */
|
processed again. */
|
||||||
strcpy( ( char * ) cLastInputString, ( char * ) cInputString );
|
strcpy( cLastInputString, cInputString );
|
||||||
cInputIndex = 0;
|
ucInputIndex = 0;
|
||||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
|
|
||||||
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcEndOfOutputMessage, strlen( ( const char * ) pcEndOfOutputMessage ) );
|
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -220,10 +222,10 @@ portBASE_TYPE xReturned;
|
||||||
{
|
{
|
||||||
/* Backspace was pressed. Erase the last character in the
|
/* Backspace was pressed. Erase the last character in the
|
||||||
string - if any. */
|
string - if any. */
|
||||||
if( cInputIndex > 0 )
|
if( ucInputIndex > 0 )
|
||||||
{
|
{
|
||||||
cInputIndex--;
|
ucInputIndex--;
|
||||||
cInputString[ cInputIndex ] = '\0';
|
cInputString[ ucInputIndex ] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -233,10 +235,10 @@ portBASE_TYPE xReturned;
|
||||||
string will be passed to the command interpreter. */
|
string will be passed to the command interpreter. */
|
||||||
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
|
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
|
||||||
{
|
{
|
||||||
if( cInputIndex < cmdMAX_INPUT_SIZE )
|
if( ucInputIndex < cmdMAX_INPUT_SIZE )
|
||||||
{
|
{
|
||||||
cInputString[ cInputIndex ] = cRxedChar;
|
cInputString[ ucInputIndex ] = cRxedChar;
|
||||||
cInputIndex++;
|
ucInputIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,20 +251,20 @@ portBASE_TYPE xReturned;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vOutputString( const uint8_t * const pucMessage )
|
void vOutputString( const char * const pcMessage )
|
||||||
{
|
{
|
||||||
if( xSemaphoreTake( xCDCMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
if( xSemaphoreTake( xCDCMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
||||||
{
|
{
|
||||||
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pucMessage, strlen( ( const char * ) pucMessage ) );
|
USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcMessage, strlen( pcMessage ) );
|
||||||
xSemaphoreGive( xCDCMutex );
|
xSemaphoreGive( xCDCMutex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
int8_t cGetCDCChar( void )
|
char cGetCDCChar( void )
|
||||||
{
|
{
|
||||||
int32_t lAvailableBytes, xBytes = 0;
|
int32_t lAvailableBytes, xBytes = 0;
|
||||||
int8_t cInputChar;
|
char cInputChar;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -274,7 +276,7 @@ int8_t cInputChar;
|
||||||
{
|
{
|
||||||
/* Attempt to read one character. */
|
/* Attempt to read one character. */
|
||||||
xBytes = 1;
|
xBytes = 1;
|
||||||
xBytes = CDC_RdOutBuf( ( char * ) &cInputChar, &xBytes );
|
xBytes = CDC_RdOutBuf( &cInputChar, &xBytes );
|
||||||
|
|
||||||
xSemaphoreGive( xCDCMutex );
|
xSemaphoreGive( xCDCMutex );
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,24 +232,24 @@ static portBASE_TYPE xTaskAlreadyCreated = pdFALSE;
|
||||||
/* Called by FreeRTOS+UDP when a reply is received to an outgoing ping request. */
|
/* Called by FreeRTOS+UDP when a reply is received to an outgoing ping request. */
|
||||||
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )
|
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )
|
||||||
{
|
{
|
||||||
static const uint8_t *pucSuccess = ( uint8_t * ) "\r\n\r\nPing reply received - ";
|
static const char *pcSuccess = "\r\n\r\nPing reply received - ";
|
||||||
static const uint8_t *pucInvalidChecksum = ( uint8_t * ) "\r\n\r\nPing reply received with invalid checksum - ";
|
static const char *pcInvalidChecksum = "\r\n\r\nPing reply received with invalid checksum - ";
|
||||||
static const uint8_t *pucInvalidData = ( uint8_t * ) "\r\n\r\nPing reply received with invalid data - ";
|
static const char *pcInvalidData = "\r\n\r\nPing reply received with invalid data - ";
|
||||||
static uint8_t ucMessage[ 50 ];
|
static char cMessage[ 50 ];
|
||||||
void vOutputString( const uint8_t * const pucMessage );
|
void vOutputString( const char * const pcMessage );
|
||||||
|
|
||||||
switch( eStatus )
|
switch( eStatus )
|
||||||
{
|
{
|
||||||
case eSuccess :
|
case eSuccess :
|
||||||
vOutputString( pucSuccess );
|
vOutputString( pcSuccess );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInvalidChecksum :
|
case eInvalidChecksum :
|
||||||
vOutputString( pucInvalidChecksum );
|
vOutputString( pcInvalidChecksum );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInvalidData :
|
case eInvalidData :
|
||||||
vOutputString( pucInvalidData );
|
vOutputString( pcInvalidData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -258,7 +258,7 @@ void vOutputString( const uint8_t * const pucMessage );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( ( char * ) ucMessage, "identifier %d\r\n\r\n", ( int ) usIdentifier );
|
sprintf( cMessage, "identifier %d\r\n\r\n", ( int ) usIdentifier );
|
||||||
vOutputString( ucMessage );
|
vOutputString( cMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ static void prvSimpleClientTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
xSocket_t xClientSocket;
|
xSocket_t xClientSocket;
|
||||||
struct freertos_sockaddr xDestinationAddress;
|
struct freertos_sockaddr xDestinationAddress;
|
||||||
uint8_t cString[ 50 ];
|
char cString[ 50 ];
|
||||||
portBASE_TYPE lReturned;
|
portBASE_TYPE lReturned;
|
||||||
uint32_t ulCount = 0UL, ulIPAddress;
|
uint32_t ulCount = 0UL, ulIPAddress;
|
||||||
const uint32_t ulLoopsPerSocket = 10UL;
|
const uint32_t ulLoopsPerSocket = 10UL;
|
||||||
|
@ -162,13 +162,13 @@ const portTickType x150ms = 150UL / portTICK_RATE_MS;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Create the string that is sent to the server. */
|
/* Create the string that is sent to the server. */
|
||||||
sprintf( ( char * ) cString, "Server received (not zero copy): Message number %lu\r\n", ulCount );
|
sprintf( cString, "Server received (not zero copy): Message number %lu\r\n", ulCount );
|
||||||
|
|
||||||
/* Send the string to the socket. ulFlags is set to 0, so the zero
|
/* Send the string to the socket. ulFlags is set to 0, so the zero
|
||||||
copy option is not selected. That means the data from cString[] is
|
copy option is not selected. That means the data from cString[] is
|
||||||
copied into a network buffer inside FreeRTOS_sendto(), and cString[]
|
copied into a network buffer inside FreeRTOS_sendto(), and cString[]
|
||||||
can be reused as soon as FreeRTOS_sendto() has returned. */
|
can be reused as soon as FreeRTOS_sendto() has returned. */
|
||||||
lReturned = FreeRTOS_sendto( xClientSocket, ( void * ) cString, strlen( ( const char * ) cString ), 0, &xDestinationAddress, sizeof( xDestinationAddress ) );
|
lReturned = FreeRTOS_sendto( xClientSocket, ( void * ) cString, strlen( cString ), 0, &xDestinationAddress, sizeof( xDestinationAddress ) );
|
||||||
|
|
||||||
ulCount++;
|
ulCount++;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ const portTickType x150ms = 150UL / portTICK_RATE_MS;
|
||||||
static void prvSimpleServerTask( void *pvParameters )
|
static void prvSimpleServerTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
long lBytes;
|
long lBytes;
|
||||||
uint8_t cReceivedString[ 60 ];
|
char cReceivedString[ 60 ];
|
||||||
struct freertos_sockaddr xClient, xBindAddress;
|
struct freertos_sockaddr xClient, xBindAddress;
|
||||||
uint32_t xClientLength = sizeof( xClient );
|
uint32_t xClientLength = sizeof( xClient );
|
||||||
xSocket_t xListeningSocket;
|
xSocket_t xListeningSocket;
|
||||||
|
@ -226,11 +226,11 @@ xSocket_t xListeningSocket;
|
||||||
/* Print the received characters. */
|
/* Print the received characters. */
|
||||||
if( lBytes > 0 )
|
if( lBytes > 0 )
|
||||||
{
|
{
|
||||||
vOutputString( ( char * ) cReceivedString );
|
vOutputString( cReceivedString );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Error check. */
|
/* Error check. */
|
||||||
configASSERT( lBytes == ( portBASE_TYPE ) strlen( ( const char * ) cReceivedString ) );
|
configASSERT( lBytes == ( portBASE_TYPE ) strlen( cReceivedString ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -243,10 +243,10 @@ struct freertos_sockaddr xDestinationAddress;
|
||||||
portBASE_TYPE lReturned;
|
portBASE_TYPE lReturned;
|
||||||
uint32_t ulCount = 0UL, ulIPAddress;
|
uint32_t ulCount = 0UL, ulIPAddress;
|
||||||
const uint32_t ulLoopsPerSocket = 10UL;
|
const uint32_t ulLoopsPerSocket = 10UL;
|
||||||
const uint8_t *pucStringToSend = ( const uint8_t * ) "Server received (using zero copy): Message number ";
|
const char *pcStringToSend = "Server received (using zero copy): Message number ";
|
||||||
const portTickType x150ms = 150UL / portTICK_RATE_MS;
|
const portTickType x150ms = 150UL / portTICK_RATE_MS;
|
||||||
/* 15 is added to ensure the number, \r\n and terminating zero fit. */
|
/* 15 is added to ensure the number, \r\n and terminating zero fit. */
|
||||||
const size_t xStringLength = strlen( ( char * ) pucStringToSend ) + 15;
|
const size_t xStringLength = strlen( pcStringToSend ) + 15;
|
||||||
|
|
||||||
/* Remove compiler warning about unused parameters. */
|
/* Remove compiler warning about unused parameters. */
|
||||||
( void ) pvParameters;
|
( void ) pvParameters;
|
||||||
|
@ -296,7 +296,7 @@ const size_t xStringLength = strlen( ( char * ) pucStringToSend ) + 15;
|
||||||
end. Note that the string is being written directly into the buffer
|
end. Note that the string is being written directly into the buffer
|
||||||
obtained from the IP stack above. */
|
obtained from the IP stack above. */
|
||||||
memset( ( void * ) pucUDPPayloadBuffer, 0x00, xStringLength );
|
memset( ( void * ) pucUDPPayloadBuffer, 0x00, xStringLength );
|
||||||
sprintf( ( char * ) pucUDPPayloadBuffer, "%s%lu\r\n", ( char * ) pucStringToSend, ulCount );
|
sprintf( ( char * ) pucUDPPayloadBuffer, "%s%lu\r\n", pcStringToSend, ulCount );
|
||||||
|
|
||||||
/* Pass the buffer into the send function. ulFlags has the
|
/* Pass the buffer into the send function. ulFlags has the
|
||||||
FREERTOS_ZERO_COPY bit set so the IP stack will take control of the
|
FREERTOS_ZERO_COPY bit set so the IP stack will take control of the
|
||||||
|
|
|
@ -163,7 +163,7 @@ extern const uint8_t ucMACAddress[ 6 ];
|
||||||
|
|
||||||
/* Send the output generated by the command's
|
/* Send the output generated by the command's
|
||||||
implementation. */
|
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. */
|
} while( xMoreDataToFollow != pdFALSE ); /* Until the command does not generate any more output. */
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ static xSocket_t prvCreateDNSSocket( void );
|
||||||
/*
|
/*
|
||||||
* Create the DNS message in the zero copy buffer passed in the first parameter.
|
* Create the DNS message in the zero copy buffer passed in the first parameter.
|
||||||
*/
|
*/
|
||||||
static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const uint8_t *pcHostName, uint16_t usIdentifier );
|
static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const char *pcHostName, uint16_t usIdentifier );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple routine that jumps over the NAME field of a resource record.
|
* Simple routine that jumps over the NAME field of a resource record.
|
||||||
|
@ -128,7 +128,7 @@ typedef struct xDNSMessage xDNSMessage_t;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
uint32_t FreeRTOS_gethostbyname( const uint8_t *pcHostName )
|
uint32_t FreeRTOS_gethostbyname( const char *pcHostName )
|
||||||
{
|
{
|
||||||
static uint16_t usIdentifier = 0;
|
static uint16_t usIdentifier = 0;
|
||||||
struct freertos_sockaddr xAddress;
|
struct freertos_sockaddr xAddress;
|
||||||
|
@ -139,7 +139,7 @@ static uint32_t ulAddressLength;
|
||||||
portBASE_TYPE xAttempt;
|
portBASE_TYPE xAttempt;
|
||||||
int32_t lBytes;
|
int32_t lBytes;
|
||||||
size_t xPayloadLength;
|
size_t xPayloadLength;
|
||||||
const size_t xExpectedPayloadLength = sizeof( xDNSMessage_t ) + strlen( ( const char * const ) pcHostName ) + sizeof( uint16_t ) + sizeof( uint16_t ) + 2; /* Two for the count of characters in the first subdomain part, and the string end byte */
|
const size_t xExpectedPayloadLength = sizeof( xDNSMessage_t ) + strlen( pcHostName ) + sizeof( uint16_t ) + sizeof( uint16_t ) + 2; /* Two for the count of characters in the first subdomain part, and the string end byte */
|
||||||
|
|
||||||
if( xDNSSocket == NULL )
|
if( xDNSSocket == NULL )
|
||||||
{
|
{
|
||||||
|
@ -207,7 +207,7 @@ const size_t xExpectedPayloadLength = sizeof( xDNSMessage_t ) + strlen( ( const
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const uint8_t *pcHostName, uint16_t usIdentifier )
|
static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const char *pcHostName, uint16_t usIdentifier )
|
||||||
{
|
{
|
||||||
xDNSMessage_t *pxDNSMessageHeader;
|
xDNSMessage_t *pxDNSMessageHeader;
|
||||||
uint8_t *pucStart, *pucByte;
|
uint8_t *pucStart, *pucByte;
|
||||||
|
@ -237,10 +237,10 @@ static const xDNSMessage_t xDefaultPartDNSHeader =
|
||||||
pucByte = pucStart + 1;
|
pucByte = pucStart + 1;
|
||||||
|
|
||||||
/* Copy in the host name. */
|
/* Copy in the host name. */
|
||||||
strcpy( ( char * ) pucByte, ( const char * ) pcHostName );
|
strcpy( ( char * ) pucByte, pcHostName );
|
||||||
|
|
||||||
/* Mark the end of the string. */
|
/* Mark the end of the string. */
|
||||||
pucByte += strlen( ( const char * ) pcHostName );
|
pucByte += strlen( pcHostName );
|
||||||
*pucByte = 0x00;
|
*pucByte = 0x00;
|
||||||
|
|
||||||
/* Walk the string to replace the '.' characters with byte counts.
|
/* Walk the string to replace the '.' characters with byte counts.
|
||||||
|
|
|
@ -972,34 +972,34 @@ xListItem *pxIterator, *pxReturn;
|
||||||
|
|
||||||
#if ipconfigINCLUDE_FULL_INET_ADDR == 1
|
#if ipconfigINCLUDE_FULL_INET_ADDR == 1
|
||||||
|
|
||||||
uint32_t FreeRTOS_inet_addr( const uint8_t * pucIPAddress )
|
uint32_t FreeRTOS_inet_addr( const char *pcIPAddress )
|
||||||
{
|
{
|
||||||
const uint8_t ucDecimalBase = 10;
|
const uint8_t ucDecimalBase = 10;
|
||||||
uint8_t ucOctet[ socketMAX_IP_ADDRESS_OCTETS ];
|
uint8_t ucOctet[ socketMAX_IP_ADDRESS_OCTETS ];
|
||||||
const uint8_t *pucPointerOnEntering;
|
const char *pcPointerOnEntering;
|
||||||
uint32_t ulReturn = 0UL, ulOctetNumber, ulValue;
|
uint32_t ulReturn = 0UL, ulOctetNumber, ulValue;
|
||||||
portBASE_TYPE xResult = pdPASS;
|
portBASE_TYPE xResult = pdPASS;
|
||||||
|
|
||||||
for( ulOctetNumber = 0; ulOctetNumber < socketMAX_IP_ADDRESS_OCTETS; ulOctetNumber++ )
|
for( ulOctetNumber = 0; ulOctetNumber < socketMAX_IP_ADDRESS_OCTETS; ulOctetNumber++ )
|
||||||
{
|
{
|
||||||
ulValue = 0;
|
ulValue = 0;
|
||||||
pucPointerOnEntering = pucIPAddress;
|
pcPointerOnEntering = pcIPAddress;
|
||||||
|
|
||||||
while( ( *pucIPAddress >= ( uint8_t ) '0' ) && ( *pucIPAddress <= ( uint8_t ) '9' ) )
|
while( ( *pcIPAddress >= ( uint8_t ) '0' ) && ( *pcIPAddress <= ( uint8_t ) '9' ) )
|
||||||
{
|
{
|
||||||
/* Move previous read characters into the next decimal
|
/* Move previous read characters into the next decimal
|
||||||
position. */
|
position. */
|
||||||
ulValue *= ucDecimalBase;
|
ulValue *= ucDecimalBase;
|
||||||
|
|
||||||
/* Add the binary value of the ascii character. */
|
/* Add the binary value of the ascii character. */
|
||||||
ulValue += ( *pucIPAddress - ( uint8_t ) '0' );
|
ulValue += ( *pcIPAddress - ( uint8_t ) '0' );
|
||||||
|
|
||||||
/* Move to next character in the string. */
|
/* Move to next character in the string. */
|
||||||
pucIPAddress++;
|
pcIPAddress++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check characters were read. */
|
/* Check characters were read. */
|
||||||
if( pucIPAddress == pucPointerOnEntering )
|
if( pcIPAddress == pcPointerOnEntering )
|
||||||
{
|
{
|
||||||
xResult = pdFAIL;
|
xResult = pdFAIL;
|
||||||
}
|
}
|
||||||
|
@ -1016,14 +1016,14 @@ xListItem *pxIterator, *pxReturn;
|
||||||
/* Check the next character is as expected. */
|
/* Check the next character is as expected. */
|
||||||
if( ulOctetNumber < ( socketMAX_IP_ADDRESS_OCTETS - 1 ) )
|
if( ulOctetNumber < ( socketMAX_IP_ADDRESS_OCTETS - 1 ) )
|
||||||
{
|
{
|
||||||
if( *pucIPAddress != ( uint8_t ) '.' )
|
if( *pcIPAddress != ( uint8_t ) '.' )
|
||||||
{
|
{
|
||||||
xResult = pdFAIL;
|
xResult = pdFAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Move past the dot. */
|
/* Move past the dot. */
|
||||||
pucIPAddress++;
|
pcIPAddress++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1035,7 @@ xListItem *pxIterator, *pxReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *pucIPAddress != ( uint8_t ) 0x00 )
|
if( *pcIPAddress != ( uint8_t ) 0x00 )
|
||||||
{
|
{
|
||||||
/* Expected the end of the string. */
|
/* Expected the end of the string. */
|
||||||
xResult = pdFAIL;
|
xResult = pdFAIL;
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
* FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
|
* FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
|
||||||
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/FreeRTOS_UDP_API_Functions.shtml
|
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/FreeRTOS_UDP_API_Functions.shtml
|
||||||
*/
|
*/
|
||||||
uint32_t FreeRTOS_gethostbyname( const uint8_t *pcHostName );
|
uint32_t FreeRTOS_gethostbyname( const char *pcHostName );
|
||||||
|
|
||||||
#endif /* FREERTOS_DNS_H */
|
#endif /* FREERTOS_DNS_H */
|
||||||
|
|
||||||
|
|
|
@ -154,8 +154,8 @@ int32_t FreeRTOS_sendto( xSocket_t xSocket, const void *pvBuffer, size_t xTotalD
|
||||||
portBASE_TYPE FreeRTOS_bind( xSocket_t xSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength );
|
portBASE_TYPE FreeRTOS_bind( xSocket_t xSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength );
|
||||||
portBASE_TYPE FreeRTOS_setsockopt( xSocket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength );
|
portBASE_TYPE FreeRTOS_setsockopt( xSocket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength );
|
||||||
portBASE_TYPE FreeRTOS_closesocket( xSocket_t xSocket );
|
portBASE_TYPE FreeRTOS_closesocket( xSocket_t xSocket );
|
||||||
uint32_t FreeRTOS_gethostbyname( const uint8_t *pcHostName );
|
uint32_t FreeRTOS_gethostbyname( const char *pcHostName );
|
||||||
uint32_t FreeRTOS_inet_addr( const uint8_t * pucIPAddress );
|
uint32_t FreeRTOS_inet_addr( const char *pcIPAddress );
|
||||||
|
|
||||||
#if ipconfigSUPPORT_SELECT_FUNCTION == 1
|
#if ipconfigSUPPORT_SELECT_FUNCTION == 1
|
||||||
xSocketSet_t FreeRTOS_CreateSocketSet( unsigned portBASE_TYPE uxEventQueueLength );
|
xSocketSet_t FreeRTOS_CreateSocketSet( unsigned portBASE_TYPE uxEventQueueLength );
|
||||||
|
|
|
@ -244,7 +244,7 @@ size_t xColumns = 50U;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to open the requested file. */
|
/* Attempt to open the requested file. */
|
||||||
pxFile = f_open( ( const char * ) pcParameter, "r" );
|
pxFile = f_open( pcParameter, "r" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
|
@ -406,7 +406,7 @@ unsigned char ucReturned;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to delete the file. */
|
/* Attempt to delete the file. */
|
||||||
ucReturned = f_delete( ( const char * ) pcParameter );
|
ucReturned = f_delete( pcParameter );
|
||||||
|
|
||||||
if( ucReturned == F_NO_ERROR )
|
if( ucReturned == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
|
@ -455,7 +455,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
pcSourceFile[ xParameterStringLength ] = 0x00;
|
pcSourceFile[ xParameterStringLength ] = 0x00;
|
||||||
|
|
||||||
/* See if the source file exists, obtain its length if it does. */
|
/* 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 )
|
if( lSourceLength == 0 )
|
||||||
{
|
{
|
||||||
|
@ -464,7 +464,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* See if the destination file exists. */
|
/* See if the destination file exists. */
|
||||||
lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );
|
lDestinationLength = f_filelength( pcDestinationFile );
|
||||||
|
|
||||||
if( lDestinationLength != 0 )
|
if( lDestinationLength != 0 )
|
||||||
{
|
{
|
||||||
|
@ -523,7 +523,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
/* Open the source file, seek past the data that has already been
|
/* 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
|
read from the file, read the next block of data, then close the
|
||||||
file again so the destination file can be opened. */
|
file again so the destination file can be opened. */
|
||||||
pxFile = f_open( ( const char * ) pcSourceFile, "r" );
|
pxFile = f_open( pcSourceFile, "r" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
||||||
|
@ -538,7 +538,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
|
|
||||||
/* Open the destination file and write the block of data to the end of
|
/* Open the destination file and write the block of data to the end of
|
||||||
the file. */
|
the file. */
|
||||||
pxFile = f_open( ( const char * ) pcDestinationFile, "a" );
|
pxFile = f_open( pcDestinationFile, "a" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
||||||
|
|
|
@ -302,7 +302,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "In directory %s\r\n", cRAMBuffer );
|
printf( "In directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
@ -331,7 +331,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcRoot ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in directory %s\r\n", cRAMBuffer );
|
printf( "Back in directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
|
@ -405,7 +405,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
@ -414,7 +414,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
sprintf( 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 )
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* End the trace, if one is running. */
|
/* End the trace, if one is running. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -348,7 +348,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
|
@ -399,7 +399,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
@ -408,7 +408,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
sprintf( 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 )
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* End the trace, if one is running. */
|
/* End the trace, if one is running. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
|
|
|
@ -178,7 +178,7 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s
|
||||||
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
||||||
|
|
||||||
/* Send the welcome message. */
|
/* Send the welcome message. */
|
||||||
prvSendBuffer( &xCDCUsart, pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );
|
prvSendBuffer( &xCDCUsart, pcWelcomeMessage, strlen( pcWelcomeMessage ) );
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
|
@ -201,7 +201,7 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s
|
||||||
if( ucInputIndex == 0 )
|
if( ucInputIndex == 0 )
|
||||||
{
|
{
|
||||||
/* Copy the last command back into the input string. */
|
/* Copy the last command back into the input string. */
|
||||||
strcpy( ( char * ) cInputString, ( char * ) cLastInputString );
|
strcpy( cInputString, cLastInputString );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass the received command to the command interpreter. The
|
/* Pass the received command to the command interpreter. The
|
||||||
|
@ -222,11 +222,11 @@ static struct usart_module xCDCUsart; /* Static so it doesn't take up too much s
|
||||||
Clear the input string ready to receive the next command. Remember
|
Clear the input string ready to receive the next command. Remember
|
||||||
the command that was just processed first in case it is to be
|
the command that was just processed first in case it is to be
|
||||||
processed again. */
|
processed again. */
|
||||||
strcpy( ( char * ) cLastInputString, ( char * ) cInputString );
|
strcpy( cLastInputString, cInputString );
|
||||||
ucInputIndex = 0;
|
ucInputIndex = 0;
|
||||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
|
|
||||||
prvSendBuffer( &xCDCUsart, pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
|
prvSendBuffer( &xCDCUsart, pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[InternetShortcut]
|
||||||
|
URL=http://www.freertos.org/Atmel_SAM4E_RTOS_Demo.html
|
||||||
|
IDList=
|
||||||
|
[{000214A0-0000-0000-C000-000000000046}]
|
||||||
|
Prop3=19,2
|
|
@ -72,7 +72,7 @@
|
||||||
* executed prior to this project being built. Once it has been executed
|
* executed prior to this project being built. Once it has been executed
|
||||||
* remove the #error line below.
|
* remove the #error line below.
|
||||||
*/
|
*/
|
||||||
#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.
|
//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set configCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
|
* Set configCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
|
||||||
|
|
|
@ -238,7 +238,7 @@ size_t xColumns = 50U;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to open the requested file. */
|
/* Attempt to open the requested file. */
|
||||||
pxFile = f_open( ( const char * ) pcParameter, "r" );
|
pxFile = f_open( pcParameter, "r" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
|
@ -400,7 +400,7 @@ unsigned char ucReturned;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* Attempt to delete the file. */
|
/* Attempt to delete the file. */
|
||||||
ucReturned = f_delete( ( const char * ) pcParameter );
|
ucReturned = f_delete( pcParameter );
|
||||||
|
|
||||||
if( ucReturned == F_NO_ERROR )
|
if( ucReturned == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
|
@ -436,7 +436,7 @@ long lSourceLength, lDestinationLength = 0;
|
||||||
configASSERT( pcDestinationFile );
|
configASSERT( pcDestinationFile );
|
||||||
|
|
||||||
/* Obtain the name of the source file. */
|
/* Obtain the name of the source file. */
|
||||||
pcSourceFile = FreeRTOS_CLIGetParameter
|
pcSourceFile = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
1, /* Return the first parameter. */
|
1, /* Return the first parameter. */
|
||||||
|
@ -518,7 +518,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
/* Open the source file, seek past the data that has already been
|
/* 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
|
read from the file, read the next block of data, then close the
|
||||||
file again so the destination file can be opened. */
|
file again so the destination file can be opened. */
|
||||||
pxFile = f_open( ( const char * ) pcSourceFile, "r" );
|
pxFile = f_open( pcSourceFile, "r" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
f_seek( pxFile, lBytesRead, F_SEEK_SET );
|
||||||
|
@ -533,7 +533,7 @@ portBASE_TYPE xReturn = pdPASS;
|
||||||
|
|
||||||
/* Open the destination file and write the block of data to the end of
|
/* Open the destination file and write the block of data to the end of
|
||||||
the file. */
|
the file. */
|
||||||
pxFile = f_open( ( const char * ) pcDestinationFile, "a" );
|
pxFile = f_open( pcDestinationFile, "a" );
|
||||||
if( pxFile != NULL )
|
if( pxFile != NULL )
|
||||||
{
|
{
|
||||||
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );
|
||||||
|
|
|
@ -302,7 +302,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "In directory %s\r\n", cRAMBuffer );
|
printf( "In directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
@ -331,7 +331,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
printf( "Back in root directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcRoot ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
printf( "Back in directory %s\r\n", cRAMBuffer );
|
printf( "Back in directory %s\r\n", cRAMBuffer );
|
||||||
configASSERT( strcmp( ( const char * ) cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
|
@ -209,8 +209,8 @@ const char *const pcHeader = "Task State Priority Stack #\r\n********
|
||||||
configASSERT( pcWriteBuffer );
|
configASSERT( pcWriteBuffer );
|
||||||
|
|
||||||
/* Generate a table of task stats. */
|
/* Generate a table of task stats. */
|
||||||
strcpy( ( char * ) pcWriteBuffer, pcHeader );
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
vTaskList( ( char * ) pcWriteBuffer + strlen( pcHeader ) );
|
vTaskList( pcWriteBuffer + strlen( pcHeader ) );
|
||||||
|
|
||||||
/* There is no more data to return after this single string, so return
|
/* There is no more data to return after this single string, so return
|
||||||
pdFALSE. */
|
pdFALSE. */
|
||||||
|
@ -230,7 +230,7 @@ const char * const pcHeader = "Task Abs Time % Time\r\n*********
|
||||||
configASSERT( pcWriteBuffer );
|
configASSERT( pcWriteBuffer );
|
||||||
|
|
||||||
/* Generate a table of task stats. */
|
/* Generate a table of task stats. */
|
||||||
strcpy( ( char * ) pcWriteBuffer, pcHeader );
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
vTaskGetRunTimeStats( ( char * ) pcWriteBuffer + strlen( pcHeader ) );
|
vTaskGetRunTimeStats( ( char * ) pcWriteBuffer + strlen( pcHeader ) );
|
||||||
|
|
||||||
/* There is no more data to return after this single string, so return
|
/* There is no more data to return after this single string, so return
|
||||||
|
@ -241,7 +241,7 @@ const char * const pcHeader = "Task Abs Time % Time\r\n*********
|
||||||
|
|
||||||
static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
static portBASE_TYPE prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||||
{
|
{
|
||||||
int8_t *pcParameter;
|
const char *pcParameter;
|
||||||
portBASE_TYPE xParameterStringLength, xReturn;
|
portBASE_TYPE xParameterStringLength, xReturn;
|
||||||
static portBASE_TYPE lParameterNumber = 0;
|
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
|
/* The first time the function is called after the command has been
|
||||||
entered just a header string is returned. */
|
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
|
/* Next time the function is called the first parameter will be echoed
|
||||||
back. */
|
back. */
|
||||||
|
@ -269,7 +269,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Obtain the parameter string. */
|
/* Obtain the parameter string. */
|
||||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
lParameterNumber, /* Return the next parameter. */
|
lParameterNumber, /* Return the next parameter. */
|
||||||
|
@ -281,9 +281,9 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* If this is the last of the three parameters then there are no more
|
/* If this is the last of the three parameters then there are no more
|
||||||
strings to return after this one. */
|
strings to return after this one. */
|
||||||
|
@ -308,7 +308,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
static portBASE_TYPE prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
static portBASE_TYPE prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||||
{
|
{
|
||||||
int8_t *pcParameter;
|
const char *pcParameter;
|
||||||
portBASE_TYPE xParameterStringLength, xReturn;
|
portBASE_TYPE xParameterStringLength, xReturn;
|
||||||
static portBASE_TYPE lParameterNumber = 0;
|
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
|
/* The first time the function is called after the command has been
|
||||||
entered just a header string is returned. */
|
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
|
/* Next time the function is called the first parameter will be echoed
|
||||||
back. */
|
back. */
|
||||||
|
@ -336,7 +336,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Obtain the parameter string. */
|
/* Obtain the parameter string. */
|
||||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
lParameterNumber, /* Return the next parameter. */
|
lParameterNumber, /* Return the next parameter. */
|
||||||
|
@ -347,9 +347,9 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
{
|
{
|
||||||
/* Return the parameter string. */
|
/* Return the parameter string. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||||
strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||||
strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* There might be more parameters to return after this one. */
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
|
@ -377,7 +377,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
|
|
||||||
static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
static portBASE_TYPE prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
||||||
{
|
{
|
||||||
int8_t *pcParameter;
|
const char *pcParameter;
|
||||||
portBASE_TYPE lParameterStringLength;
|
portBASE_TYPE lParameterStringLength;
|
||||||
|
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
|
@ -388,7 +388,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcWriteBuffer );
|
configASSERT( pcWriteBuffer );
|
||||||
|
|
||||||
/* Obtain the parameter string. */
|
/* Obtain the parameter string. */
|
||||||
pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
(
|
(
|
||||||
pcCommandString, /* The command string itself. */
|
pcCommandString, /* The command string itself. */
|
||||||
1, /* Return the first parameter. */
|
1, /* Return the first parameter. */
|
||||||
|
@ -399,24 +399,24 @@ static portBASE_TYPE lParameterNumber = 0;
|
||||||
configASSERT( pcParameter );
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
/* There are only two valid parameter values. */
|
/* 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. */
|
/* Start or restart the trace. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
vTraceClear();
|
vTraceClear();
|
||||||
vTraceStart();
|
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 )
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
{
|
{
|
||||||
/* End the trace, if one is running. */
|
/* End the trace, if one is running. */
|
||||||
vTraceStop();
|
vTraceStop();
|
||||||
sprintf( ( char * ) pcWriteBuffer, "Stopping trace recording.\r\n" );
|
sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" );
|
||||||
}
|
}
|
||||||
else
|
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
|
/* There is no more data to return after this single string, so return
|
||||||
|
|
|
@ -165,7 +165,7 @@ portBASE_TYPE xReturned;
|
||||||
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
||||||
|
|
||||||
/* Send the welcome message. */
|
/* Send the welcome message. */
|
||||||
prvSendBuffer( pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );
|
prvSendBuffer( pcWelcomeMessage, strlen( pcWelcomeMessage ) );
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
|
@ -179,14 +179,14 @@ portBASE_TYPE xReturned;
|
||||||
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
||||||
{
|
{
|
||||||
/* Just to space the output from the input. */
|
/* Just to space the output from the input. */
|
||||||
prvSendBuffer( pcNewLine, strlen( ( char * ) pcNewLine ) );
|
prvSendBuffer( pcNewLine, strlen( pcNewLine ) );
|
||||||
|
|
||||||
/* See if the command is empty, indicating that the last command is
|
/* See if the command is empty, indicating that the last command is
|
||||||
to be executed again. */
|
to be executed again. */
|
||||||
if( cInputIndex == 0 )
|
if( cInputIndex == 0 )
|
||||||
{
|
{
|
||||||
/* Copy the last command back into the input string. */
|
/* Copy the last command back into the input string. */
|
||||||
strcpy( ( char * ) cInputString, ( char * ) cLastInputString );
|
strcpy( cInputString, cLastInputString );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass the received command to the command interpreter. The
|
/* Pass the received command to the command interpreter. The
|
||||||
|
@ -207,11 +207,11 @@ portBASE_TYPE xReturned;
|
||||||
Clear the input string ready to receive the next command. Remember
|
Clear the input string ready to receive the next command. Remember
|
||||||
the command that was just processed first in case it is to be
|
the command that was just processed first in case it is to be
|
||||||
processed again. */
|
processed again. */
|
||||||
strcpy( ( char * ) cLastInputString, ( char * ) cInputString );
|
strcpy( cLastInputString, cInputString );
|
||||||
cInputIndex = 0;
|
cInputIndex = 0;
|
||||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
|
|
||||||
prvSendBuffer( pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
|
prvSendBuffer( pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue