mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-29 22:48:37 -04:00
Add the Labs projects provided in the V10.2.1_191129 zip file.
This commit is contained in:
parent
46e5937529
commit
e5708b38e9
801 changed files with 356576 additions and 0 deletions
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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:
|
||||
* http://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,433 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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!
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.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"
|
||||
|
||||
/* 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. */
|
||||
#ifndef configTCP_ECHO_CLIENT_PORT
|
||||
#define echoECHO_PORT ( 7 )
|
||||
#else
|
||||
#define echoECHO_PORT ( configTCP_ECHO_CLIENT_PORT )
|
||||
#endif
|
||||
|
||||
/* 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 ( 2 )
|
||||
#define echoBUFFER_SIZES ( ipconfigTCP_MSS * echoBUFFER_SIZE_MULTIPLIER )
|
||||
|
||||
/* The number of instances of the echo client task to create. */
|
||||
#define echoNUM_ECHO_CLIENTS ( 1 )
|
||||
|
||||
/* If ipconfigUSE_TCP_WIN is 1 then the Tx socket will use a buffer size set by
|
||||
ipconfigTCP_TX_BUFFER_LENGTH, and the Tx window size will be
|
||||
configECHO_CLIENT_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_CLIENT_TX_WINDOW_SIZE is set in
|
||||
FreeRTOSConfig.h as it is a demo application constant. */
|
||||
#ifndef configECHO_CLIENT_TX_WINDOW_SIZE
|
||||
#define configECHO_CLIENT_TX_WINDOW_SIZE 2
|
||||
#endif
|
||||
|
||||
/* If ipconfigUSE_TCP_WIN is 1 then the Rx socket will use a buffer size set by
|
||||
ipconfigTCP_RX_BUFFER_LENGTH, and the Rx window size will be
|
||||
configECHO_CLIENT_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_CLIENT_RX_WINDOW_SIZE is set in
|
||||
FreeRTOSConfig.h as it is a demo application constant. */
|
||||
#ifndef configECHO_CLIENT_RX_WINDOW_SIZE
|
||||
#define configECHO_CLIENT_RX_WINDOW_SIZE 2
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* 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;
|
||||
TickType_t xTimeOnEntering;
|
||||
|
||||
#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_CLIENT_TX_WINDOW_SIZE;
|
||||
xWinProps.lRxBufSize = ipconfigTCP_RX_BUFFER_LENGTH;
|
||||
xWinProps.lRxWinSize = configECHO_CLIENT_RX_WINDOW_SIZE;
|
||||
|
||||
#endif /* ipconfigUSE_TCP_WIN */
|
||||
|
||||
/* 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_quick( configECHO_SERVER_ADDR0,
|
||||
configECHO_SERVER_ADDR1,
|
||||
configECHO_SERVER_ADDR2,
|
||||
configECHO_SERVER_ADDR3 );
|
||||
|
||||
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 ) );
|
||||
|
||||
#if( ipconfigUSE_TCP_WIN == 1 )
|
||||
{
|
||||
/* Set the window and buffer sizes. */
|
||||
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) );
|
||||
}
|
||||
#endif /* ipconfigUSE_TCP_WIN */
|
||||
|
||||
/* 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", ( unsigned ) 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;
|
||||
|
||||
/* Randomise the number of characters that will be sent in the echo
|
||||
request. */
|
||||
do
|
||||
{
|
||||
lCharactersToAdd = ipconfigRAND32() % ( 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 */
|
||||
|
582
FreeRTOS-Labs/Demo/Common/FreeRTOS_Plus_TCP_Demos/TFTPServer.c
Normal file
582
FreeRTOS-Labs/Demo/Common/FreeRTOS_Plus_TCP_Demos/TFTPServer.c
Normal file
|
@ -0,0 +1,582 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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!
|
||||
*/
|
||||
|
||||
/*
|
||||
* A basic TFTP server that can currently only be used to receive files, and not
|
||||
* send files. This is a slim implementation intended for use in boot loaders
|
||||
* and other applications that require over the air reception of files.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_Sockets.h"
|
||||
|
||||
/* FreeRTOS+FAT includes. */
|
||||
#include "ff_stdio.h"
|
||||
|
||||
#if( ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND != 1 )
|
||||
#error ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND must be set to one to use this TFTP server.
|
||||
#endif
|
||||
|
||||
#if( configTICK_RATE_HZ > 1000 )
|
||||
#error The TFTP server uses the pdMS_TO_TICKS() macro, so configTICK_RATE_HZ must be less than or equal to 1000
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTFTP_TIME_OUT_MS
|
||||
#define ipconfigTFTP_TIME_OUT_MS ( 10000 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTFTP_MAX_RETRIES
|
||||
#define ipconfigTFTP_MAX_RETRIES ( 6 )
|
||||
#endif
|
||||
|
||||
/* Standard/expected TFTP port number. */
|
||||
#define tftpPORT_NUMBER ( ( uint16_t ) 69 )
|
||||
|
||||
/* Offset to the file name within the frame. */
|
||||
#define tftpFILE_NAME_OFFSET ( 2 )
|
||||
|
||||
/* Number of bytes in the Ack message. */
|
||||
#define tftpACK_MESSAGE_LENGTH 4
|
||||
|
||||
/* Files are sent in fixed length blocks of 512 (the original maximum). */
|
||||
#define tftpMAX_DATA_LENGTH ( ( size_t ) 512 )
|
||||
|
||||
/* Standard TFTP opcodes. */
|
||||
typedef enum
|
||||
{
|
||||
eReadRequest = 1,
|
||||
eWriteRequest,
|
||||
eData,
|
||||
eAck,
|
||||
eError
|
||||
} eTFTPOpcode_t;
|
||||
|
||||
/* Error codes from the RFC. */
|
||||
typedef enum
|
||||
{
|
||||
eFileNotFound = 1,
|
||||
eAccessViolation,
|
||||
eDiskFull,
|
||||
eIllegalTFTPOperation,
|
||||
eUnknownTransferID,
|
||||
eFileAlreadyExists
|
||||
} eTFTPErrorCode_t;
|
||||
|
||||
/* Header used in data transfer packets. */
|
||||
#include "pack_struct_start.h"
|
||||
struct DataPacketHeader
|
||||
{
|
||||
uint16_t usOpcode;
|
||||
uint16_t usBlockNumber;
|
||||
}
|
||||
#include "pack_struct_end.h"
|
||||
typedef struct DataPacketHeader TFTPBlockNumberHeader_t;
|
||||
|
||||
/*
|
||||
* Manages a single TFTP connection at a time.
|
||||
*/
|
||||
static void prvSimpleTFTPServerTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Manage the reception of a file. If the file is received correctly then
|
||||
* return pdPASS, otherwise return pdFAIL.
|
||||
*/
|
||||
static BaseType_t prvReceiveFile( FF_FILE *pxFile, struct freertos_sockaddr *pxClient );
|
||||
|
||||
/*
|
||||
* Send an error frame to the client.
|
||||
*/
|
||||
static void prvSendTFTPError( Socket_t xSocket, struct freertos_sockaddr *pxClient, eTFTPErrorCode_t eErrorCode );
|
||||
|
||||
/*
|
||||
* Check a received write request contains a potentially valid file name string,
|
||||
* and is a binary mode transfer. If so return a pointer to the file name with
|
||||
* the write request packet received from the network, otherwise return NULL.
|
||||
*/
|
||||
static const char* prvValidateWriteRequest( Socket_t xSocket, struct freertos_sockaddr *pxClient, uint8_t *pucUDPPayloadBuffer );
|
||||
|
||||
/*
|
||||
* Called after a valid write request has been received to first check the file
|
||||
* does not already exist, and if the file does not exist, create the file ready
|
||||
* to be written. If the file did already exist, or if the file could not be
|
||||
* created, then NULL is returned - otherwise a handle to the created file is
|
||||
* returned.
|
||||
*/
|
||||
static FF_FILE* prvValidateFileToWrite( Socket_t xSocket, struct freertos_sockaddr *pxClient, const char *pcFileName );
|
||||
|
||||
/*
|
||||
* Send an acknowledgement packet to pxClient with block number usBlockNumber.
|
||||
*/
|
||||
static void prvSendAcknowledgement( Socket_t xSocket, struct freertos_sockaddr *pxClient, uint16_t usBlockNumber );
|
||||
|
||||
/* The index for the error string below MUST match the value of the applicable
|
||||
eTFTPErrorCode_t error code value. */
|
||||
static const char *cErrorStrings[] =
|
||||
{
|
||||
NULL, /* Not valid. */
|
||||
"File not found.",
|
||||
"Access violation.",
|
||||
"Disk full or allocation exceeded.",
|
||||
"Illegal TFTP operation.",
|
||||
"Unknown transfer ID.",
|
||||
"File already exists.",
|
||||
"No such user."
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vStartTFTPServerTask( uint16_t usStackSize, UBaseType_t uxPriority )
|
||||
{
|
||||
/* A single server task is created. Currently this is only capable of
|
||||
managing one TFTP transfer at a time. */
|
||||
xTaskCreate( prvSimpleTFTPServerTask, "TFTPd", usStackSize, NULL, uxPriority, NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSimpleTFTPServerTask( void *pvParameters )
|
||||
{
|
||||
int32_t lBytes;
|
||||
uint8_t *pucUDPPayloadBuffer;
|
||||
struct freertos_sockaddr xClient, xBindAddress;
|
||||
uint32_t xClientLength = sizeof( xClient ), ulIPAddress;
|
||||
Socket_t xTFTPListeningSocket;
|
||||
const char *pcFileName;
|
||||
FF_FILE *pxFile;
|
||||
|
||||
/* Just to prevent compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Attempt to open the socket. The receive block time defaults to the max
|
||||
delay, so there is no need to set that separately. */
|
||||
xTFTPListeningSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||
configASSERT( xTFTPListeningSocket != FREERTOS_INVALID_SOCKET );
|
||||
|
||||
/* Bind to the standard TFTP port. */
|
||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||
xBindAddress.sin_addr = ulIPAddress;
|
||||
xBindAddress.sin_port = FreeRTOS_htons( tftpPORT_NUMBER );
|
||||
FreeRTOS_bind( xTFTPListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Look for the start of a new transfer on the TFTP port. 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. */
|
||||
lBytes = FreeRTOS_recvfrom( xTFTPListeningSocket, ( void * ) &pucUDPPayloadBuffer, 0, FREERTOS_ZERO_COPY, &xClient, &xClientLength );
|
||||
|
||||
if( lBytes >= 0 )
|
||||
{
|
||||
/* Could this be a new write request? The opcode is contained in
|
||||
the first two bytes of the received data. */
|
||||
if( ( pucUDPPayloadBuffer[ 0 ] == ( uint8_t ) 0 ) && ( pucUDPPayloadBuffer[ 1 ] == ( uint8_t ) eWriteRequest ) )
|
||||
{
|
||||
/* If the write request is valid pcFileName will get set to
|
||||
point to the file name within pucWriteRequestBuffer - otherwise
|
||||
an appropriate error will be sent on xTFTPListeningSocket. */
|
||||
pcFileName = prvValidateWriteRequest( xTFTPListeningSocket, &xClient, pucUDPPayloadBuffer );
|
||||
|
||||
if( pcFileName != NULL )
|
||||
{
|
||||
/* If the file does not already exist, and can be created,
|
||||
then xFile will get set to the file's open handle.
|
||||
Otherwise an appropriate error will be sent on
|
||||
xTFTPListeningSocket. */
|
||||
pxFile = prvValidateFileToWrite( xTFTPListeningSocket, &xClient, pcFileName );
|
||||
|
||||
if( pxFile != NULL )
|
||||
{
|
||||
/* Manage reception of the file. */
|
||||
prvReceiveFile( pxFile, &xClient );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not a transfer ID handled by this server. */
|
||||
prvSendTFTPError( xTFTPListeningSocket, &xClient, eUnknownTransferID );
|
||||
}
|
||||
|
||||
/* The buffer was received using zero copy, so *must* be freed. */
|
||||
FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayloadBuffer );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t prvReceiveFile( FF_FILE *pxFile, struct freertos_sockaddr *pxClient )
|
||||
{
|
||||
BaseType_t xReturn = pdPASS, xRetries = 0;
|
||||
uint16_t usExpectedBlockNumber;
|
||||
Socket_t xTFTPRxSocket = FREERTOS_INVALID_SOCKET;
|
||||
TickType_t xRxTimeout = pdMS_TO_TICKS( ipconfigTFTP_TIME_OUT_MS );
|
||||
int32_t lBytes;
|
||||
uint8_t *pucFileBuffer;
|
||||
struct freertos_sockaddr xClient;
|
||||
uint32_t xClientLength = sizeof( xClient );
|
||||
TFTPBlockNumberHeader_t *pxHeader;
|
||||
size_t xBlocksWritten, xBytesOfFileDataReceived = tftpMAX_DATA_LENGTH;
|
||||
const size_t xBlocksToWrite = 1;
|
||||
|
||||
/* The file is open for writing, now create the socket on which the file
|
||||
will be received from the client. Note the socket is not bound here - so
|
||||
will be automatically bound to a port number selected by the IP stack when
|
||||
it is used for the first time. */
|
||||
xTFTPRxSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||
|
||||
if( xTFTPRxSocket != FREERTOS_INVALID_SOCKET )
|
||||
{
|
||||
/* The socket's Rx block time is set to the user configurable timeout
|
||||
value. */
|
||||
FreeRTOS_setsockopt( xTFTPRxSocket, 0, FREERTOS_SO_RCVTIMEO, &xRxTimeout, sizeof( xRxTimeout ) );
|
||||
|
||||
/* Acknowledge the write request so the client starts to send the file.
|
||||
The first acknowledgment does not have a corresponding block number so
|
||||
the special case block number 0 is used. */
|
||||
usExpectedBlockNumber = 0;
|
||||
|
||||
do
|
||||
{
|
||||
/* The acknowledgment sent here may be a duplicate if the last call
|
||||
to FreeRTOS_recvfrom() timee out. */
|
||||
prvSendAcknowledgement( xTFTPRxSocket, pxClient, usExpectedBlockNumber );
|
||||
|
||||
/* Wait for next data packet. Zero copy is used so it is the
|
||||
responsibility of this task to free the received data once it is no
|
||||
longer required. */
|
||||
lBytes = FreeRTOS_recvfrom( xTFTPRxSocket, ( void * ) &pucFileBuffer, 0, FREERTOS_ZERO_COPY, &xClient, &xClientLength );
|
||||
|
||||
if( lBytes == 0 )
|
||||
{
|
||||
/* Timed out. */
|
||||
FreeRTOS_printf( ( "Error: Timeout.\n" ) );
|
||||
xRetries++;
|
||||
|
||||
if( xRetries > ipconfigTFTP_MAX_RETRIES )
|
||||
{
|
||||
FreeRTOS_printf( ( "Error: Retry limit exceeded.\n" ) );
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Data received. It is expected to be the next sequential
|
||||
block. */
|
||||
usExpectedBlockNumber++;
|
||||
pxHeader = ( TFTPBlockNumberHeader_t * ) pucFileBuffer;
|
||||
pxHeader->usOpcode = FreeRTOS_ntohs( pxHeader->usOpcode );
|
||||
pxHeader->usBlockNumber = FreeRTOS_ntohs( pxHeader->usBlockNumber );
|
||||
|
||||
/* Is the data as expected and from the expected IP address and
|
||||
port? */
|
||||
if( ( pxHeader->usOpcode == ( uint16_t ) eData ) &&
|
||||
( pxHeader->usBlockNumber == usExpectedBlockNumber ) &&
|
||||
( pxClient->sin_addr == xClient.sin_addr ) &&
|
||||
( pxClient->sin_port == xClient.sin_port ) )
|
||||
{
|
||||
/* Everything in the packet other than the header is file
|
||||
data. */
|
||||
xBytesOfFileDataReceived = ( size_t ) lBytes - sizeof( TFTPBlockNumberHeader_t );
|
||||
FreeRTOS_printf( ( "Received %d bytes of file data.\n", ( int ) xBytesOfFileDataReceived ) );
|
||||
|
||||
/* Ack the data then write the data to the file. */
|
||||
prvSendAcknowledgement( xTFTPRxSocket, pxClient, usExpectedBlockNumber );
|
||||
|
||||
/* The data is located by jumping over the header. */
|
||||
/*_RB_ Is it ok to write 0 bytes? */
|
||||
xBlocksWritten = ff_fwrite( pucFileBuffer + sizeof( TFTPBlockNumberHeader_t ),
|
||||
xBytesOfFileDataReceived,
|
||||
xBlocksToWrite,
|
||||
pxFile );
|
||||
|
||||
if( xBlocksWritten != xBlocksToWrite )
|
||||
{
|
||||
/* File could not be written. */
|
||||
prvSendTFTPError( xTFTPRxSocket, pxClient, eDiskFull );
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
|
||||
/* Start to receive the next block. */
|
||||
xRetries = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prvSendTFTPError( xTFTPRxSocket, pxClient, eIllegalTFTPOperation );
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
|
||||
/* pucFileBuffer was obtained using zero copy mode, so the
|
||||
buffer must be freed now its contents have been written to the
|
||||
disk. */
|
||||
FreeRTOS_ReleaseUDPPayloadBuffer( pucFileBuffer );
|
||||
}
|
||||
|
||||
/* Until a disk write fails, or the maximum number of retries is
|
||||
exceeded, or fewer bytes than tftpMAX_DATA_LENGTH are received (which
|
||||
indicates the end of the file). */
|
||||
} while( ( xReturn != pdFAIL ) && ( xBytesOfFileDataReceived == tftpMAX_DATA_LENGTH ) );
|
||||
|
||||
FreeRTOS_printf( ( "Closing connection.\n" ) );
|
||||
FreeRTOS_closesocket( xTFTPRxSocket );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* An error could be returned here, but it is probably cleaner to just
|
||||
time out as the error would have to be sent via the listening socket
|
||||
outside of this function. */
|
||||
FreeRTOS_printf( ( "Could not create socket to receive file.\n" ) );
|
||||
}
|
||||
|
||||
ff_fclose( pxFile );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void prvSendAcknowledgement( Socket_t xSocket, struct freertos_sockaddr *pxClient, uint16_t usBlockNumber )
|
||||
{
|
||||
/* Small fixed size buffer, so not much to be gained by using the zero copy
|
||||
interface, just send the buffer directly. */
|
||||
TFTPBlockNumberHeader_t xAckMessage;
|
||||
|
||||
xAckMessage.usOpcode = FreeRTOS_htons( ( ( uint16_t ) eAck ) );
|
||||
xAckMessage.usBlockNumber = FreeRTOS_htons( usBlockNumber );
|
||||
FreeRTOS_sendto( xSocket, ( void * ) &xAckMessage, tftpACK_MESSAGE_LENGTH, 0, pxClient, sizeof( struct freertos_sockaddr ) );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static FF_FILE* prvValidateFileToWrite( Socket_t xSocket, struct freertos_sockaddr *pxClient, const char *pcFileName )
|
||||
{
|
||||
FF_FILE *pxFile;
|
||||
|
||||
FreeRTOS_printf( ( "Write request for %s received\n", pcFileName ) );
|
||||
|
||||
/* The file cannot be received if it already exists. Attempt to open the
|
||||
file in read mode to see if it exists. */
|
||||
pxFile = ff_fopen( pcFileName, "r" );
|
||||
|
||||
if( pxFile != NULL )
|
||||
{
|
||||
/* Can't receive a new file without deleting the old one first. */
|
||||
ff_fclose( pxFile );
|
||||
pxFile = NULL;
|
||||
prvSendTFTPError( xSocket, pxClient, eFileAlreadyExists );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The file does not already exist. Attempt to open the file in write
|
||||
mode, which will cause it to be created. */
|
||||
pxFile = ff_fopen( pcFileName, "w" );
|
||||
|
||||
if( pxFile == NULL )
|
||||
{
|
||||
/* The file cannot be created. */
|
||||
prvSendTFTPError( xSocket, pxClient, eAccessViolation );
|
||||
}
|
||||
}
|
||||
|
||||
return pxFile;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static const char* prvValidateWriteRequest( Socket_t xSocket, struct freertos_sockaddr *pxClient, uint8_t *pucUDPPayloadBuffer )
|
||||
{
|
||||
char *pcFileName;
|
||||
BaseType_t x;
|
||||
const char *pcOctedMode = "octet";
|
||||
|
||||
/* pcFileName is set to point to the file name which is inside the write
|
||||
request frame, so its important not to free the frame until the operation is
|
||||
over. The start of the file name string is after the opcode, so two bytes
|
||||
into the packet. */
|
||||
pcFileName = ( char * ) &( pucUDPPayloadBuffer[ tftpFILE_NAME_OFFSET ] );
|
||||
|
||||
/* Sanity check the file name. */
|
||||
for( x = 0; x < ffconfigMAX_FILENAME; x++ )
|
||||
{
|
||||
if( pcFileName[ x ] == 0x00 )
|
||||
{
|
||||
/* The end of the string was located. */
|
||||
break;
|
||||
}
|
||||
else if( ( pcFileName[ x ] < ' ' ) || ( pcFileName[ x ] > '~' ) )
|
||||
{
|
||||
/* Not a valid file name character. */
|
||||
pcFileName = NULL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just a character in the file name. */
|
||||
}
|
||||
}
|
||||
|
||||
if( pcFileName != NULL )
|
||||
{
|
||||
/* Only binary transfers are supported, indicated by an 'octet' mode
|
||||
string following the file name. +1 to move past the null terminator to
|
||||
the start of the next string. */
|
||||
x++;
|
||||
if( strcmpi( pcOctedMode, ( const char * ) &( pucUDPPayloadBuffer[ tftpFILE_NAME_OFFSET + x ] ) ) != 0 )
|
||||
{
|
||||
/* Not the expected mode. */
|
||||
prvSendTFTPError( xSocket, pxClient, eIllegalTFTPOperation );
|
||||
pcFileName = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prvSendTFTPError( xSocket, pxClient, eFileNotFound );
|
||||
}
|
||||
|
||||
return pcFileName;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSendTFTPError( Socket_t xSocket, struct freertos_sockaddr *pxClient, eTFTPErrorCode_t eErrorCode )
|
||||
{
|
||||
uint8_t *pucUDPPayloadBuffer = NULL;
|
||||
const size_t xFixedSizePart = ( size_t ) 5; /* 2 byte opcode, plus two byte error code, plus string terminating 0. */
|
||||
const size_t xNumberOfErrorStrings = sizeof( cErrorStrings ) / sizeof( char * );
|
||||
size_t xErrorCode = ( size_t ) eErrorCode, xTotalLength = 0; /* Only initialised to keep compiler quiet. */
|
||||
const char *pcErrorString = NULL;
|
||||
int32_t lReturned;
|
||||
|
||||
/* The total size of the packet to be sent depends on the length of the
|
||||
error string. */
|
||||
if( xErrorCode < xNumberOfErrorStrings )
|
||||
{
|
||||
pcErrorString = cErrorStrings[ xErrorCode ];
|
||||
|
||||
/* 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
|
||||
error packet will be written. Although a max delay is used, the actual
|
||||
delay will be capped to ipconfigMAX_SEND_BLOCK_TIME_TICKS. */
|
||||
xTotalLength = strlen( pcErrorString ) + xFixedSizePart;
|
||||
pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xTotalLength, portMAX_DELAY );
|
||||
}
|
||||
|
||||
if( pucUDPPayloadBuffer != NULL )
|
||||
{
|
||||
FreeRTOS_printf( ( "Error: %s\n", pcErrorString ) );
|
||||
|
||||
/* Create error packet: Opcode. */
|
||||
pucUDPPayloadBuffer[ 0 ] = 0;
|
||||
pucUDPPayloadBuffer[ 1 ] = ( uint8_t ) eError;
|
||||
|
||||
/* Create error packet: Error code. */
|
||||
pucUDPPayloadBuffer[ 2 ] = 0;
|
||||
pucUDPPayloadBuffer[ 3 ] = ( uint8_t ) eErrorCode;
|
||||
|
||||
/* Create error packet: Error string. */
|
||||
strcpy( ( ( char * ) &( pucUDPPayloadBuffer[ 4 ] ) ), pcErrorString );
|
||||
|
||||
/* 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( xSocket, /* The socket to which the error frame is sent. */
|
||||
( void * ) pucUDPPayloadBuffer, /* A pointer to the the data being sent. */
|
||||
xTotalLength, /* The length of the data being sent. */
|
||||
FREERTOS_ZERO_COPY, /* ulFlags with the FREERTOS_ZERO_COPY bit set. */
|
||||
pxClient, /* Where the data is being sent. */
|
||||
sizeof( *pxClient ) );
|
||||
|
||||
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(). */
|
||||
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. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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!
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file, along with DemoIPTrace.h, provides a basic example use of the
|
||||
* FreeRTOS+TCP trace macros. The statistics gathered here can be viewed in
|
||||
* the command line interface.
|
||||
* See http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_CLI.html
|
||||
*
|
||||
* A simple generic mechanism is used that allocates a structure (see the
|
||||
* ExampleDebugStatEntry_t definition in DemoIPTrace.h) to each ID defined in
|
||||
* the same header file. The structures are stored in an array (see the
|
||||
* xIPTraceValues[] below.
|
||||
*
|
||||
* The structure associates a function with a data value. See the
|
||||
* vPerformAction and ulData members of ExampleDebugStatEntry_t respectively.
|
||||
* The function is used to manipulate the data. At the time of writing two
|
||||
* functions can be used - these are prvIncrementEventCount() which simply
|
||||
* increments the data each time it is called, and prvStoreLowest() which
|
||||
* sets the data to the lowest value of an input parameter ever seen. For
|
||||
* example, to store the lowest ever number of free network buffer descriptors
|
||||
* the parameter value is the current number of network buffer descriptors.
|
||||
*
|
||||
* The trace macros themselves are defined in DemoIPTrace.h and just invoke
|
||||
* vExampleDebugStatUpdate(), passing in an ID value. vExampleDebugStatUpdate()
|
||||
* then just executes the function associated with that value (prvStoreLowest(),
|
||||
* prvIncrementEventCount(), etc.) as defined in the xIPTraceValues[] array.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_UDP_IP.h"
|
||||
#include "DemoIPTrace.h"
|
||||
|
||||
/* It is possible to remove the trace macros using the
|
||||
configINCLUDE_DEMO_DEBUG_STATS setting in FreeRTOSIPConfig.h. */
|
||||
#if configINCLUDE_DEMO_DEBUG_STATS == 1
|
||||
|
||||
/*
|
||||
* Each row in the xIPTraceValues[] table contains a pointer to a function that
|
||||
* updates the value for that row. Rows that latch the lowest value point to
|
||||
* this function (for example, this function can be used to latch the lowest
|
||||
* number of network buffers that were available during the execution of the
|
||||
* stack).
|
||||
*/
|
||||
static void prvStoreLowest( uint32_t *pulCurrentValue, uint32_t ulCount );
|
||||
|
||||
/*
|
||||
* Each row in the xIPTraceValues[] table contains a pointer to a function that
|
||||
* updates the value for that row. Rows that simply increment an event count
|
||||
* point to this function.
|
||||
*/
|
||||
static void prvIncrementEventCount( uint32_t *pulCurrentValue, uint32_t ulCount );
|
||||
|
||||
/* The header file defines the IDs within this table. The string is used to
|
||||
print a friendly message for the stat, and the function pointer is used to
|
||||
perform the action for the state - for example, note the lowest ever value for
|
||||
a stat, or just count the number of times the event occurs. */
|
||||
ExampleDebugStatEntry_t xIPTraceValues[] =
|
||||
{
|
||||
/* Comment out array entries to remove individual trace items. */
|
||||
|
||||
{ iptraceID_NETWORK_INTERFACE_RECEIVE, "Packets received by the network interface", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_NETWORK_INTERFACE_TRANSMIT, "Count of transmitted packets", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_PACKET_DROPPED_TO_GENERATE_ARP, "Count of packets dropped to generate ARP", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_NETWORK_BUFFER_OBTAINED, "Lowest ever available network buffers", prvStoreLowest, 0xffffUL },
|
||||
{ iptraceID_NETWORK_EVENT_RECEIVED, "Lowest ever free space in network event queue", prvStoreLowest, 0xffffUL },
|
||||
{ iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER, "Count of failed attempts to obtain a network buffer", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_ARP_TABLE_ENTRY_EXPIRED, "Count of expired ARP entries", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_FAILED_TO_CREATE_SOCKET, "Count of failures to create a socket", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_RECVFROM_DISCARDING_BYTES, "Count of times recvfrom() has discarding bytes", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_ETHERNET_RX_EVENT_LOST, "Count of lost Etheret Rx events (event queue full?)", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_STACK_TX_EVENT_LOST, "Count of lost IP stack events (event queue full?)", prvIncrementEventCount, 0 },
|
||||
{ ipconfigID_BIND_FAILED, "Count of failed calls to bind()", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_RECVFROM_TIMEOUT, "Count of receive timeouts", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_SENDTO_DATA_TOO_LONG, "Count of failed sends due to oversized payload", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_SENDTO_SOCKET_NOT_BOUND, "Count of failed sends due to unbound socket", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_NO_BUFFER_FOR_SENDTO, "Count of failed transmits due to timeout", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, "Number of times task had to wait to obtain a DMA Tx descriptor", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, "Failed to notify select group", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_TOTAL_NETWORK_BUFFERS_OBTAINED, "Total network buffers obtained", prvIncrementEventCount, 0 },
|
||||
{ iptraceID_TOTAL_NETWORK_BUFFERS_RELEASED, "Total network buffers released", prvIncrementEventCount, 0 }
|
||||
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xExampleDebugStatEntries( void )
|
||||
{
|
||||
/* Return the number of entries in the xIPTraceValues[] table. */
|
||||
return ( BaseType_t ) ( sizeof( xIPTraceValues ) / sizeof( ExampleDebugStatEntry_t ) );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vExampleDebugStatUpdate( uint8_t ucIdentifier, uint32_t ulValue )
|
||||
{
|
||||
BaseType_t xIndex;
|
||||
const BaseType_t xEntries = sizeof( xIPTraceValues ) / sizeof( ExampleDebugStatEntry_t );
|
||||
|
||||
/* Update an entry in the xIPTraceValues[] table. Each row in the table
|
||||
includes a pointer to a function that performs the actual update. This
|
||||
function just executes the update function from that table row.
|
||||
|
||||
Search the array to find the identifier - this could be made more efficient
|
||||
by using the identifier as an index into the array - but that would come
|
||||
with the usability cost of needing to change all the identifiers above any
|
||||
identifiers that are later inserted into the table. */
|
||||
for( xIndex = 0; xIndex < xEntries; xIndex++ )
|
||||
{
|
||||
if( xIPTraceValues[ xIndex ].ucIdentifier == ucIdentifier )
|
||||
{
|
||||
xIPTraceValues[ xIndex ].vPerformAction( &( xIPTraceValues[ xIndex ].ulData ), ulValue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
configASSERT( xIndex != xEntries );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvIncrementEventCount( uint32_t *pulCurrentValue, uint32_t ulCount )
|
||||
{
|
||||
/* Each row in the xIPTraceValues[] table contains a pointer to a function
|
||||
that updates the value for that row. Rows that simply increment an event
|
||||
count point to this function. */
|
||||
( void ) ulCount;
|
||||
( *pulCurrentValue )++;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvStoreLowest( uint32_t *pulCurrentValue, uint32_t ulCount )
|
||||
{
|
||||
/* Each row in the xIPTraceValues[] table contains a pointer to a function
|
||||
that updates the value for that row. Rows that latch the lowest value
|
||||
point to this function (for example, this function can be used to latch
|
||||
the lowest number of network buffers that were available during the
|
||||
execution of the stack). */
|
||||
if( ulCount < *pulCurrentValue )
|
||||
{
|
||||
*pulCurrentValue = ulCount;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif /* configINCLUDE_DEMO_DEBUG_STATS == 1 */
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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!
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file, along with DemoIPTrace.c, provides a basic example use of the
|
||||
* FreeRTOS+TCP trace macros. The statistics gathered here can be viewed in
|
||||
* the command line interface.
|
||||
* See http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_CLI.html
|
||||
*
|
||||
* A simple generic mechanism is used that allocates a structure (see the
|
||||
* ExampleDebugStatEntry_t definition below) to each ID defined in this file.
|
||||
* The structures are stored in an array (see the xIPTraceValues[] array in
|
||||
* DemoIPTrace.c).
|
||||
*
|
||||
* The structure associates a function with a data value. See the
|
||||
* vPerformAction and ulData members of ExampleDebugStatEntry_t respectively.
|
||||
* The function is used to manipulate the data. At the time of writing two
|
||||
* functions can be used - these are prvIncrementEventCount() which simply
|
||||
* increments the data each time it is called, and prvStoreLowest() which
|
||||
* sets the data to the lowest value of an input parameter ever seen. For
|
||||
* example, to store the lowest ever number of free network buffer descriptors
|
||||
* the parameter value is the current number of network buffer descriptors.
|
||||
*
|
||||
* The trace macros themselves are defined in this file and just invoke
|
||||
* vExampleDebugStatUpdate(), passing in an ID value. vExampleDebugStatUpdate()
|
||||
* then just executes the function associated with that value (prvStoreLowest(),
|
||||
* prvIncrementEventCount(), etc.) as defined in the xIPTraceValues[] array.
|
||||
*/
|
||||
|
||||
#ifndef DEMO_IP_TRACE_MACROS_H
|
||||
#define DEMO_IP_TRACE_MACROS_H
|
||||
|
||||
typedef void ( *vTraceAction_t )( uint32_t *, uint32_t );
|
||||
|
||||
/* Type that defines each statistic being gathered. */
|
||||
typedef struct ExampleDebugStatEntry
|
||||
{
|
||||
uint8_t ucIdentifier; /* Unique identifier for statistic. */
|
||||
const char * const pucDescription; /* Text description for the statistic. */
|
||||
vTraceAction_t vPerformAction; /* Action to perform when the statistic is updated (increment counter, store minimum value, store maximum value, etc. */
|
||||
uint32_t ulData; /* The meaning of this data is dependent on the trace macro ID. */
|
||||
} ExampleDebugStatEntry_t;
|
||||
|
||||
/* Unique identifiers used to locate the entry for each trace macro in the
|
||||
xIPTraceValues[] table defined in DemoIPTrace.c. See the comments at the top of
|
||||
this file. */
|
||||
#define iptraceID_NETWORK_INTERFACE_RECEIVE 0
|
||||
#define iptraceID_NETWORK_INTERFACE_TRANSMIT 1
|
||||
#define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP 2
|
||||
#define iptraceID_NETWORK_BUFFER_OBTAINED 3
|
||||
#define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR 4
|
||||
#define iptraceID_NETWORK_EVENT_RECEIVED 5
|
||||
#define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER 6
|
||||
#define iptraceID_ARP_TABLE_ENTRY_EXPIRED 7
|
||||
#define iptraceID_FAILED_TO_CREATE_SOCKET 8
|
||||
#define iptraceID_RECVFROM_DISCARDING_BYTES 9
|
||||
#define iptraceID_ETHERNET_RX_EVENT_LOST 10
|
||||
#define iptraceID_STACK_TX_EVENT_LOST 11
|
||||
#define ipconfigID_BIND_FAILED 12
|
||||
#define iptraceID_RECVFROM_TIMEOUT 13
|
||||
#define iptraceID_SENDTO_DATA_TOO_LONG 14
|
||||
#define iptraceID_SENDTO_SOCKET_NOT_BOUND 15
|
||||
#define iptraceID_NO_BUFFER_FOR_SENDTO 16
|
||||
#define iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR 17
|
||||
#define iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP 18
|
||||
#define iptraceID_TOTAL_NETWORK_BUFFERS_OBTAINED 19
|
||||
#define iptraceID_TOTAL_NETWORK_BUFFERS_RELEASED 20
|
||||
|
||||
/* It is possible to remove the trace macros using the
|
||||
configINCLUDE_DEMO_DEBUG_STATS setting in FreeRTOSIPConfig.h. */
|
||||
#if configINCLUDE_DEMO_DEBUG_STATS == 1
|
||||
|
||||
/* The trace macro definitions themselves. Any trace macros left undefined
|
||||
will default to be empty macros. See the comments at the top of this
|
||||
file. */
|
||||
#define iptraceNETWORK_BUFFER_OBTAINED( pxBufferAddress ) vExampleDebugStatUpdate( iptraceID_NETWORK_BUFFER_OBTAINED, uxQueueMessagesWaiting( ( QueueHandle_t ) xNetworkBufferSemaphore ) ); vExampleDebugStatUpdate( iptraceID_TOTAL_NETWORK_BUFFERS_OBTAINED, 0 )
|
||||
#define iptraceNETWORK_BUFFER_RELEASED( pxBufferAddress ) vExampleDebugStatUpdate( iptraceID_TOTAL_NETWORK_BUFFERS_RELEASED, 0 )
|
||||
#define iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR( pxBufferAddress ) vExampleDebugStatUpdate( iptraceID_NETWORK_BUFFER_OBTAINED, uxQueueMessagesWaiting( ( QueueHandle_t ) xNetworkBufferSemaphore ) )
|
||||
|
||||
#define iptraceNETWORK_EVENT_RECEIVED( eEvent ) { \
|
||||
uint16_t usSpace; \
|
||||
usSpace = ( uint16_t ) uxQueueMessagesWaiting( xNetworkEventQueue ); \
|
||||
/* Minus one as an event was removed before the space was queried. */ \
|
||||
usSpace = ( ipconfigEVENT_QUEUE_LENGTH - usSpace ) - 1; \
|
||||
vExampleDebugStatUpdate( iptraceID_NETWORK_EVENT_RECEIVED, usSpace ); \
|
||||
}
|
||||
|
||||
#define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER() vExampleDebugStatUpdate( iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER, 0 )
|
||||
#define iptraceARP_TABLE_ENTRY_EXPIRED( ulIPAddress ) vExampleDebugStatUpdate( iptraceID_ARP_TABLE_ENTRY_EXPIRED, 0 )
|
||||
#define iptracePACKET_DROPPED_TO_GENERATE_ARP( ulIPAddress ) vExampleDebugStatUpdate( iptraceID_PACKET_DROPPED_TO_GENERATE_ARP, 0 )
|
||||
#define iptraceFAILED_TO_CREATE_SOCKET() vExampleDebugStatUpdate( iptraceID_FAILED_TO_CREATE_SOCKET, 0 )
|
||||
#define iptraceRECVFROM_DISCARDING_BYTES( xNumberOfBytesDiscarded ) vExampleDebugStatUpdate( iptraceID_RECVFROM_DISCARDING_BYTES, 0 )
|
||||
#define iptraceETHERNET_RX_EVENT_LOST() vExampleDebugStatUpdate( iptraceID_ETHERNET_RX_EVENT_LOST, 0 )
|
||||
#define iptraceSTACK_TX_EVENT_LOST( xEvent ) vExampleDebugStatUpdate( iptraceID_STACK_TX_EVENT_LOST, 0 )
|
||||
#define iptraceBIND_FAILED( xSocket, usPort ) vExampleDebugStatUpdate( ipconfigID_BIND_FAILED, 0 )
|
||||
#define iptraceNETWORK_INTERFACE_TRANSMIT() vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_TRANSMIT, 0 )
|
||||
#define iptraceRECVFROM_TIMEOUT() vExampleDebugStatUpdate( iptraceID_RECVFROM_TIMEOUT, 0 )
|
||||
#define iptraceSENDTO_DATA_TOO_LONG() vExampleDebugStatUpdate( iptraceID_SENDTO_DATA_TOO_LONG, 0 )
|
||||
#define iptraceSENDTO_SOCKET_NOT_BOUND() vExampleDebugStatUpdate( iptraceID_SENDTO_SOCKET_NOT_BOUND, 0 )
|
||||
#define iptraceNO_BUFFER_FOR_SENDTO() vExampleDebugStatUpdate( iptraceID_NO_BUFFER_FOR_SENDTO, 0 )
|
||||
#define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR() vExampleDebugStatUpdate( iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, 0 )
|
||||
#define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket ) vExampleDebugStatUpdate( iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, 0 )
|
||||
#define iptraceNETWORK_INTERFACE_RECEIVE() vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_RECEIVE, 0 )
|
||||
|
||||
/*
|
||||
* The function that updates a line in the xIPTraceValues table.
|
||||
*/
|
||||
void vExampleDebugStatUpdate( uint8_t ucIdentifier, uint32_t ulValue );
|
||||
|
||||
/*
|
||||
* Returns the number of entries in the xIPTraceValues table.
|
||||
*/
|
||||
BaseType_t xExampleDebugStatEntries( void );
|
||||
|
||||
#endif /* configINCLUDE_DEMO_DEBUG_STATS == 1 */
|
||||
|
||||
|
||||
#endif /* DEMO_IP_TRACE_MACROS_H */
|
||||
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
|
@ -0,0 +1,100 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
FreeRTOS+TCP and FreeRTOS+FAT HTTP Web Server Default Web Page
|
||||
</title>
|
||||
<style>
|
||||
H1 {color: #1a3065; font-size:27px; line-height: 30px;}
|
||||
H1 small {font-size:16px;}
|
||||
H2 {color: #1a3065; font-size:22px;}
|
||||
H3 {color: #1a3065; font-size:18px; line-height: normal;}
|
||||
H3 small {color: #1a3065; font-size:15px;}
|
||||
H4 {color: #1a3065}
|
||||
TABLE { font-size: 14px; line-height: 1.5em; }
|
||||
TABLE.text_ad { line-height: normal; }
|
||||
A:visited {text-decoration: none; color: #0000ee}
|
||||
A:hover { text-decoration: none; }
|
||||
a {text-decoration: none;}
|
||||
BODY {
|
||||
color: #202020;
|
||||
font-family: arial, helvetica, serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5em;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-top:0px;
|
||||
background: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table style="height:100%; width:1008px; background:white; border-right:solid 1px #e6e6e6; border-left:solid 1px #e6e6e6;" cellpadding="5" cellspacing="0" align="center">
|
||||
<tr valign="top">
|
||||
<td style="width:100%; height:100px;"> <!-- Spans the left menu, blank line, and main content columns of the next row. -->
|
||||
<font face="Arial, Helvetica">
|
||||
<table style="width:100%;" cellspacing="2" cellpadding="0" border="0"> <!-- Rows for logos and banners, blue lines with menu. -->
|
||||
<tr style="padding: 0px 0px 0px 0px;"> <!-- Top row, banner and logo. -->
|
||||
<td>
|
||||
<table width="100%" cellpadding="0" cellspacing="5px">
|
||||
<tr>
|
||||
<td style="line-height:normal;" valign="middle" width="174px">
|
||||
<div style="float:left;">
|
||||
<img src="logo.jpg" alt="Free RTOS logo" width="164px" border="0" style="padding: 0 0 0 5px;">
|
||||
</div>
|
||||
</td>
|
||||
<td style="width:5px; border-top:solid 2px #e6e6e6; border-left:solid 2px #e6e6e6; border-bottom:solid 2px #e6e6e6;">
|
||||
|
||||
</td>
|
||||
<td valign="middle" style="line-height:normal;">
|
||||
<h3>
|
||||
Default Web Page
|
||||
</h3>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height:5px;" bgcolor="#7095d3"> <!-- Blank line. -->
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height:19px;" bgcolor="#b6cffe"> <!-- Horizontal menu. -->
|
||||
<td valign="middle" bgcolor="#b6cffe">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"> <!-- Main content row with menu and content area columns. -->
|
||||
<td style="padding: 20px 20px 20px 20px;">
|
||||
<div style="float:right;" align="center">
|
||||
<img src="ftp.png">
|
||||
<small>
|
||||
<br>
|
||||
<b>
|
||||
FTP'ing web content into /ram/websrc
|
||||
</b>
|
||||
</small>
|
||||
</div>
|
||||
<h1>
|
||||
FreeRTOS+TCP Web Server
|
||||
</h1>
|
||||
This is the default page being served by the FreeRTOS+TCP
|
||||
web server, with files served from a disk implemented
|
||||
using FreeRTOS+FAT.
|
||||
<p>
|
||||
The HTTP root directory is set by the configHTTP_ROOT constant
|
||||
in FreeRTOSConfig.h. These default web pages can be replaced
|
||||
with new web content by FTP'ing files into that directory.
|
||||
<p>
|
||||
<b>NOTE:</b> Performance will be limited when using the
|
||||
FreeRTOS Windows port.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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,82 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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 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,79 @@
|
|||
/*
|
||||
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
|
||||
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 TFTP_SERVER_TASK_H
|
||||
#define TFTP_SERVER_TASK_H
|
||||
|
||||
/*
|
||||
* Create the task that manages TFTP transfers (one at a time).
|
||||
*/
|
||||
void vStartTFTPServerTask( uint16_t usStackSize, UBaseType_t uxPriority );
|
||||
|
||||
#endif /* TFTP_SERVER_TASK_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue