Added EchoServer
This commit is contained in:
parent
90e1f84f8e
commit
4896902361
|
|
@ -0,0 +1,288 @@
|
||||||
|
/*
|
||||||
|
FreeRTOS V202212.00
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||||
|
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||||
|
>>! obliged to provide the source code for proprietary components !<<
|
||||||
|
>>! outside of the FreeRTOS kernel. !<<
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||||
|
link: http://www.freertos.org/a00114.html
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS provides completely free yet professionally developed, *
|
||||||
|
* robust, strictly quality controlled, supported, and cross *
|
||||||
|
* platform software that is more than just the market leader, it *
|
||||||
|
* is the industry's de facto standard. *
|
||||||
|
* *
|
||||||
|
* Help yourself get started quickly while simultaneously helping *
|
||||||
|
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||||
|
* tutorial book, reference manual, or both: *
|
||||||
|
* http://www.FreeRTOS.org/Documentation *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||||
|
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||||
|
defined configASSERT()?
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||||
|
embedded software for free we request you assist our global community by
|
||||||
|
participating in the support forum.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||||
|
be as productive as possible as early as possible. Now you can receive
|
||||||
|
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||||
|
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||||
|
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||||
|
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||||
|
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||||
|
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||||
|
licenses offer ticketed support, indemnification and commercial middleware.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||||
|
engineered and independently SIL3 certified version for use in safety and
|
||||||
|
mission critical applications that require provable dependability.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FreeRTOS tasks are used with FreeRTOS+TCP to create a TCP echo server on the
|
||||||
|
* standard echo port number (7).
|
||||||
|
*
|
||||||
|
* See the following web page for essential demo usage and configuration
|
||||||
|
* details:
|
||||||
|
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Server.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
|
||||||
|
/* FreeRTOS+TCP includes. */
|
||||||
|
#include "FreeRTOS_IP.h"
|
||||||
|
#include "FreeRTOS_Sockets.h"
|
||||||
|
|
||||||
|
/* Remove the whole file if FreeRTOSIPConfig.h is set to exclude TCP. */
|
||||||
|
#if( ipconfigUSE_TCP == 1 )
|
||||||
|
|
||||||
|
/* The maximum time to wait for a closing socket to close. */
|
||||||
|
#define tcpechoSHUTDOWN_DELAY ( pdMS_TO_TICKS( 5000 ) )
|
||||||
|
|
||||||
|
/* The standard echo port number. */
|
||||||
|
#define tcpechoPORT_NUMBER 7
|
||||||
|
|
||||||
|
/* If ipconfigUSE_TCP_WIN is 1 then the Tx sockets will use a buffer size set by
|
||||||
|
ipconfigTCP_TX_BUFFER_LENGTH, and the Tx window size will be
|
||||||
|
configECHO_SERVER_TX_WINDOW_SIZE times the buffer size. Note
|
||||||
|
ipconfigTCP_TX_BUFFER_LENGTH is set in FreeRTOSIPConfig.h as it is a standard TCP/IP
|
||||||
|
stack constant, whereas configECHO_SERVER_TX_WINDOW_SIZE is set in
|
||||||
|
FreeRTOSConfig.h as it is a demo application constant. */
|
||||||
|
#ifndef configECHO_SERVER_TX_WINDOW_SIZE
|
||||||
|
#define configECHO_SERVER_TX_WINDOW_SIZE 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If ipconfigUSE_TCP_WIN is 1 then the Rx sockets will use a buffer size set by
|
||||||
|
ipconfigTCP_RX_BUFFER_LENGTH, and the Rx window size will be
|
||||||
|
configECHO_SERVER_RX_WINDOW_SIZE times the buffer size. Note
|
||||||
|
ipconfigTCP_RX_BUFFER_LENGTH is set in FreeRTOSIPConfig.h as it is a standard TCP/IP
|
||||||
|
stack constant, whereas configECHO_SERVER_RX_WINDOW_SIZE is set in
|
||||||
|
FreeRTOSConfig.h as it is a demo application constant. */
|
||||||
|
#ifndef configECHO_SERVER_RX_WINDOW_SIZE
|
||||||
|
#define configECHO_SERVER_RX_WINDOW_SIZE 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses FreeRTOS+TCP to listen for incoming echo connections, creating a task
|
||||||
|
* to handle each connection.
|
||||||
|
*/
|
||||||
|
static void prvConnectionListeningTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created by the connection listening task to handle a single connection.
|
||||||
|
*/
|
||||||
|
static void prvServerConnectionInstance( void *pvParameters );
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Stores the stack size passed into vStartSimpleTCPServerTasks() so it can be
|
||||||
|
reused when the server listening task creates tasks to handle connections. */
|
||||||
|
static uint16_t usUsedStackSize = 0;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vStartSimpleTCPServerTasks( uint16_t usStackSize, UBaseType_t uxPriority )
|
||||||
|
{
|
||||||
|
/* Create the TCP echo server. */
|
||||||
|
xTaskCreate( prvConnectionListeningTask, "ServerListener", usStackSize, NULL, uxPriority + 1, NULL );
|
||||||
|
|
||||||
|
/* Remember the requested stack size so it can be re-used by the server
|
||||||
|
listening task when it creates tasks to handle connections. */
|
||||||
|
usUsedStackSize = usStackSize;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvConnectionListeningTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
struct freertos_sockaddr xClient, xBindAddress;
|
||||||
|
Socket_t xListeningSocket, xConnectedSocket;
|
||||||
|
socklen_t xSize = sizeof( xClient );
|
||||||
|
static const TickType_t xReceiveTimeOut = portMAX_DELAY;
|
||||||
|
const BaseType_t xBacklog = 20;
|
||||||
|
|
||||||
|
#if( ipconfigUSE_TCP_WIN == 1 )
|
||||||
|
WinProperties_t xWinProps;
|
||||||
|
|
||||||
|
/* Fill in the buffer and window sizes that will be used by the socket. */
|
||||||
|
xWinProps.lTxBufSize = ipconfigTCP_TX_BUFFER_LENGTH;
|
||||||
|
xWinProps.lTxWinSize = configECHO_SERVER_TX_WINDOW_SIZE;
|
||||||
|
xWinProps.lRxBufSize = ipconfigTCP_RX_BUFFER_LENGTH;
|
||||||
|
xWinProps.lRxWinSize = configECHO_SERVER_RX_WINDOW_SIZE;
|
||||||
|
#endif /* ipconfigUSE_TCP_WIN */
|
||||||
|
|
||||||
|
/* Just to prevent compiler warnings. */
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* Attempt to open the socket. */
|
||||||
|
xListeningSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
||||||
|
configASSERT( xListeningSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* Set a time out so accept() will just wait for a connection. */
|
||||||
|
FreeRTOS_setsockopt( xListeningSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
|
||||||
|
|
||||||
|
/* Set the window and buffer sizes. */
|
||||||
|
#if( ipconfigUSE_TCP_WIN == 1 )
|
||||||
|
{
|
||||||
|
FreeRTOS_setsockopt( xListeningSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) );
|
||||||
|
}
|
||||||
|
#endif /* ipconfigUSE_TCP_WIN */
|
||||||
|
|
||||||
|
/* Bind the socket to the port that the client task will send to, then
|
||||||
|
listen for incoming connections. */
|
||||||
|
xBindAddress.sin_port = tcpechoPORT_NUMBER;
|
||||||
|
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
||||||
|
FreeRTOS_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
|
||||||
|
FreeRTOS_listen( xListeningSocket, xBacklog );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Wait for a client to connect. */
|
||||||
|
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
|
||||||
|
configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* Spawn a task to handle the connection. */
|
||||||
|
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY, NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvServerConnectionInstance( void *pvParameters )
|
||||||
|
{
|
||||||
|
int32_t lBytes, lSent, lTotalSent;
|
||||||
|
Socket_t xConnectedSocket;
|
||||||
|
static const TickType_t xReceiveTimeOut = pdMS_TO_TICKS( 5000 );
|
||||||
|
static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 5000 );
|
||||||
|
TickType_t xTimeOnShutdown;
|
||||||
|
uint8_t *pucRxBuffer;
|
||||||
|
|
||||||
|
xConnectedSocket = ( Socket_t ) pvParameters;
|
||||||
|
|
||||||
|
/* Attempt to create the buffer used to receive the string to be echoed
|
||||||
|
back. This could be avoided using a zero copy interface that just returned
|
||||||
|
the same buffer. */
|
||||||
|
pucRxBuffer = ( uint8_t * ) pvPortMalloc( ipconfigTCP_MSS );
|
||||||
|
|
||||||
|
if( pucRxBuffer != NULL )
|
||||||
|
{
|
||||||
|
FreeRTOS_setsockopt( xConnectedSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
|
||||||
|
FreeRTOS_setsockopt( xConnectedSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xReceiveTimeOut ) );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Zero out the receive array so there is NULL at the end of the string
|
||||||
|
when it is printed out. */
|
||||||
|
memset( pucRxBuffer, 0x00, ipconfigTCP_MSS );
|
||||||
|
|
||||||
|
/* Receive data on the socket. */
|
||||||
|
lBytes = FreeRTOS_recv( xConnectedSocket, pucRxBuffer, ipconfigTCP_MSS, 0 );
|
||||||
|
|
||||||
|
/* If data was received, echo it back. */
|
||||||
|
if( lBytes >= 0 )
|
||||||
|
{
|
||||||
|
lSent = 0;
|
||||||
|
lTotalSent = 0;
|
||||||
|
|
||||||
|
/* Call send() until all the data has been sent. */
|
||||||
|
while( ( lSent >= 0 ) && ( lTotalSent < lBytes ) )
|
||||||
|
{
|
||||||
|
lSent = FreeRTOS_send( xConnectedSocket, pucRxBuffer, lBytes - lTotalSent, 0 );
|
||||||
|
lTotalSent += lSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lSent < 0 )
|
||||||
|
{
|
||||||
|
/* Socket closed? */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Socket closed? */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initiate a shutdown in case it has not already been initiated. */
|
||||||
|
FreeRTOS_shutdown( xConnectedSocket, FREERTOS_SHUT_RDWR );
|
||||||
|
|
||||||
|
/* Wait for the shutdown to take effect, indicated by FreeRTOS_recv()
|
||||||
|
returning an error. */
|
||||||
|
xTimeOnShutdown = xTaskGetTickCount();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if( FreeRTOS_recv( xConnectedSocket, pucRxBuffer, ipconfigTCP_MSS, 0 ) < 0 )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while( ( xTaskGetTickCount() - xTimeOnShutdown ) < tcpechoSHUTDOWN_DELAY );
|
||||||
|
|
||||||
|
/* Finished with the socket, buffer, the task. */
|
||||||
|
vPortFree( pucRxBuffer );
|
||||||
|
FreeRTOS_closesocket( xConnectedSocket );
|
||||||
|
|
||||||
|
vTaskDelete( NULL );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* The whole file is excluded if TCP is not compiled in. */
|
||||||
|
#endif /* ipconfigUSE_TCP */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,354 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS V202212.00
|
||||||
|
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates two transmitting tasks and two receiving tasks. The transmitting
|
||||||
|
* tasks send values that are received by the receiving tasks. One set of tasks
|
||||||
|
* uses the standard API. The other set of tasks uses the zero copy API.
|
||||||
|
*
|
||||||
|
* See the following web page for essential demo usage and configuration
|
||||||
|
* details:
|
||||||
|
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
/* FreeRTOS+TCP includes. */
|
||||||
|
#include "FreeRTOS_IP.h"
|
||||||
|
#include "FreeRTOS_Sockets.h"
|
||||||
|
|
||||||
|
#define simpTINY_DELAY ( ( TickType_t ) 2 )
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses a socket to send data without using the zero copy option.
|
||||||
|
* prvSimpleServerTask() will receive the data.
|
||||||
|
*/
|
||||||
|
static void prvSimpleClientTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses a socket to receive the data sent by the prvSimpleClientTask() task.
|
||||||
|
* Does not use the zero copy option.
|
||||||
|
*/
|
||||||
|
static void prvSimpleServerTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses a socket to send data using the zero copy option.
|
||||||
|
* prvSimpleZeroCopyServerTask() will receive the data.
|
||||||
|
*/
|
||||||
|
static void prvSimpleZeroCopyUDPClientTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses a socket to receive the data sent by the prvSimpleZeroCopyUDPClientTask()
|
||||||
|
* task. Uses the zero copy option.
|
||||||
|
*/
|
||||||
|
static void prvSimpleZeroCopyServerTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vStartSimpleUDPClientServerTasks( uint16_t usStackSize, uint32_t ulPort, UBaseType_t uxPriority )
|
||||||
|
{
|
||||||
|
/* Create the client and server tasks that do not use the zero copy
|
||||||
|
interface. */
|
||||||
|
xTaskCreate( prvSimpleClientTask, "SimpCpyClnt", usStackSize, ( void * ) ulPort, uxPriority, NULL );
|
||||||
|
xTaskCreate( prvSimpleServerTask, "SimpCpySrv", usStackSize, ( void * ) ulPort, uxPriority + 1, NULL );
|
||||||
|
|
||||||
|
/* Create the client and server tasks that do use the zero copy interface. */
|
||||||
|
xTaskCreate( prvSimpleZeroCopyUDPClientTask, "SimpZCpyClnt", usStackSize, ( void * ) ( ulPort + 1 ), uxPriority, NULL );
|
||||||
|
xTaskCreate( prvSimpleZeroCopyServerTask, "SimpZCpySrv", usStackSize, ( void * ) ( ulPort + 1 ), uxPriority + 1, NULL );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSimpleClientTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
Socket_t xClientSocket;
|
||||||
|
struct freertos_sockaddr xDestinationAddress;
|
||||||
|
uint8_t cString[ 65 ];
|
||||||
|
BaseType_t lReturned;
|
||||||
|
uint32_t ulCount = 0UL, ulIPAddress;
|
||||||
|
const uint32_t ulLoopsPerSocket = 10UL;
|
||||||
|
const TickType_t x150ms = 150UL / portTICK_PERIOD_MS;
|
||||||
|
|
||||||
|
/* Remove compiler warning about unused parameters. */
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* It is assumed that this task is not created until the network is up,
|
||||||
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
|
port on the same IP address. */
|
||||||
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
|
||||||
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
|
this nodes IP address, and the port number being sent to. The strange
|
||||||
|
casting is to try and remove compiler warnings on 32 bit machines. */
|
||||||
|
xDestinationAddress.sin_addr = ulIPAddress;
|
||||||
|
xDestinationAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
|
xDestinationAddress.sin_port = FreeRTOS_htons( xDestinationAddress.sin_port );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Create the socket. */
|
||||||
|
xClientSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||||
|
configASSERT( xClientSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* The count is used to differentiate between different messages sent to
|
||||||
|
the server, and to break out of the do while loop below. */
|
||||||
|
ulCount = 0UL;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* Create the string that is sent to the server. */
|
||||||
|
printf( ( char * ) 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
|
||||||
|
copy option is not selected. That means the data from cString[] is
|
||||||
|
copied into a network buffer inside FreeRTOS_sendto(), and cString[]
|
||||||
|
can be reused as soon as FreeRTOS_sendto() has returned. */
|
||||||
|
lReturned = FreeRTOS_sendto( xClientSocket, ( void * ) cString, strlen( ( const char * ) cString ), 0, &xDestinationAddress, sizeof( xDestinationAddress ) );
|
||||||
|
|
||||||
|
ulCount++;
|
||||||
|
|
||||||
|
} while( ( lReturned != FREERTOS_SOCKET_ERROR ) && ( ulCount < ulLoopsPerSocket ) );
|
||||||
|
|
||||||
|
FreeRTOS_closesocket( xClientSocket );
|
||||||
|
|
||||||
|
/* A short delay to prevent the messages printed by the server task
|
||||||
|
scrolling off the screen too quickly, and to prevent reduce the network
|
||||||
|
loading. */
|
||||||
|
vTaskDelay( x150ms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSimpleServerTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
int32_t lBytes;
|
||||||
|
uint8_t cReceivedString[ 60 ];
|
||||||
|
struct freertos_sockaddr xClient, xBindAddress;
|
||||||
|
uint32_t xClientLength = sizeof( xClient );
|
||||||
|
Socket_t xListeningSocket;
|
||||||
|
|
||||||
|
/* Just to prevent compiler warnings. */
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* Attempt to open the socket. */
|
||||||
|
xListeningSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||||
|
configASSERT( xListeningSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* This test receives data sent from a different port on the same IP
|
||||||
|
address. Configure the freertos_sockaddr structure with the address being
|
||||||
|
bound to. The strange casting is to try and remove compiler warnings on 32
|
||||||
|
bit machines. Note that this task is only created after the network is up,
|
||||||
|
so the IP address is valid here. */
|
||||||
|
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
|
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
||||||
|
|
||||||
|
/* Bind the socket to the port that the client task will send to. */
|
||||||
|
FreeRTOS_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Zero out the receive array so there is NULL at the end of the string
|
||||||
|
when it is printed out. */
|
||||||
|
memset( cReceivedString, 0x00, sizeof( cReceivedString ) );
|
||||||
|
|
||||||
|
/* Receive data on the socket. ulFlags is zero, so the zero copy option
|
||||||
|
is not set and the received data is copied into the buffer pointed to by
|
||||||
|
cReceivedString. By default the block time is portMAX_DELAY.
|
||||||
|
xClientLength is not actually used by FreeRTOS_recvfrom(), but is set
|
||||||
|
appropriately in case future versions do use it. */
|
||||||
|
lBytes = FreeRTOS_recvfrom( xListeningSocket, cReceivedString, sizeof( cReceivedString ), 0, &xClient, &xClientLength );
|
||||||
|
|
||||||
|
/* Error check. */
|
||||||
|
configASSERT( lBytes == ( BaseType_t ) strlen( ( const char * ) cReceivedString ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSimpleZeroCopyUDPClientTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
Socket_t xClientSocket;
|
||||||
|
uint8_t *pucUDPPayloadBuffer;
|
||||||
|
struct freertos_sockaddr xDestinationAddress;
|
||||||
|
BaseType_t lReturned;
|
||||||
|
uint32_t ulCount = 0UL, ulIPAddress;
|
||||||
|
const uint32_t ulLoopsPerSocket = 10UL;
|
||||||
|
const char *pcStringToSend = "Server received (using zero copy): Message number ";
|
||||||
|
const TickType_t x150ms = 150UL / portTICK_PERIOD_MS;
|
||||||
|
/* 15 is added to ensure the number, \r\n and terminating zero fit. */
|
||||||
|
const size_t xStringLength = strlen( pcStringToSend ) + 15;
|
||||||
|
|
||||||
|
/* Remove compiler warning about unused parameters. */
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* It is assumed that this task is not created until the network is up,
|
||||||
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
|
port on the same IP address. */
|
||||||
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
|
||||||
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
|
this nodes IP address, and the port number being sent to. The strange
|
||||||
|
casting is to try and remove compiler warnings on 32 bit machines. */
|
||||||
|
xDestinationAddress.sin_addr = ulIPAddress;
|
||||||
|
xDestinationAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
|
xDestinationAddress.sin_port = FreeRTOS_htons( xDestinationAddress.sin_port );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Create the socket. */
|
||||||
|
xClientSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||||
|
configASSERT( xClientSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* The count is used to differentiate between different messages sent to
|
||||||
|
the server, and to break out of the do while loop below. */
|
||||||
|
ulCount = 0UL;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* This task is going to send using the zero copy interface. The
|
||||||
|
data being sent is therefore written directly into a buffer that is
|
||||||
|
passed into, rather than copied into, the FreeRTOS_sendto()
|
||||||
|
function.
|
||||||
|
|
||||||
|
First obtain a buffer of adequate length from the IP stack into which
|
||||||
|
the string will be written. Although a max delay is used, the actual
|
||||||
|
delay will be capped to ipconfigMAX_SEND_BLOCK_TIME_TICKS, hence
|
||||||
|
the do while loop is used to ensure a buffer is obtained. */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY ) ) == NULL );
|
||||||
|
|
||||||
|
/* A buffer was successfully obtained. Create the string that is
|
||||||
|
sent to the server. First the string is filled with zeros as this will
|
||||||
|
effectively be the null terminator when the string is received at the other
|
||||||
|
end. Note that the string is being written directly into the buffer
|
||||||
|
obtained from the IP stack above. */
|
||||||
|
memset( ( void * ) pucUDPPayloadBuffer, 0x00, xStringLength );
|
||||||
|
printf( ( char * ) pucUDPPayloadBuffer, "%s%lu\r\n", pcStringToSend, ulCount );
|
||||||
|
|
||||||
|
/* Pass the buffer into the send function. ulFlags has the
|
||||||
|
FREERTOS_ZERO_COPY bit set so the IP stack will take control of the
|
||||||
|
buffer rather than copy data out of the buffer. */
|
||||||
|
lReturned = FreeRTOS_sendto( xClientSocket, /* The socket being sent to. */
|
||||||
|
( void * ) pucUDPPayloadBuffer, /* A pointer to the the data being sent. */
|
||||||
|
strlen( ( const char * ) pucUDPPayloadBuffer ) + 1, /* The length of the data being sent - including the string's null terminator. */
|
||||||
|
FREERTOS_ZERO_COPY, /* ulFlags with the FREERTOS_ZERO_COPY bit set. */
|
||||||
|
&xDestinationAddress, /* Where the data is being sent. */
|
||||||
|
sizeof( xDestinationAddress ) );
|
||||||
|
|
||||||
|
if( lReturned == 0 )
|
||||||
|
{
|
||||||
|
/* The send operation failed, so this task is still responsible
|
||||||
|
for the buffer obtained from the IP stack. To ensure the buffer
|
||||||
|
is not lost it must either be used again, or, as in this case,
|
||||||
|
returned to the IP stack using FreeRTOS_ReleaseUDPPayloadBuffer().
|
||||||
|
pucUDPPayloadBuffer can be safely re-used after this call. */
|
||||||
|
FreeRTOS_ReleaseUDPPayloadBuffer( ( void * ) pucUDPPayloadBuffer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The send was successful so the IP stack is now managing the
|
||||||
|
buffer pointed to by pucUDPPayloadBuffer, and the IP stack will
|
||||||
|
return the buffer once it has been sent. pucUDPPayloadBuffer can
|
||||||
|
be safely re-used. */
|
||||||
|
}
|
||||||
|
|
||||||
|
ulCount++;
|
||||||
|
|
||||||
|
} while( ( lReturned != FREERTOS_SOCKET_ERROR ) && ( ulCount < ulLoopsPerSocket ) );
|
||||||
|
|
||||||
|
FreeRTOS_closesocket( xClientSocket );
|
||||||
|
|
||||||
|
/* A short delay to prevent the messages scrolling off the screen too
|
||||||
|
quickly. */
|
||||||
|
vTaskDelay( x150ms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSimpleZeroCopyServerTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
int32_t lBytes;
|
||||||
|
uint8_t *pucUDPPayloadBuffer;
|
||||||
|
struct freertos_sockaddr xClient, xBindAddress;
|
||||||
|
uint32_t xClientLength = sizeof( xClient ), ulIPAddress;
|
||||||
|
Socket_t xListeningSocket;
|
||||||
|
|
||||||
|
/* Just to prevent compiler warnings. */
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
/* Attempt to open the socket. */
|
||||||
|
xListeningSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||||
|
configASSERT( xListeningSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* This test receives data sent from a different port on the same IP address.
|
||||||
|
Obtain the nodes IP address. Configure the freertos_sockaddr structure with
|
||||||
|
the address being bound to. The strange casting is to try and remove
|
||||||
|
compiler warnings on 32 bit machines. Note that this task is only created
|
||||||
|
after the network is up, so the IP address is valid here. */
|
||||||
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
xBindAddress.sin_addr = ulIPAddress;
|
||||||
|
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
|
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
||||||
|
|
||||||
|
/* Bind the socket to the port that the client task will send to. */
|
||||||
|
FreeRTOS_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Receive data on the socket. ulFlags has the zero copy bit set
|
||||||
|
(FREERTOS_ZERO_COPY) indicating to the stack that a reference to the
|
||||||
|
received data should be passed out to this task using the second
|
||||||
|
parameter to the FreeRTOS_recvfrom() call. When this is done the
|
||||||
|
IP stack is no longer responsible for releasing the buffer, and
|
||||||
|
the task *must* return the buffer to the stack when it is no longer
|
||||||
|
needed. By default the block time is portMAX_DELAY. */
|
||||||
|
lBytes = FreeRTOS_recvfrom( xListeningSocket, ( void * ) &pucUDPPayloadBuffer, 0, FREERTOS_ZERO_COPY, &xClient, &xClientLength );
|
||||||
|
|
||||||
|
/* Print the received characters. */
|
||||||
|
if( lBytes > 0 )
|
||||||
|
{
|
||||||
|
/* It is expected to receive one more byte than the string length as
|
||||||
|
the NULL terminator is also transmitted. */
|
||||||
|
configASSERT( lBytes == ( ( BaseType_t ) strlen( ( const char * ) pucUDPPayloadBuffer ) + 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lBytes >= 0 )
|
||||||
|
{
|
||||||
|
/* The buffer *must* be freed once it is no longer needed. */
|
||||||
|
FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayloadBuffer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,358 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS V202212.00
|
||||||
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://github.com/FreeRTOS
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A set of tasks are created that send TCP echo requests to the standard echo
|
||||||
|
* port (port 7) on the IP address set by the configECHO_SERVER_ADDR0 to
|
||||||
|
* configECHO_SERVER_ADDR3 constants, then wait for and verify the reply
|
||||||
|
* (another demo is available that demonstrates the reception being performed in
|
||||||
|
* a task other than that from with the request was made).
|
||||||
|
*
|
||||||
|
* See the following web page for essential demo usage and configuration
|
||||||
|
* details:
|
||||||
|
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "queue.h"
|
||||||
|
|
||||||
|
/* FreeRTOS+TCP includes. */
|
||||||
|
#include "FreeRTOS_IP.h"
|
||||||
|
#include "FreeRTOS_Sockets.h"
|
||||||
|
|
||||||
|
#include "tcp_echo_config.h"
|
||||||
|
|
||||||
|
/* Exclude the whole file if FreeRTOSIPConfig.h is configured to use UDP only. */
|
||||||
|
#if( ipconfigUSE_TCP == 1 )
|
||||||
|
|
||||||
|
/* The echo tasks create a socket, send out a number of echo requests, listen
|
||||||
|
for the echo reply, then close the socket again before starting over. This
|
||||||
|
delay is used between each iteration to ensure the network does not get too
|
||||||
|
congested. */
|
||||||
|
#define echoLOOP_DELAY ( ( TickType_t ) 150 / portTICK_PERIOD_MS )
|
||||||
|
|
||||||
|
/* The echo server is assumed to be on port 7, which is the standard echo
|
||||||
|
protocol port. */
|
||||||
|
#define echoECHO_PORT ( 7 )
|
||||||
|
|
||||||
|
/* The size of the buffers is a multiple of the MSS - the length of the data
|
||||||
|
sent is a pseudo random size between 20 and echoBUFFER_SIZES. */
|
||||||
|
#define echoBUFFER_SIZE_MULTIPLIER ( 3 )
|
||||||
|
#define echoBUFFER_SIZES ( ipconfigTCP_MSS * echoBUFFER_SIZE_MULTIPLIER )
|
||||||
|
|
||||||
|
/* The number of instances of the echo client task to create. */
|
||||||
|
#define echoNUM_ECHO_CLIENTS ( 5 )
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uses a socket to send data to, then receive data from, the standard echo
|
||||||
|
* port number 7.
|
||||||
|
*/
|
||||||
|
static void prvEchoClientTask( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a pseudo random sized buffer of data to send to the echo server.
|
||||||
|
*/
|
||||||
|
static BaseType_t prvCreateTxData( char *ucBuffer, uint32_t ulBufferLength );
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Rx and Tx time outs are used to ensure the sockets do not wait too long for
|
||||||
|
missing data. */
|
||||||
|
static const TickType_t xReceiveTimeOut = pdMS_TO_TICKS( 4000 );
|
||||||
|
static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 2000 );
|
||||||
|
|
||||||
|
/* Counters for each created task - for inspection only. */
|
||||||
|
static uint32_t ulTxRxCycles[ echoNUM_ECHO_CLIENTS ] = { 0 },
|
||||||
|
ulTxRxFailures[ echoNUM_ECHO_CLIENTS ] = { 0 },
|
||||||
|
ulConnections[ echoNUM_ECHO_CLIENTS ] = { 0 };
|
||||||
|
|
||||||
|
/* Rx and Tx buffers for each created task. */
|
||||||
|
static char cTxBuffers[ echoNUM_ECHO_CLIENTS ][ echoBUFFER_SIZES ],
|
||||||
|
cRxBuffers[ echoNUM_ECHO_CLIENTS ][ echoBUFFER_SIZES ];
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vStartTCPEchoClientTasks_SingleTasks( uint16_t usTaskStackSize, UBaseType_t uxTaskPriority )
|
||||||
|
{
|
||||||
|
BaseType_t x;
|
||||||
|
|
||||||
|
/* Create the echo client tasks. */
|
||||||
|
for( x = 0; x < echoNUM_ECHO_CLIENTS; x++ )
|
||||||
|
{
|
||||||
|
xTaskCreate( prvEchoClientTask, /* The function that implements the task. */
|
||||||
|
"Echo0", /* Just a text name for the task to aid debugging. */
|
||||||
|
usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
|
||||||
|
( void * ) x, /* The task parameter, not used in this case. */
|
||||||
|
uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
|
||||||
|
NULL ); /* The task handle is not used. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvEchoClientTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
Socket_t xSocket;
|
||||||
|
struct freertos_sockaddr xEchoServerAddress;
|
||||||
|
int32_t lLoopCount = 0UL;
|
||||||
|
const int32_t lMaxLoopCount = 1;
|
||||||
|
volatile uint32_t ulTxCount = 0UL;
|
||||||
|
BaseType_t xReceivedBytes, xReturned, xInstance;
|
||||||
|
BaseType_t lTransmitted, lStringLength;
|
||||||
|
char *pcTransmittedString, *pcReceivedString;
|
||||||
|
WinProperties_t xWinProps;
|
||||||
|
TickType_t xTimeOnEntering;
|
||||||
|
|
||||||
|
/* Fill in the buffer and window sizes that will be used by the socket. */
|
||||||
|
xWinProps.lTxBufSize = 6 * ipconfigTCP_MSS;
|
||||||
|
xWinProps.lTxWinSize = 3;
|
||||||
|
xWinProps.lRxBufSize = 6 * ipconfigTCP_MSS;
|
||||||
|
xWinProps.lRxWinSize = 3;
|
||||||
|
|
||||||
|
/* This task can be created a number of times. Each instance is numbered
|
||||||
|
to enable each instance to use a different Rx and Tx buffer. The number is
|
||||||
|
passed in as the task's parameter. */
|
||||||
|
xInstance = ( BaseType_t ) pvParameters;
|
||||||
|
|
||||||
|
/* Point to the buffers to be used by this instance of this task. */
|
||||||
|
pcTransmittedString = &( cTxBuffers[ xInstance ][ 0 ] );
|
||||||
|
pcReceivedString = &( cRxBuffers[ xInstance ][ 0 ] );
|
||||||
|
|
||||||
|
/* Echo requests are sent to the echo server. The address of the echo
|
||||||
|
server is configured by the constants configECHO_SERVER_ADDR0 to
|
||||||
|
configECHO_SERVER_ADDR3 in FreeRTOSConfig.h. */
|
||||||
|
xEchoServerAddress.sin_port = FreeRTOS_htons( echoECHO_PORT );
|
||||||
|
xEchoServerAddress.sin_addr = FreeRTOS_inet_addr( configECHO_SERVER_ADDR );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
/* Create a TCP socket. */
|
||||||
|
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
||||||
|
configASSERT( xSocket != FREERTOS_INVALID_SOCKET );
|
||||||
|
|
||||||
|
/* Set a time out so a missing reply does not cause the task to block
|
||||||
|
indefinitely. */
|
||||||
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
|
||||||
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
|
||||||
|
|
||||||
|
/* Set the window and buffer sizes. */
|
||||||
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) );
|
||||||
|
|
||||||
|
/* Connect to the echo server. */
|
||||||
|
if( FreeRTOS_connect( xSocket, &xEchoServerAddress, sizeof( xEchoServerAddress ) ) == 0 )
|
||||||
|
{
|
||||||
|
ulConnections[ xInstance ]++;
|
||||||
|
|
||||||
|
/* Send a number of echo requests. */
|
||||||
|
for( lLoopCount = 0; lLoopCount < lMaxLoopCount; lLoopCount++ )
|
||||||
|
{
|
||||||
|
/* Create the string that is sent to the echo server. */
|
||||||
|
lStringLength = prvCreateTxData( pcTransmittedString, echoBUFFER_SIZES );
|
||||||
|
|
||||||
|
/* Add in some unique text at the front of the string. */
|
||||||
|
sprintf( pcTransmittedString, "TxRx message number %u", ulTxCount );
|
||||||
|
ulTxCount++;
|
||||||
|
|
||||||
|
/* Send the string to the socket. */
|
||||||
|
lTransmitted = FreeRTOS_send( xSocket, /* The socket being sent to. */
|
||||||
|
( void * ) pcTransmittedString, /* The data being sent. */
|
||||||
|
lStringLength, /* The length of the data being sent. */
|
||||||
|
0 ); /* No flags. */
|
||||||
|
|
||||||
|
if( lTransmitted < 0 )
|
||||||
|
{
|
||||||
|
/* Error? */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the buffer into which the echoed string will be
|
||||||
|
placed. */
|
||||||
|
memset( ( void * ) pcReceivedString, 0x00, echoBUFFER_SIZES );
|
||||||
|
xReceivedBytes = 0;
|
||||||
|
|
||||||
|
/* Receive data echoed back to the socket. */
|
||||||
|
while( xReceivedBytes < lTransmitted )
|
||||||
|
{
|
||||||
|
xReturned = FreeRTOS_recv( xSocket, /* The socket being received from. */
|
||||||
|
&( pcReceivedString[ xReceivedBytes ] ),/* The buffer into which the received data will be written. */
|
||||||
|
lStringLength - xReceivedBytes, /* The size of the buffer provided to receive the data. */
|
||||||
|
0 ); /* No flags. */
|
||||||
|
|
||||||
|
if( xReturned < 0 )
|
||||||
|
{
|
||||||
|
/* Error occurred. Latch it so it can be detected
|
||||||
|
below. */
|
||||||
|
xReceivedBytes = xReturned;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if( xReturned == 0 )
|
||||||
|
{
|
||||||
|
/* Timed out. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Keep a count of the bytes received so far. */
|
||||||
|
xReceivedBytes += xReturned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If an error occurred it will be latched in xReceivedBytes,
|
||||||
|
otherwise xReceived bytes will be just that - the number of
|
||||||
|
bytes received from the echo server. */
|
||||||
|
if( xReceivedBytes > 0 )
|
||||||
|
{
|
||||||
|
/* Compare the transmitted string to the received string. */
|
||||||
|
configASSERT( strncmp( pcReceivedString, pcTransmittedString, lTransmitted ) == 0 );
|
||||||
|
if( strncmp( pcReceivedString, pcTransmittedString, lTransmitted ) == 0 )
|
||||||
|
{
|
||||||
|
/* The echo reply was received without error. */
|
||||||
|
ulTxRxCycles[ xInstance ]++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The received string did not match the transmitted
|
||||||
|
string. */
|
||||||
|
ulTxRxFailures[ xInstance ]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( xReceivedBytes < 0 )
|
||||||
|
{
|
||||||
|
/* FreeRTOS_recv() returned an error. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Timed out without receiving anything? */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finished using the connected socket, initiate a graceful close:
|
||||||
|
FIN, FIN+ACK, ACK. */
|
||||||
|
FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RDWR );
|
||||||
|
|
||||||
|
/* Expect FreeRTOS_recv() to return an error once the shutdown is
|
||||||
|
complete. */
|
||||||
|
xTimeOnEntering = xTaskGetTickCount();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
xReturned = FreeRTOS_recv( xSocket, /* The socket being received from. */
|
||||||
|
&( pcReceivedString[ 0 ] ), /* The buffer into which the received data will be written. */
|
||||||
|
echoBUFFER_SIZES, /* The size of the buffer provided to receive the data. */
|
||||||
|
0 );
|
||||||
|
|
||||||
|
if( xReturned < 0 )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while( ( xTaskGetTickCount() - xTimeOnEntering ) < xReceiveTimeOut );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close this socket before looping back to create another. */
|
||||||
|
FreeRTOS_closesocket( xSocket );
|
||||||
|
|
||||||
|
/* Pause for a short while to ensure the network is not too
|
||||||
|
congested. */
|
||||||
|
vTaskDelay( echoLOOP_DELAY );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static BaseType_t prvCreateTxData( char *cBuffer, uint32_t ulBufferLength )
|
||||||
|
{
|
||||||
|
BaseType_t lCharactersToAdd, lCharacter;
|
||||||
|
char cChar = '0';
|
||||||
|
const BaseType_t lMinimumLength = 60;
|
||||||
|
uint32_t ulRandomNumber;
|
||||||
|
|
||||||
|
/* Randomise the number of characters that will be sent in the echo
|
||||||
|
request. */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
( void ) xApplicationGetRandomNumber( &ulRandomNumber );
|
||||||
|
lCharactersToAdd = ulRandomNumber % ( ulBufferLength - 20UL );
|
||||||
|
} while ( ( lCharactersToAdd == 0 ) || ( lCharactersToAdd < lMinimumLength ) ); /* Must be at least enough to add the unique text to the start of the string later. */
|
||||||
|
|
||||||
|
/* Fill the buffer. */
|
||||||
|
for( lCharacter = 0; lCharacter < lCharactersToAdd; lCharacter++ )
|
||||||
|
{
|
||||||
|
cBuffer[ lCharacter ] = cChar;
|
||||||
|
cChar++;
|
||||||
|
|
||||||
|
if( cChar > '~' )
|
||||||
|
{
|
||||||
|
cChar = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lCharactersToAdd;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
BaseType_t xAreSingleTaskTCPEchoClientsStillRunning( void )
|
||||||
|
{
|
||||||
|
static uint32_t ulLastEchoSocketCount[ echoNUM_ECHO_CLIENTS ] = { 0 }, ulLastConnections[ echoNUM_ECHO_CLIENTS ] = { 0 };
|
||||||
|
BaseType_t xReturn = pdPASS, x;
|
||||||
|
|
||||||
|
/* Return fail is the number of cycles does not increment between
|
||||||
|
consecutive calls. */
|
||||||
|
for( x = 0; x < echoNUM_ECHO_CLIENTS; x++ )
|
||||||
|
{
|
||||||
|
if( ulTxRxCycles[ x ] == ulLastEchoSocketCount[ x ] )
|
||||||
|
{
|
||||||
|
xReturn = pdFAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulLastEchoSocketCount[ x ] = ulTxRxCycles[ x ];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ulConnections[ x ] == ulLastConnections[ x ] )
|
||||||
|
{
|
||||||
|
xReturn = pdFAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulConnections[ x ] = ulLastConnections[ x ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return xReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ipconfigUSE_TCP */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
FreeRTOS V202212.00
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||||
|
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||||
|
>>! obliged to provide the source code for proprietary components !<<
|
||||||
|
>>! outside of the FreeRTOS kernel. !<<
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||||
|
link: http://www.freertos.org/a00114.html
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS provides completely free yet professionally developed, *
|
||||||
|
* robust, strictly quality controlled, supported, and cross *
|
||||||
|
* platform software that is more than just the market leader, it *
|
||||||
|
* is the industry's de facto standard. *
|
||||||
|
* *
|
||||||
|
* Help yourself get started quickly while simultaneously helping *
|
||||||
|
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||||
|
* tutorial book, reference manual, or both: *
|
||||||
|
* http://www.FreeRTOS.org/Documentation *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||||
|
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||||
|
defined configASSERT()?
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||||
|
embedded software for free we request you assist our global community by
|
||||||
|
participating in the support forum.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||||
|
be as productive as possible as early as possible. Now you can receive
|
||||||
|
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||||
|
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||||
|
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||||
|
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||||
|
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||||
|
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||||
|
licenses offer ticketed support, indemnification and commercial middleware.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||||
|
engineered and independently SIL3 certified version for use in safety and
|
||||||
|
mission critical applications that require provable dependability.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_TCP_ECHO_SERVER_H
|
||||||
|
#define SIMPLE_TCP_ECHO_SERVER_H
|
||||||
|
|
||||||
|
void vStartSimpleTCPServerTasks( uint16_t usStackSize, BaseType_t uxPriority );
|
||||||
|
BaseType_t xAreTCPEchoServersStillRunning( void );
|
||||||
|
|
||||||
|
#endif /* SIMPLE_TCP_ECHO_SERVER_H */
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS V202212.00
|
||||||
|
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_UDP_CLIENT_AND_SERVER_H
|
||||||
|
#define SIMPLE_UDP_CLIENT_AND_SERVER_H
|
||||||
|
|
||||||
|
void vStartSimpleUDPClientServerTasks( uint16_t usStackSize, uint32_t ulsPort, UBaseType_t uxPriority );
|
||||||
|
|
||||||
|
#endif /* SIMPLE_UDPCLIENT_AND_SERVER_H */
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS V202212.00
|
||||||
|
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SINGLE_TASK_TCP_ECHO_CLIENTS_H
|
||||||
|
#define SINGLE_TASK_TCP_ECHO_CLIENTS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the TCP echo client tasks. This is the version where an echo request
|
||||||
|
* is made from the same task that listens for the echo reply.
|
||||||
|
*/
|
||||||
|
void vStartTCPEchoClientTasks_SingleTasks( uint16_t usTaskStackSize, UBaseType_t uxTaskPriority );
|
||||||
|
BaseType_t xAreSingleTaskTCPEchoClientsStillRunning( void );
|
||||||
|
|
||||||
|
#endif /* SINGLE_TASK_TCP_ECHO_CLIENTS_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS V202212.00
|
||||||
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://github.com/FreeRTOS
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* TCP Echo Demo configuration */
|
||||||
|
|
||||||
|
#ifndef TCP_ECHO_CONFIG_H_
|
||||||
|
#define TCP_ECHO_CONFIG_H_
|
||||||
|
|
||||||
|
#define configECHO_SERVER_ADDR "127.0.0.1"
|
||||||
|
#define configECHO_SERVER_PORT ( 9000U )
|
||||||
|
|
||||||
|
#endif /* TCP_ECHO_CONFIG_H_ */
|
||||||
Binary file not shown.
|
|
@ -40,4 +40,6 @@
|
||||||
* dependent. */
|
* dependent. */
|
||||||
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
|
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -153,24 +153,7 @@
|
||||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
|
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint>
|
<Breakpoint/>
|
||||||
<Bp>
|
|
||||||
<Number>0</Number>
|
|
||||||
<Type>0</Type>
|
|
||||||
<LineNumber>157</LineNumber>
|
|
||||||
<EnabledFlag>1</EnabledFlag>
|
|
||||||
<Address>0</Address>
|
|
||||||
<ByteObject>0</ByteObject>
|
|
||||||
<HtxType>0</HtxType>
|
|
||||||
<ManyObjects>0</ManyObjects>
|
|
||||||
<SizeOfObject>0</SizeOfObject>
|
|
||||||
<BreakByAccess>0</BreakByAccess>
|
|
||||||
<BreakIfRCount>0</BreakIfRCount>
|
|
||||||
<Filename>.\main.c</Filename>
|
|
||||||
<ExecCommand></ExecCommand>
|
|
||||||
<Expression></Expression>
|
|
||||||
</Bp>
|
|
||||||
</Breakpoint>
|
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
|
|
@ -254,17 +237,53 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>1</GroupNumber>
|
||||||
|
<FileNumber>2</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>.\DemoTasks\SimpleTCPEchoServer.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>SimpleTCPEchoServer.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>1</GroupNumber>
|
||||||
|
<FileNumber>3</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>1</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>.\DemoTasks\SimpleUDPClientAndServer.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>SimpleUDPClientAndServer.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>1</GroupNumber>
|
||||||
|
<FileNumber>4</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>.\DemoTasks\TCPEchoClient_SingleTasks.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>TCPEchoClient_SingleTasks.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>FreeRTOS</GroupName>
|
<GroupName>FreeRTOS</GroupName>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>2</FileNumber>
|
<FileNumber>5</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -276,7 +295,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>3</FileNumber>
|
<FileNumber>6</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -288,7 +307,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>4</FileNumber>
|
<FileNumber>7</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -300,7 +319,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>5</FileNumber>
|
<FileNumber>8</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -312,7 +331,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>6</FileNumber>
|
<FileNumber>9</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -324,7 +343,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>7</FileNumber>
|
<FileNumber>10</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -336,7 +355,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>8</FileNumber>
|
<FileNumber>11</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -348,7 +367,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>9</FileNumber>
|
<FileNumber>12</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -360,7 +379,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>10</FileNumber>
|
<FileNumber>13</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -372,7 +391,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>11</FileNumber>
|
<FileNumber>14</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -384,7 +403,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>12</FileNumber>
|
<FileNumber>15</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -396,7 +415,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>13</FileNumber>
|
<FileNumber>16</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -408,7 +427,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>14</FileNumber>
|
<FileNumber>17</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -420,7 +439,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>15</FileNumber>
|
<FileNumber>18</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -432,7 +451,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>16</FileNumber>
|
<FileNumber>19</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -444,7 +463,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>17</FileNumber>
|
<FileNumber>20</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -456,7 +475,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>18</FileNumber>
|
<FileNumber>21</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -468,7 +487,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>19</FileNumber>
|
<FileNumber>22</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -480,7 +499,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>20</FileNumber>
|
<FileNumber>23</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -492,7 +511,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>21</FileNumber>
|
<FileNumber>24</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -504,7 +523,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>22</FileNumber>
|
<FileNumber>25</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -516,7 +535,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>23</FileNumber>
|
<FileNumber>26</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -528,7 +547,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>24</FileNumber>
|
<FileNumber>27</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -540,7 +559,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>25</FileNumber>
|
<FileNumber>28</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
@ -594,7 +613,15 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::RTOS</GroupName>
|
<GroupName>::RTOS</GroupName>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<cbSel>0</cbSel>
|
||||||
|
<RteFlg>1</RteFlg>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group>
|
||||||
|
<GroupName>::Security</GroupName>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>1</RteFlg>
|
<RteFlg>1</RteFlg>
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@
|
||||||
<MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls>
|
<MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;C:\Users\User\AppData\Local\Arm\Packs\Arm-Packs\PKCS11\1.0.0\include</IncludePath>
|
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;C:\Users\User\AppData\Local\Arm\Packs\Arm-Packs\PKCS11\1.0.0\include;.\DemoTasks\include</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
<Aads>
|
<Aads>
|
||||||
|
|
@ -390,6 +390,21 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>.\main.c</FilePath>
|
<FilePath>.\main.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>SimpleTCPEchoServer.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\DemoTasks\SimpleTCPEchoServer.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>SimpleUDPClientAndServer.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\DemoTasks\SimpleUDPClientAndServer.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>TCPEchoClient_SingleTasks.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\DemoTasks\TCPEchoClient_SingleTasks.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
|
@ -742,6 +757,78 @@
|
||||||
</GroupArmAds>
|
</GroupArmAds>
|
||||||
</GroupOption>
|
</GroupOption>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group>
|
||||||
|
<GroupName>::Security</GroupName>
|
||||||
|
<GroupOption>
|
||||||
|
<CommonProperty>
|
||||||
|
<UseCPPCompiler>0</UseCPPCompiler>
|
||||||
|
<RVCTCodeConst>0</RVCTCodeConst>
|
||||||
|
<RVCTZI>0</RVCTZI>
|
||||||
|
<RVCTOtherData>0</RVCTOtherData>
|
||||||
|
<ModuleSelection>0</ModuleSelection>
|
||||||
|
<IncludeInBuild>0</IncludeInBuild>
|
||||||
|
<AlwaysBuild>2</AlwaysBuild>
|
||||||
|
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||||
|
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||||
|
<PublicsOnly>2</PublicsOnly>
|
||||||
|
<StopOnExitCode>11</StopOnExitCode>
|
||||||
|
<CustomArgument></CustomArgument>
|
||||||
|
<IncludeLibraryModules></IncludeLibraryModules>
|
||||||
|
<ComprImg>1</ComprImg>
|
||||||
|
</CommonProperty>
|
||||||
|
<GroupArmAds>
|
||||||
|
<Cads>
|
||||||
|
<interw>2</interw>
|
||||||
|
<Optim>0</Optim>
|
||||||
|
<oTime>2</oTime>
|
||||||
|
<SplitLS>2</SplitLS>
|
||||||
|
<OneElfS>2</OneElfS>
|
||||||
|
<Strict>2</Strict>
|
||||||
|
<EnumInt>2</EnumInt>
|
||||||
|
<PlainCh>2</PlainCh>
|
||||||
|
<Ropi>2</Ropi>
|
||||||
|
<Rwpi>2</Rwpi>
|
||||||
|
<wLevel>0</wLevel>
|
||||||
|
<uThumb>2</uThumb>
|
||||||
|
<uSurpInc>2</uSurpInc>
|
||||||
|
<uC99>2</uC99>
|
||||||
|
<uGnu>2</uGnu>
|
||||||
|
<useXO>2</useXO>
|
||||||
|
<v6Lang>0</v6Lang>
|
||||||
|
<v6LangP>0</v6LangP>
|
||||||
|
<vShortEn>2</vShortEn>
|
||||||
|
<vShortWch>2</vShortWch>
|
||||||
|
<v6Lto>2</v6Lto>
|
||||||
|
<v6WtE>2</v6WtE>
|
||||||
|
<v6Rtti>2</v6Rtti>
|
||||||
|
<VariousControls>
|
||||||
|
<MiscControls></MiscControls>
|
||||||
|
<Define></Define>
|
||||||
|
<Undefine></Undefine>
|
||||||
|
<IncludePath></IncludePath>
|
||||||
|
</VariousControls>
|
||||||
|
</Cads>
|
||||||
|
<Aads>
|
||||||
|
<interw>2</interw>
|
||||||
|
<Ropi>2</Ropi>
|
||||||
|
<Rwpi>2</Rwpi>
|
||||||
|
<thumb>2</thumb>
|
||||||
|
<SplitLS>2</SplitLS>
|
||||||
|
<SwStkChk>2</SwStkChk>
|
||||||
|
<NoWarn>2</NoWarn>
|
||||||
|
<uSurpInc>2</uSurpInc>
|
||||||
|
<useXO>2</useXO>
|
||||||
|
<ClangAsOpt>0</ClangAsOpt>
|
||||||
|
<VariousControls>
|
||||||
|
<MiscControls></MiscControls>
|
||||||
|
<Define></Define>
|
||||||
|
<Undefine></Undefine>
|
||||||
|
<IncludePath></IncludePath>
|
||||||
|
</VariousControls>
|
||||||
|
</Aads>
|
||||||
|
</GroupArmAds>
|
||||||
|
</GroupOption>
|
||||||
|
</Group>
|
||||||
</Groups>
|
</Groups>
|
||||||
</Target>
|
</Target>
|
||||||
</Targets>
|
</Targets>
|
||||||
|
|
@ -873,6 +960,12 @@
|
||||||
<targetInfo excluded="1" name="Target 1"/>
|
<targetInfo excluded="1" name="Target 1"/>
|
||||||
</targetInfos>
|
</targetInfos>
|
||||||
</component>
|
</component>
|
||||||
|
<component Capiversion="2.4.0-errata1" Cclass="Security" Cgroup="PKCS11" Csub="corePKCS11" Cvendor="AWS" Cversion="3.0.1" condition="pkcs11_implementation Condition">
|
||||||
|
<package name="corePKCS11" schemaVersion="1.7.2" url="https://freertos-cmsis-packs.s3.us-west-2.amazonaws.com/" vendor="AWS" version="4.0.1"/>
|
||||||
|
<targetInfos>
|
||||||
|
<targetInfo excluded="1" name="Target 1"/>
|
||||||
|
</targetInfos>
|
||||||
|
</component>
|
||||||
<component Cclass="Device" Cgroup="EVAL" Csub="GD32F107C" Cvendor="GigaDevice" Cversion="2.0.2" condition="GD32F10x STDPERIPHERALS EVAL">
|
<component Cclass="Device" Cgroup="EVAL" Csub="GD32F107C" Cvendor="GigaDevice" Cversion="2.0.2" condition="GD32F10x STDPERIPHERALS EVAL">
|
||||||
<package name="GD32F10x_DFP" schemaVersion="1.2" url="https://gd32mcu.com/data/documents/pack/" vendor="GigaDevice" version="2.0.3"/>
|
<package name="GD32F10x_DFP" schemaVersion="1.2" url="https://gd32mcu.com/data/documents/pack/" vendor="GigaDevice" version="2.0.3"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
|
|
|
||||||
134
main.c
134
main.c
|
|
@ -4,18 +4,47 @@
|
||||||
#include "gd32f10x_gpio.h"
|
#include "gd32f10x_gpio.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
/* System application includes. */
|
/* System application includes. */
|
||||||
|
#include "FreeRTOSIPConfig.h"
|
||||||
|
|
||||||
|
/* Demo application includes. */
|
||||||
#include "FreeRTOS_IP.h"
|
#include "FreeRTOS_IP.h"
|
||||||
#include "FreeRTOS_Sockets.h"
|
#include "FreeRTOS_Sockets.h"
|
||||||
#include "FreeRTOS_DHCP.h"
|
#include "SimpleUDPClientAndServer.h"
|
||||||
|
#include "SimpleTCPEchoServer.h"
|
||||||
|
#include "TCPEchoClient_SingleTasks.h"
|
||||||
|
|
||||||
#define BUTTON_USER GPIO_PIN_14
|
#define BUTTON_USER GPIO_PIN_14
|
||||||
|
|
||||||
#define LED2_USER_PORT GPIOC
|
#define LED2_USER_PORT GPIOC
|
||||||
#define LED5_TICK_PORT GPIOE
|
#define LED5_TICK_PORT GPIOE
|
||||||
|
|
||||||
#define LED2_USER GPIO_PIN_0
|
#define LED2_USER GPIO_PIN_0
|
||||||
#define LED5_TICK GPIO_PIN_1
|
#define LED5_TICK GPIO_PIN_1
|
||||||
|
|
||||||
#define TASK_HELLO_WORLD_DELAY 500
|
#define TASK_HELLO_WORLD_DELAY 500
|
||||||
#define TASK_TOGGLE_LED_DELAY 125
|
#define TASK_TOGGLE_LED_DELAY 125
|
||||||
|
|
||||||
|
#define TEST_RUNNER_TASK_STACK_SIZE 512
|
||||||
|
|
||||||
|
#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1
|
||||||
|
#define mainCREATE_TCP_ECHO_TASKS_SINGLE 0
|
||||||
|
#define mainCREATE_TCP_ECHO_SERVER_TASK 0
|
||||||
|
|
||||||
|
/* Simple UDP client and server task parameters. */
|
||||||
|
#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||||
|
#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
|
||||||
|
|
||||||
|
/* Echo client task parameters - used for both TCP and UDP echo clients. */
|
||||||
|
#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
|
||||||
|
#define mainECHO_CLIENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||||
|
|
||||||
|
/* Echo server task parameters. */
|
||||||
|
#define mainECHO_SERVER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the Windows port. */
|
||||||
|
#define mainECHO_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||||
|
|
||||||
|
/* Define a name that will be used for LLMNR and NBNS searches. */
|
||||||
|
//#define mainHOST_NAME "RTOSDemo"
|
||||||
|
//#define mainDEVICE_NICK_NAME "windows_demo"
|
||||||
|
|
||||||
/* Default MAC address configuration. The demo creates a virtual network
|
/* Default MAC address configuration. The demo creates a virtual network
|
||||||
* connection that uses this MAC address by accessing the raw Ethernet data
|
* connection that uses this MAC address by accessing the raw Ethernet data
|
||||||
|
|
@ -66,7 +95,19 @@ static const uint8_t ucDNSServerAddress[ 4 ] =
|
||||||
configDNS_SERVER_ADDR3
|
configDNS_SERVER_ADDR3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Use by the pseudo random number generator. */
|
||||||
|
static UBaseType_t ulNextRand;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just seeds the simple pseudo random number generator.
|
||||||
|
*/
|
||||||
|
static void prvSRand( UBaseType_t ulSeed );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Miscellaneous initialisation including preparing the logging and seeding the
|
||||||
|
* random number generator.
|
||||||
|
*/
|
||||||
|
static void prvMiscInitialisation( void );
|
||||||
|
|
||||||
void vTaskHelloWorld( void *pvParameters);
|
void vTaskHelloWorld( void *pvParameters);
|
||||||
void vTaskToggleLed( void *pvParameters);
|
void vTaskToggleLed( void *pvParameters);
|
||||||
|
|
@ -148,9 +189,33 @@ void vTaskToggleLed( void *pvParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prvMiscInitialisation( void )
|
||||||
|
{
|
||||||
|
// time_t xTimeNow;
|
||||||
|
uint32_t ulRandomNumbers[ 4 ];
|
||||||
|
|
||||||
|
/* Seed the random number generator. */
|
||||||
|
// time( &xTimeNow );
|
||||||
|
FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\r\n", xTimeNow ) );
|
||||||
|
// prvSRand( ( uint32_t ) xTimeNow );
|
||||||
|
|
||||||
|
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] );
|
||||||
|
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] );
|
||||||
|
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] );
|
||||||
|
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] );
|
||||||
|
FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\r\n",
|
||||||
|
ulRandomNumbers[ 0 ],
|
||||||
|
ulRandomNumbers[ 1 ],
|
||||||
|
ulRandomNumbers[ 2 ],
|
||||||
|
ulRandomNumbers[ 3 ] ) );
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
vInitMCU();
|
vInitMCU();
|
||||||
|
/* Miscellaneous initialisation including preparing the logging and seeding
|
||||||
|
* the random number generator. */
|
||||||
|
prvMiscInitialisation();
|
||||||
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
|
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||||
xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
|
xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||||
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
|
@ -158,6 +223,73 @@ int main(void)
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
|
*/
|
||||||
|
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
|
||||||
|
* events are only received if implemented in the MAC driver. */
|
||||||
|
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
|
{
|
||||||
|
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
|
||||||
|
char cBuffer[ 16 ];
|
||||||
|
static BaseType_t xTasksAlreadyCreated = pdFALSE;
|
||||||
|
|
||||||
|
/* If the network has just come up...*/
|
||||||
|
if( eNetworkEvent == eNetworkUp )
|
||||||
|
{
|
||||||
|
/* Create the tasks that use the IP stack if they have not already been
|
||||||
|
* created. */
|
||||||
|
if( xTasksAlreadyCreated == pdFALSE )
|
||||||
|
{
|
||||||
|
/* See the comments above the definitions of these pre-processor
|
||||||
|
* macros at the top of this file for a description of the individual
|
||||||
|
* demo tasks. */
|
||||||
|
#if ( mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS == 1 )
|
||||||
|
{
|
||||||
|
vStartSimpleUDPClientServerTasks( configMINIMAL_STACK_SIZE, mainSIMPLE_UDP_CLIENT_SERVER_PORT, mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY );
|
||||||
|
}
|
||||||
|
#endif /* mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS */
|
||||||
|
|
||||||
|
#if ( mainCREATE_TCP_ECHO_TASKS_SINGLE == 1 )
|
||||||
|
{
|
||||||
|
vStartTCPEchoClientTasks_SingleTasks( mainECHO_CLIENT_TASK_STACK_SIZE, mainECHO_CLIENT_TASK_PRIORITY );
|
||||||
|
}
|
||||||
|
#endif /* mainCREATE_TCP_ECHO_TASKS_SINGLE */
|
||||||
|
|
||||||
|
#if ( mainCREATE_TCP_ECHO_SERVER_TASK == 1 )
|
||||||
|
{
|
||||||
|
vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
xTasksAlreadyCreated = pdTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print out the network configuration, which may have come from a DHCP
|
||||||
|
* server. */
|
||||||
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
||||||
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
|
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
|
||||||
|
FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
|
||||||
|
FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
|
||||||
|
FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void prvSRand( UBaseType_t ulSeed )
|
||||||
|
{
|
||||||
|
/* Utility function to seed the pseudo random number generator. */
|
||||||
|
ulNextRand = ulSeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UBaseType_t uxRand( void )
|
UBaseType_t uxRand( void )
|
||||||
{
|
{
|
||||||
static UBaseType_t ulNextRand;
|
static UBaseType_t ulNextRand;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue