mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -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
32 changed files with 304 additions and 297 deletions
|
@ -333,7 +333,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
/* Return the parameter string. */
|
||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
||||
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||
|
||||
/* If this is the last of the three parameters then there are no more
|
||||
|
@ -399,7 +399,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
/* Return the parameter string. */
|
||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||
sprintf( pcWriteBuffer, "%d: ", ( int ) lParameterNumber );
|
||||
strncat( pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );
|
||||
strncat( pcWriteBuffer, pcParameter, xParameterStringLength );
|
||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||
|
||||
/* There might be more parameters to return after this one. */
|
||||
|
@ -459,7 +459,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
}
|
||||
else
|
||||
{
|
||||
ulBytesToPing = atol( ( const char * ) pcParameter );
|
||||
ulBytesToPing = atol( pcParameter );
|
||||
}
|
||||
|
||||
/* Obtain the IP address string. */
|
||||
|
@ -477,7 +477,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
digit, assume the host name has been passed in. */
|
||||
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
||||
{
|
||||
ulIPAddress = FreeRTOS_inet_addr( ( const uint8_t * ) pcParameter );
|
||||
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -485,7 +485,7 @@ static portBASE_TYPE lParameterNumber = 0;
|
|||
pcParameter[ lParameterStringLength ] = 0x00;
|
||||
|
||||
/* Attempt to resolve host. */
|
||||
ulIPAddress = FreeRTOS_gethostbyname( ( uint8_t * ) pcParameter );
|
||||
ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
|
||||
}
|
||||
|
||||
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
||||
|
@ -639,7 +639,7 @@ uint32_t ulAddress;
|
|||
configASSERT( pcParameter );
|
||||
|
||||
/* There are only two valid parameter values. */
|
||||
if( strncmp( ( const char * ) pcParameter, "start", strlen( "start" ) ) == 0 )
|
||||
if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
|
||||
{
|
||||
/* Start or restart the trace. */
|
||||
vTraceStop();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -108,7 +108,7 @@ void vStartUDPCommandInterpreterTask( uint16_t usStackSize, uint32_t ulPort, uns
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Task that provides the input and output for the FreeRTOS+CLI command
|
||||
* interpreter. In this case a UDP port is used. See the URL in the comments
|
||||
* within main.c for the location of the online documentation.
|
||||
|
@ -117,7 +117,7 @@ void vUDPCommandInterpreterTask( void *pvParameters )
|
|||
{
|
||||
long lBytes, lByte;
|
||||
signed char cInChar, cInputIndex = 0;
|
||||
static signed char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ], cLocalBuffer[ cmdSOCKET_INPUT_BUFFER_SIZE ];
|
||||
static char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ], cLocalBuffer[ cmdSOCKET_INPUT_BUFFER_SIZE ];
|
||||
portBASE_TYPE xMoreDataToFollow;
|
||||
struct freertos_sockaddr xClient;
|
||||
socklen_t xClientAddressLength = 0; /* This is required as a parameter to maintain the sendto() Berkeley sockets API - but it is not actually used so can take any value. */
|
||||
|
@ -152,25 +152,25 @@ xSocket_t xSocket;
|
|||
string. */
|
||||
if( cInChar == '\n' )
|
||||
{
|
||||
/* Process the input string received prior to the
|
||||
/* Process the input string received prior to the
|
||||
newline. */
|
||||
do
|
||||
{
|
||||
/* Pass the string to FreeRTOS+CLI. */
|
||||
xMoreDataToFollow = FreeRTOS_CLIProcessCommand( cInputString, cOutputString, cmdMAX_OUTPUT_SIZE );
|
||||
|
||||
|
||||
/* Send the output generated by the command's
|
||||
implementation. */
|
||||
FreeRTOS_sendto( xSocket, cOutputString, strlen( ( const char * ) cOutputString ), 0, &xClient, xClientAddressLength );
|
||||
FreeRTOS_sendto( xSocket, cOutputString, strlen( cOutputString ), 0, &xClient, xClientAddressLength );
|
||||
|
||||
} while( xMoreDataToFollow != pdFALSE ); /* Until the command does not generate any more output. */
|
||||
|
||||
/* All the strings generated by the command processing
|
||||
have been sent. Clear the input string ready to receive
|
||||
/* All the strings generated by the command processing
|
||||
have been sent. Clear the input string ready to receive
|
||||
the next command. */
|
||||
cInputIndex = 0;
|
||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||
|
||||
|
||||
/* Transmit a spacer, just to make the command console
|
||||
easier to read. */
|
||||
FreeRTOS_sendto( xSocket, "\r\n", strlen( "\r\n" ), 0, &xClient, xClientAddressLength );
|
||||
|
@ -179,12 +179,12 @@ xSocket_t xSocket;
|
|||
{
|
||||
if( cInChar == '\r' )
|
||||
{
|
||||
/* Ignore the character. Newlines are used to
|
||||
/* Ignore the character. Newlines are used to
|
||||
detect the end of the input string. */
|
||||
}
|
||||
else if( cInChar == '\b' )
|
||||
{
|
||||
/* Backspace was pressed. Erase the last character
|
||||
/* Backspace was pressed. Erase the last character
|
||||
in the string - if any. */
|
||||
if( cInputIndex > 0 )
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ xSocket_t xSocket;
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ xSocket_t xSocket = FREERTOS_INVALID_SOCKET;
|
|||
|
||||
/* Bind the address to the socket. */
|
||||
if( FreeRTOS_bind( xSocket, &xServer, sizeof( xServer ) ) == -1 )
|
||||
{
|
||||
{
|
||||
FreeRTOS_closesocket( xSocket );
|
||||
xSocket = FREERTOS_INVALID_SOCKET;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ static void prvEchoClientTask( void *pvParameters )
|
|||
{
|
||||
xSocket_t xSocket;
|
||||
struct freertos_sockaddr xEchoServerAddress;
|
||||
int8_t cTxString[ 25 ], cRxString[ 25 ]; /* Make sure the stack is large enough to hold these. Turn on stack overflow checking during debug to be sure. */
|
||||
char cTxString[ 25 ], cRxString[ 25 ]; /* Make sure the stack is large enough to hold these. Turn on stack overflow checking during debug to be sure. */
|
||||
int32_t lLoopCount = 0UL;
|
||||
const int32_t lMaxLoopCount = 50;
|
||||
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
||||
|
@ -188,7 +188,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
|||
for( lLoopCount = 0; lLoopCount < lMaxLoopCount; lLoopCount++ )
|
||||
{
|
||||
/* Create the string that is sent to the echo server. */
|
||||
sprintf( ( char * ) cTxString, "Message number %u\r\n", ( unsigned int ) ulTxCount );
|
||||
sprintf( cTxString, "Message number %u\r\n", ( unsigned int ) ulTxCount );
|
||||
|
||||
/* Send the string to the socket. ulFlags is set to 0, so the zero
|
||||
copy interface is not used. That means the data from cTxString is
|
||||
|
@ -197,7 +197,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
|||
to ensure the NULL string terminator is sent as part of the message. */
|
||||
FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
||||
( void * ) cTxString, /* The data being sent. */
|
||||
strlen( ( const char * ) cTxString ) + 1, /* The length of the data being sent. */
|
||||
strlen( cTxString ) + 1,/* The length of the data being sent. */
|
||||
0, /* ulFlags with the FREERTOS_ZERO_COPY bit clear. */
|
||||
&xEchoServerAddress, /* The destination address. */
|
||||
sizeof( xEchoServerAddress ) );
|
||||
|
@ -223,7 +223,7 @@ uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
|||
&xAddressLength );
|
||||
|
||||
/* Compare the transmitted string to the received string. */
|
||||
if( strcmp( ( char * ) cRxString, ( char * ) cTxString ) == 0 )
|
||||
if( strcmp( cRxString, cTxString ) == 0 )
|
||||
{
|
||||
/* The echo reply was received without error. */
|
||||
ulRxCount++;
|
||||
|
@ -244,7 +244,7 @@ static void prvZeroCopyEchoClientTask( void *pvParameters )
|
|||
{
|
||||
xSocket_t xSocket;
|
||||
struct freertos_sockaddr xEchoServerAddress;
|
||||
static int8_t cTxString[ 40 ];
|
||||
static char cTxString[ 40 ];
|
||||
int32_t lLoopCount = 0UL;
|
||||
volatile uint32_t ulRxCount = 0UL, ulTxCount = 0UL;
|
||||
uint32_t xAddressLength = sizeof( xEchoServerAddress );
|
||||
|
@ -252,9 +252,9 @@ int32_t lReturned;
|
|||
uint8_t *pucUDPPayloadBuffer;
|
||||
|
||||
const int32_t lMaxLoopCount = 50;
|
||||
const uint8_t * const pucStringToSend = ( const uint8_t * const ) "Zero copy message number";
|
||||
const char * const pcStringToSend = "Zero copy message number";
|
||||
/* The buffer is large enough to hold the string, a number, and the string terminator. */
|
||||
const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
|
||||
const size_t xBufferLength = strlen( pcStringToSend ) + 15;
|
||||
|
||||
#if ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1
|
||||
{
|
||||
|
@ -309,11 +309,11 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
|
|||
/* A buffer was successfully obtained. Create the string that is
|
||||
sent to the echo server. Note the string is written directly
|
||||
into the buffer obtained from the IP stack. */
|
||||
sprintf( ( char * ) pucUDPPayloadBuffer, "%s %u\r\n", ( const char * ) "Zero copy message number", ( unsigned int ) ulTxCount );
|
||||
sprintf( ( char * ) pucUDPPayloadBuffer, "%s %u\r\n", "Zero copy message number", ( unsigned int ) ulTxCount );
|
||||
|
||||
/* Also copy the string into a local buffer so it can be compared
|
||||
with the string that is later received back from the echo server. */
|
||||
strcpy( ( char * ) cTxString, ( char * ) pucUDPPayloadBuffer );
|
||||
strcpy( cTxString, ( char * ) pucUDPPayloadBuffer );
|
||||
|
||||
/* Pass the buffer into the send function. ulFlags has the
|
||||
FREERTOS_ZERO_COPY bit set so the IP stack will take control of
|
||||
|
@ -321,7 +321,7 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
|
|||
echoMARK_SEND_IN_TRACE_BUFFER( xZeroCopySendEvent );
|
||||
lReturned = FreeRTOS_sendto( xSocket, /* The socket being sent to. */
|
||||
( void * ) pucUDPPayloadBuffer, /* The buffer being passed into the IP stack. */
|
||||
strlen( ( const char * ) cTxString ) + 1, /* The length of the data being sent. Plus 1 to ensure the null terminator is part of the data. */
|
||||
strlen( cTxString ) + 1, /* The length of the data being sent. Plus 1 to ensure the null terminator is part of the data. */
|
||||
FREERTOS_ZERO_COPY, /* ulFlags with the zero copy bit is set. */
|
||||
&xEchoServerAddress, /* Where the data is being sent. */
|
||||
sizeof( xEchoServerAddress ) );
|
||||
|
@ -372,7 +372,7 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
|
|||
{
|
||||
/* Compare the string sent to the echo server with the string
|
||||
received back from the echo server. */
|
||||
if( strcmp( ( char * ) pucUDPPayloadBuffer, ( char * ) cTxString ) == 0 )
|
||||
if( strcmp( ( char * ) pucUDPPayloadBuffer, cTxString ) == 0 )
|
||||
{
|
||||
/* The strings matched. */
|
||||
ulRxCount++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue