mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-21 22:11:57 -04:00
FreeRTOS+TCP: Added ipconfigSOCKET_HAS_USER_WAKE_CALLBACK configuration option so the user can specify a callback to execute when data arrives.
FreeRTOS+TCP: Improve print output when using WinPCap to assist in selecting the correct network interface. FreeRTOS kernel: Fix extern "C" { in stream_buffer.h. FreeRTOS kernel: Correct tskKERNEL_VERSION_NUMBER and tskKERNEL_VERSION_MAJOR constants for V10. Ensure the currently executing task is printed correctly in vTaskList().
This commit is contained in:
parent
cfc268814a
commit
0d903cf2d6
|
@ -150,7 +150,7 @@ example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
|
|||
results in the wired network being used, while setting
|
||||
configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
|
||||
used. */
|
||||
#define configNETWORK_INTERFACE_TO_USE 4L
|
||||
#define configNETWORK_INTERFACE_TO_USE 2L
|
||||
|
||||
/* The address of an echo server that will be used by the two demo echo client
|
||||
tasks.
|
||||
|
|
|
@ -1438,10 +1438,23 @@ FreeRTOS_Socket_t *pxSocket;
|
|||
case FREERTOS_SO_SET_SEMAPHORE:
|
||||
{
|
||||
pxSocket->pxUserSemaphore = *( ( SemaphoreHandle_t * ) pvOptionValue );
|
||||
}
|
||||
xReturn = 0;
|
||||
}
|
||||
break;
|
||||
#endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */
|
||||
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK != 0 )
|
||||
case FREERTOS_SO_WAKEUP_CALLBACK:
|
||||
{
|
||||
/* Each socket can have a callback function that is executed
|
||||
when there is an event the socket's owner might want to
|
||||
process. */
|
||||
pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue;
|
||||
xReturn = 0;
|
||||
}
|
||||
break;
|
||||
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */
|
||||
|
||||
case FREERTOS_SO_SNDBUF: /* Set the size of the send buffer, in units of MSS (TCP only) */
|
||||
case FREERTOS_SO_RCVBUF: /* Set the size of the receive buffer, in units of MSS (TCP only) */
|
||||
{
|
||||
|
@ -1839,6 +1852,15 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
|
|||
}
|
||||
#endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */
|
||||
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 )
|
||||
{
|
||||
if( pxSocket->pxUserWakeCallback != NULL )
|
||||
{
|
||||
pxSocket->pxUserWakeCallback( pxSocket );
|
||||
}
|
||||
}
|
||||
#endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */
|
||||
|
||||
#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
|
||||
{
|
||||
if( pxSocket->pxSocketSet != NULL )
|
||||
|
@ -2854,7 +2876,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
|
|||
|
||||
#if( ipconfigUSE_TCP == 1 )
|
||||
|
||||
static StreamBuffer_t *prvTCPCreateStream ( FreeRTOS_Socket_t *pxSocket, BaseType_t xIsInputStream )
|
||||
static StreamBuffer_t *prvTCPCreateStream( FreeRTOS_Socket_t *pxSocket, BaseType_t xIsInputStream )
|
||||
{
|
||||
StreamBuffer_t *pxBuffer;
|
||||
size_t uxLength;
|
||||
|
@ -2880,7 +2902,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
|
|||
if( pxSocket->u.xTCP.uxLittleSpace == 0ul )
|
||||
{
|
||||
pxSocket->u.xTCP.uxLittleSpace = ( 1ul * pxSocket->u.xTCP.uxRxStreamSize ) / 5u; /*_RB_ Why divide by 5? Can this be changed to a #define? */
|
||||
if( (pxSocket->u.xTCP.uxLittleSpace < pxSocket->u.xTCP.usCurMSS ) && ( pxSocket->u.xTCP.uxRxStreamSize >= 2 * pxSocket->u.xTCP.usCurMSS ) )
|
||||
if( ( pxSocket->u.xTCP.uxLittleSpace < pxSocket->u.xTCP.usCurMSS ) && ( pxSocket->u.xTCP.uxRxStreamSize >= 2u * pxSocket->u.xTCP.usCurMSS ) )
|
||||
{
|
||||
pxSocket->u.xTCP.uxLittleSpace = pxSocket->u.xTCP.usCurMSS;
|
||||
}
|
||||
|
|
|
@ -1,37 +1,81 @@
|
|||
Changes since the 160112 release
|
||||
Changes since V2.0.0 release
|
||||
|
||||
FTP : now has ipconfigFTP_HAS_USER_PROPERTIES_HOOK
|
||||
Each user can be assigned a different root directory and different access rights.
|
||||
Read-only access for FTP is now possible.
|
||||
+ Added FREERTOS_SO_WAKEUP_CALLBACK option so a callback can be executed
|
||||
when data arrives.
|
||||
+ Improve print output when using WinPCap to assist in selecting the
|
||||
correct network interface.
|
||||
|
||||
Adapted to comply a bit more to MISRA rules.
|
||||
The introduction of unsigned true/false, e.g. pdTRUE_UNSIGNED.
|
||||
Changes between 160908 and 160919 releases:
|
||||
|
||||
'ipBUFFER_PADDING' now configurable (expert option).
|
||||
+ Add a NULL check before attempting to close the DHCP socket. [Prior to
|
||||
160823 the IP task closed the DHCP socket by calling a public API function
|
||||
- which checked for the socket being NULL. This was changed to call a
|
||||
local private function, which did not have a NULL check, in place of the
|
||||
public API function.]
|
||||
+ Various [internal only] naming changes to better comply with the FreeRTOS
|
||||
naming conventions.
|
||||
+ Improvements to the Zynq network driver. DMA transmission buffers now use
|
||||
a counting semaphore. When all TX-buffers are in-use, the IP-task will
|
||||
block momentarily until a TX-buffer becomes available.
|
||||
+ Experimental implementation of the TCP window scaling protocol. The
|
||||
scaling option will always be offered, at least with a factor 1. If the
|
||||
TCP sliding window size becomes more than 64KB, the factor will increase
|
||||
automatically.
|
||||
+ ipconfigETHERNET_MINIMUM_PACKET_BYTES is now applied for every protocol:
|
||||
TCP, UDP, and ARP.
|
||||
+ Updated the Zynq project to use BufferAllocation_1.c rather than
|
||||
BufferAllocation_2.c - which is a requirement with its current
|
||||
configuration (due to the alignment requirements on the combined cache and
|
||||
DMA configuration).
|
||||
|
||||
Added ipconfigFTP_HAS_USER_PROPERTIES_HOOK.
|
||||
ipconfigHAS_TX_CRC_OFFLOADING
|
||||
Improve support for read only file systems in the FTP server.
|
||||
Changes between 160823 and 160908 releases:
|
||||
|
||||
Depending on priorities: FreeRTOS_accept() could fail if the priority of the application task is higher than the priority of the IP-task. Now with a higher priority FreeRTOS_accept() will still work correctly.
|
||||
+ Use ipconfigZERO_COPY_TX_DRIVER as the xReleaseAfterSend() parameter where
|
||||
prvTCPReturnPacket() is called in prvSendData() to prevent unnecessary
|
||||
copying of data.
|
||||
+ Remove the use of the uxGetRxEventCount variable, which was used to give
|
||||
priority to incoming messages, but could result in the IP task starving
|
||||
application tasks of processing time.
|
||||
|
||||
Depending on the tick rate: A TCP socket could freeze (stop working) when the FreeRTOS tick rate was lower than 1,000 Hz. Now also tested with 100 Hz.
|
||||
Changes between 160112 and 160823 releases
|
||||
|
||||
When "ipconfigZERO_COPY_TX_DRIVER = 0", sometime xNetworkInterfaceOutput() was called to send out a small TCP ACK. The network buffer would refer to space on the TCP socket ("lastPacket"), which was not 8-byte aligned. Repaired: from now on the buffer will have a proper 8-byte alignment.
|
||||
|
||||
"#if __cplusplus" is been replaced with the more proper test "#ifdef __cplusplus".
|
||||
|
||||
|
||||
|
||||
These are the recent commits:
|
||||
565 Initial check-in of +TCP/multi
|
||||
566 LPC18xx : updated and re-tested the TCP and FAT drivers
|
||||
569 +TCP : protocols: Added an installable application hook: "CheckDrivesHook"
|
||||
570 +TCP : will now work properly when configTICK_RATE_HZ < 1000
|
||||
571 +TCP : will now work properly when configTICK_RATE_HZ < 1000
|
||||
572 +TCP : FreeRTOS_recvfrom now recognises "FREERTOS_MSG_PEEK"
|
||||
573 +FAT : Zynq : writing may fail if it goes too fast. Introduced pauses but not yet satisfied
|
||||
NOTE: The 160908 release is a maintenance release for the 160112 single
|
||||
interface labs release - not a release of the current development branch.
|
||||
|
||||
+ Various minor stability enhancements, including the ability to work with
|
||||
configTICK_RATE_HZ set to less than 1KHz, closing DHCP sockets directly
|
||||
rather than via FreeRTOS_closesocket(), and better handling of unknown
|
||||
TCP packets before an IP address has been assigned.
|
||||
+ ipBUFFER_PADDING is now configurable through the ipconfigBUFFER_PADDING
|
||||
constant to improve network buffer alignment handling capabilities (expert
|
||||
users/driver writers only).
|
||||
+ Multiple improvements to the FTP server, including to how read only and
|
||||
zero length files are handled.
|
||||
+ ipconfigFTP_HAS_USER_PROPERTIES_HOOK (to allow each user to have a
|
||||
different root directory and access rights) and
|
||||
ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK (to handle AJAX style data)
|
||||
introduced, although these are not yet fully tested and the constant names
|
||||
are likely to change.
|
||||
+ Introduce ipconfigHAS_TX_CRC_OFFLOADING.
|
||||
+ ipconfigUSE_DHCP_HOOK is now called ipconfigUSE_DHCP_HOOK, and the name
|
||||
of the callback function has also changed. See the web documentation for
|
||||
details.
|
||||
+ ipconfigTCP_RX_BUF_LEN is now ipconfigTCP_RX_BUFFER_LENGTH, and
|
||||
ipconfigTCP_TX_BUF_LEN is now ipconfigTCP_TX_BUFFER_LENGTH, which is
|
||||
actually how they have always been documented.
|
||||
+ Added example TFTP server capable of receiving (not sending) files.
|
||||
Intended for bootloader type functionality.
|
||||
+ Various variable name changes for consistency (mainly ensuring UDP, TCP,
|
||||
DNS, etc. always use the same case letters, and type prefixes are correct).
|
||||
+ Various minor edits to improve types used by internal variables.
|
||||
+ Simplified mapping of standard library functions to their Visual Studio
|
||||
equivalents.
|
||||
+ Improve robustness of network drivers.
|
||||
+ Introduce pxResizeNetworkBufferWithDescriptor().
|
||||
+ Removed obsolete FreeRTOSIPConfig.h constants from
|
||||
FreeRTOSIPConfigDefaults.h.
|
||||
+ Added additional asserts() - predominantly to catch incorrect structure
|
||||
packing.
|
||||
|
||||
Changes between 160112 and 160111 releases
|
||||
|
||||
|
|
|
@ -502,6 +502,10 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#define ipconfigSOCKET_HAS_USER_SEMAPHORE 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSOCKET_HAS_USER_WAKE_CALLBACK
|
||||
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSUPPORT_SELECT_FUNCTION
|
||||
#define ipconfigSUPPORT_SELECT_FUNCTION 0
|
||||
#endif
|
||||
|
|
|
@ -111,11 +111,11 @@ FreeRTOS_setsockopt(). */
|
|||
#define FREERTOS_SO_RCVBUF ( 5 ) /* Set the size of the receive buffer (TCP only) */
|
||||
|
||||
#if ipconfigUSE_CALLBACKS == 1
|
||||
#define FREERTOS_SO_TCP_CONN_HANDLER ( 6 ) /* Install a callback for (dis) connection events. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_RECV_HANDLER ( 7 ) /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_SENT_HANDLER ( 8 ) /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_RECV_HANDLER ( 9 ) /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_SENT_HANDLER ( 10 ) /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_CONN_HANDLER ( 6 ) /* Install a callback for (dis) connection events. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_RECV_HANDLER ( 7 ) /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_SENT_HANDLER ( 8 ) /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_RECV_HANDLER ( 9 ) /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_SENT_HANDLER ( 10 ) /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#endif /* ipconfigUSE_CALLBACKS */
|
||||
|
||||
#define FREERTOS_SO_REUSE_LISTEN_SOCKET ( 11 ) /* When a listening socket gets connected, do not create a new one but re-use it */
|
||||
|
@ -123,7 +123,7 @@ FreeRTOS_setsockopt(). */
|
|||
#define FREERTOS_SO_WIN_PROPERTIES ( 13 ) /* Set all buffer and window properties in one call, parameter is pointer to WinProperties_t */
|
||||
#define FREERTOS_SO_SET_FULL_SIZE ( 14 ) /* Refuse to send packets smaller than MSS */
|
||||
|
||||
#define FREERTOS_SO_STOP_RX ( 15 ) /* Tempoarily hold up reception, used by streaming client */
|
||||
#define FREERTOS_SO_STOP_RX ( 15 ) /* Temporarily hold up reception, used by streaming client */
|
||||
|
||||
#if( ipconfigUDP_MAX_RX_PACKETS > 0 )
|
||||
#define FREERTOS_SO_UDP_MAX_RX_PACKETS ( 16 ) /* This option helps to limit the maximum number of packets a UDP socket will buffer */
|
||||
|
|
|
@ -236,12 +236,19 @@ static pcap_if_t * prvPrintAvailableNetworkInterfaces( void )
|
|||
pcap_if_t * pxAllNetworkInterfaces = NULL, *xInterface;
|
||||
int32_t lInterfaceNumber = 1;
|
||||
char cBuffer[ 512 ];
|
||||
static BaseType_t xInvalidInterfaceDetected = pdFALSE;
|
||||
|
||||
if( xInvalidInterfaceDetected == pdFALSE )
|
||||
{
|
||||
if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL, &pxAllNetworkInterfaces, cErrorBuffer ) == -1 )
|
||||
{
|
||||
printf( "Could not obtain a list of network interfaces\n%s\n", cErrorBuffer );
|
||||
pxAllNetworkInterfaces = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "\r\n\r\nThe following network interfaces are available:\r\n\r\n" );
|
||||
}
|
||||
|
||||
if( pxAllNetworkInterfaces != NULL )
|
||||
{
|
||||
|
@ -252,7 +259,7 @@ char cBuffer[ 512 ];
|
|||
/* The descriptions of the devices can be full of spaces, clean them
|
||||
a little. printf() can only be used here because the network is not
|
||||
up yet - so no other network tasks will be running. */
|
||||
printf( "%d. %s\n", lInterfaceNumber, prvRemoveSpaces( cBuffer, sizeof( cBuffer ), xInterface->name ) );
|
||||
printf( "Interface %d - %s\n", lInterfaceNumber, prvRemoveSpaces( cBuffer, sizeof( cBuffer ), xInterface->name ) );
|
||||
printf( " (%s)\n", prvRemoveSpaces(cBuffer, sizeof( cBuffer ), xInterface->description ? xInterface->description : "No description" ) );
|
||||
printf( "\n" );
|
||||
lInterfaceNumber++;
|
||||
|
@ -267,13 +274,16 @@ char cBuffer[ 512 ];
|
|||
pxAllNetworkInterfaces = NULL;
|
||||
}
|
||||
|
||||
printf( "The interface that will be opened is set by\n" );
|
||||
printf( "\"configNETWORK_INTERFACE_TO_USE\" which should be defined in FreeRTOSConfig.h\n" );
|
||||
printf( "Attempting to open interface number %d.\n", xConfigNextworkInterfaceToUse );
|
||||
printf( "\r\nThe interface that will be opened is set by " );
|
||||
printf( "\"configNETWORK_INTERFACE_TO_USE\", which\r\nshould be defined in FreeRTOSConfig.h\r\n" );
|
||||
|
||||
if( ( xConfigNextworkInterfaceToUse < 1L ) || ( xConfigNextworkInterfaceToUse > lInterfaceNumber ) )
|
||||
if( ( xConfigNextworkInterfaceToUse < 1L ) || ( xConfigNextworkInterfaceToUse >= lInterfaceNumber ) )
|
||||
{
|
||||
printf( "configNETWORK_INTERFACE_TO_USE is not in the valid range.\n" );
|
||||
printf( "\r\nERROR: configNETWORK_INTERFACE_TO_USE is set to %d, which is an invalid value.\r\n", xConfigNextworkInterfaceToUse );
|
||||
printf( "Please set configNETWORK_INTERFACE_TO_USE to one of the interface numbers listed above,\r\n" );
|
||||
printf( "then re-compile and re-start the application. Only Ethernet (as opposed to WiFi)\r\n" );
|
||||
printf( "interfaces are supported.\r\n\r\nHALTING\r\n\r\n\r\n" );
|
||||
xInvalidInterfaceDetected = pdTRUE;
|
||||
|
||||
if( pxAllNetworkInterfaces != NULL )
|
||||
{
|
||||
|
@ -282,6 +292,11 @@ char cBuffer[ 512 ];
|
|||
pxAllNetworkInterfaces = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Attempting to open interface number %d.\n", xConfigNextworkInterfaceToUse );
|
||||
}
|
||||
}
|
||||
|
||||
return pxAllNetworkInterfaces;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
#ifndef STREAM_BUFFER_H
|
||||
#define STREAM_BUFFER_H
|
||||
|
||||
#if defined( __cplusplus )
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Type by which stream buffers are referenced. For example, a call to
|
||||
* xStreamBufferCreate() returns an StreamBufferHandle_t variable that can
|
||||
|
@ -843,7 +847,7 @@ StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
|
|||
#endif
|
||||
|
||||
#if defined( __cplusplus )
|
||||
extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined( STREAM_BUFFER_H ) */
|
||||
|
|
|
@ -44,8 +44,8 @@ extern "C" {
|
|||
* MACROS AND DEFINITIONS
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define tskKERNEL_VERSION_NUMBER "V9.0.0"
|
||||
#define tskKERNEL_VERSION_MAJOR 9
|
||||
#define tskKERNEL_VERSION_NUMBER "V10.0.0"
|
||||
#define tskKERNEL_VERSION_MAJOR 10
|
||||
#define tskKERNEL_VERSION_MINOR 0
|
||||
#define tskKERNEL_VERSION_BUILD 0
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ set then don't fill the stack so there is no unnecessary dependency on memset. *
|
|||
/*
|
||||
* Macros used by vListTask to indicate which state a task is in.
|
||||
*/
|
||||
#define tskRUNNING_CHAR ( 'X' )
|
||||
#define tskBLOCKED_CHAR ( 'B' )
|
||||
#define tskREADY_CHAR ( 'R' )
|
||||
#define tskDELETED_CHAR ( 'D' )
|
||||
|
@ -4209,6 +4210,9 @@ TCB_t *pxTCB;
|
|||
{
|
||||
switch( pxTaskStatusArray[ x ].eCurrentState )
|
||||
{
|
||||
case eRunning: cStatus = tskRUNNING_CHAR;
|
||||
break;
|
||||
|
||||
case eReady: cStatus = tskREADY_CHAR;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue