mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update TimerDemo.c to test the new vTimerSetTimerID() function.
Update WinPCap NetworkInterface.c for FreeRTOS+UDP to correctly store a pointer to the network buffer structure at the beginning of the network buffer.
This commit is contained in:
parent
03213b9e4a
commit
d39c0d5926
|
@ -185,13 +185,16 @@ configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
|
||||||
used. */
|
used. */
|
||||||
#define configNETWORK_INTERFACE_TO_USE 4L
|
#define configNETWORK_INTERFACE_TO_USE 4L
|
||||||
|
|
||||||
|
/* Only when using BufferAllocation_1.c. */
|
||||||
|
#define configUSE_STATIC_BUFFERS 1
|
||||||
|
|
||||||
/* The address of an echo server that will be used by the two demo echo client
|
/* The address of an echo server that will be used by the two demo echo client
|
||||||
tasks.
|
tasks.
|
||||||
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */
|
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */
|
||||||
#define configECHO_SERVER_ADDR0 10
|
#define configECHO_SERVER_ADDR0 172
|
||||||
#define configECHO_SERVER_ADDR1 134
|
#define configECHO_SERVER_ADDR1 25
|
||||||
#define configECHO_SERVER_ADDR2 134
|
#define configECHO_SERVER_ADDR2 218
|
||||||
#define configECHO_SERVER_ADDR3 71
|
#define configECHO_SERVER_ADDR3 100
|
||||||
|
|
||||||
/* Default MAC address configuration. The demo creates a virtual network
|
/* Default MAC address configuration. The demo creates a virtual network
|
||||||
connection that uses this MAC address by accessing the raw Ethernet/WiFi data
|
connection that uses this MAC address by accessing the raw Ethernet/WiFi data
|
||||||
|
|
|
@ -139,6 +139,9 @@
|
||||||
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_DNS.c" />
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_DNS.c" />
|
||||||
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_Sockets.c" />
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_Sockets.c" />
|
||||||
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_UDP_IP.c" />
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\FreeRTOS_UDP_IP.c" />
|
||||||
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\BufferManagement\BufferAllocation_1.c">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\BufferManagement\BufferAllocation_2.c" />
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\BufferManagement\BufferAllocation_2.c" />
|
||||||
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
|
||||||
<ClCompile Include="..\Common\FreeRTOS_Plus_UDP_Demos\CLICommands\CLI-commands.c" />
|
<ClCompile Include="..\Common\FreeRTOS_Plus_UDP_Demos\CLICommands\CLI-commands.c" />
|
||||||
|
|
|
@ -109,6 +109,9 @@
|
||||||
<ClCompile Include="DemoTasks\SelectServer.c">
|
<ClCompile Include="DemoTasks\SelectServer.c">
|
||||||
<Filter>Demo App Source\DemoTasks</Filter>
|
<Filter>Demo App Source\DemoTasks</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\BufferManagement\BufferAllocation_1.c">
|
||||||
|
<Filter>FreeRTOS+\FreeRTOS+UDP\portable</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="FreeRTOSConfig.h">
|
<ClInclude Include="FreeRTOSConfig.h">
|
||||||
|
|
|
@ -630,6 +630,7 @@ static uint8_t *prvCreatePartDHCPMessage( struct freertos_sockaddr *pxAddress, x
|
||||||
xDHCPMessage_t *pxDHCPMessage;
|
xDHCPMessage_t *pxDHCPMessage;
|
||||||
const size_t xRequiredBufferSize = sizeof( xDHCPMessage_t ) + xOptionsArraySize;
|
const size_t xRequiredBufferSize = sizeof( xDHCPMessage_t ) + xOptionsArraySize;
|
||||||
uint8_t *pucUDPPayloadBuffer;
|
uint8_t *pucUDPPayloadBuffer;
|
||||||
|
static uint8_t ucUseBroadcastFlag = pdFALSE;
|
||||||
|
|
||||||
/* Get a buffer. This uses a maximum delay, but the delay will be capped
|
/* Get a buffer. This uses a maximum delay, but the delay will be capped
|
||||||
to ipconfigMAX_SEND_BLOCK_TIME_TICKS so the return value still needs to be
|
to ipconfigMAX_SEND_BLOCK_TIME_TICKS so the return value still needs to be
|
||||||
|
@ -649,7 +650,19 @@ uint8_t *pucUDPPayloadBuffer;
|
||||||
pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH;
|
pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH;
|
||||||
pxDHCPMessage->ulTransactionID = ulTransactionId;
|
pxDHCPMessage->ulTransactionID = ulTransactionId;
|
||||||
pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE;
|
pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE;
|
||||||
pxDHCPMessage->usFlags = dhcpBROADCAST;
|
|
||||||
|
/* For maximum possibility of success, alternate between broadcast and non
|
||||||
|
broadcast. */
|
||||||
|
ucUseBroadcastFlag = !ucUseBroadcastFlag;
|
||||||
|
if( ucUseBroadcastFlag == pdTRUE )
|
||||||
|
{
|
||||||
|
pxDHCPMessage->usFlags = dhcpBROADCAST;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pxDHCPMessage->usFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) pxMACAddress, sizeof( xMACAddress_t ) );
|
memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) pxMACAddress, sizeof( xMACAddress_t ) );
|
||||||
|
|
||||||
/* Copy in the const part of the options options. */
|
/* Copy in the const part of the options options. */
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
* This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license
|
* This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license
|
||||||
* terms are different to the FreeRTOS license terms.
|
* terms are different to the FreeRTOS license terms.
|
||||||
*
|
*
|
||||||
* FreeRTOS+UDP uses a dual license model that allows the software to be used
|
* FreeRTOS+UDP uses a dual license model that allows the software to be used
|
||||||
* under a standard GPL open source license, or a commercial license. The
|
* under a standard GPL open source license, or a commercial license. The
|
||||||
* standard GPL license (unlike the modified GPL license under which FreeRTOS
|
* standard GPL license (unlike the modified GPL license under which FreeRTOS
|
||||||
* itself is distributed) requires that all software statically linked with
|
* itself is distributed) requires that all software statically linked with
|
||||||
* FreeRTOS+UDP is also distributed under the same GPL V2 license terms.
|
* FreeRTOS+UDP is also distributed under the same GPL V2 license terms.
|
||||||
* Details of both license options follow:
|
* Details of both license options follow:
|
||||||
*
|
*
|
||||||
* - Open source licensing -
|
* - Open source licensing -
|
||||||
|
@ -21,9 +21,9 @@
|
||||||
*
|
*
|
||||||
* - Commercial licensing -
|
* - Commercial licensing -
|
||||||
* Businesses and individuals that for commercial or other reasons cannot comply
|
* Businesses and individuals that for commercial or other reasons cannot comply
|
||||||
* with the terms of the GPL V2 license must obtain a commercial license before
|
* with the terms of the GPL V2 license must obtain a commercial license before
|
||||||
* incorporating FreeRTOS+UDP into proprietary software for distribution in any
|
* incorporating FreeRTOS+UDP into proprietary software for distribution in any
|
||||||
* form. Commercial licenses can be purchased from http://shop.freertos.org/udp
|
* form. Commercial licenses can be purchased from http://shop.freertos.org/udp
|
||||||
* and do not require any source files to be changed.
|
* and do not require any source files to be changed.
|
||||||
*
|
*
|
||||||
* FreeRTOS+UDP is distributed in the hope that it will be useful. You cannot
|
* FreeRTOS+UDP is distributed in the hope that it will be useful. You cannot
|
||||||
|
@ -117,7 +117,7 @@ this case the network buffers are declared in NetworkInterface.c because, as
|
||||||
this file is only used on Windows machines, wasting a few bytes in buffers that
|
this file is only used on Windows machines, wasting a few bytes in buffers that
|
||||||
never get used does not matter (the buffers will not get used if the dynamic
|
never get used does not matter (the buffers will not get used if the dynamic
|
||||||
payload allocation file is included in the project). */
|
payload allocation file is included in the project). */
|
||||||
static uint8_t ucBuffers[ ipconfigNUM_NETWORK_BUFFERS ][ ipTOTAL_ETHERNET_FRAME_SIZE ];
|
static uint8_t ucBuffers[ ipconfigNUM_NETWORK_BUFFERS ][ ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING ];
|
||||||
|
|
||||||
/* The queue used to communicate Ethernet events with the IP task. */
|
/* The queue used to communicate Ethernet events with the IP task. */
|
||||||
extern xQueueHandle xNetworkEventQueue;
|
extern xQueueHandle xNetworkEventQueue;
|
||||||
|
@ -472,10 +472,18 @@ eFrameProcessingResult_t eResult;
|
||||||
void vNetworkInterfaceAllocateRAMToBuffers( xNetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFERS ] )
|
void vNetworkInterfaceAllocateRAMToBuffers( xNetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFERS ] )
|
||||||
{
|
{
|
||||||
BaseType_t x;
|
BaseType_t x;
|
||||||
|
xNetworkBufferDescriptor_t **ppxStartOfBuffer;
|
||||||
|
|
||||||
for( x = 0; x < ipconfigNUM_NETWORK_BUFFERS; x++ )
|
for( x = 0; x < ipconfigNUM_NETWORK_BUFFERS; x++ )
|
||||||
{
|
{
|
||||||
pxNetworkBuffers[ x ].pucEthernetBuffer = &( ucBuffers[ x ][ 0 ] );
|
/* Place a pointer to the network buffer structure at the beginning
|
||||||
|
of the buffer that will be allocated to the structure. */
|
||||||
|
ppxStartOfBuffer = ( xNetworkBufferDescriptor_t ** ) &( ucBuffers[ x ][ 0 ] );
|
||||||
|
*ppxStartOfBuffer = &( pxNetworkBuffers[ x ] );
|
||||||
|
|
||||||
|
/* Allocate the buffer to the network buffer structure, jumping over
|
||||||
|
the bytes where the pointer to the network buffer is now stored. */
|
||||||
|
pxNetworkBuffers[ x ].pucEthernetBuffer = &( ucBuffers[ x ][ ipBUFFER_PADDING ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,7 +192,7 @@ static void prvTimerTestTask( void *pvParameters )
|
||||||
xOneShotTimer = xTimerCreate( "Oneshot Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */
|
xOneShotTimer = xTimerCreate( "Oneshot Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */
|
||||||
tmrdemoONE_SHOT_TIMER_PERIOD, /* The period for the timer. */
|
tmrdemoONE_SHOT_TIMER_PERIOD, /* The period for the timer. */
|
||||||
pdFALSE, /* Don't auto-reload - hence a one shot timer. */
|
pdFALSE, /* Don't auto-reload - hence a one shot timer. */
|
||||||
( void * ) 0, /* The timer identifier. In this case this is not used as the timer has its own callback. */
|
( void * ) 0, /* The timer identifier. Initialise to 0, then increment each time it is called. */
|
||||||
prvOneShotTimerCallback ); /* The callback to be called when the timer expires. */
|
prvOneShotTimerCallback ); /* The callback to be called when the timer expires. */
|
||||||
|
|
||||||
if( xOneShotTimer == NULL )
|
if( xOneShotTimer == NULL )
|
||||||
|
@ -1062,9 +1062,22 @@ uint32_t ulTimerID;
|
||||||
|
|
||||||
static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer )
|
static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer )
|
||||||
{
|
{
|
||||||
/* The parameter is not used in this case as only one timer uses this
|
/* A count is kept of the number of times this callback function is executed.
|
||||||
callback function. */
|
The count is stored as the timer's ID. This is only done to test the
|
||||||
( void ) pxExpiredTimer;
|
vTimerSetTimerID() function. */
|
||||||
|
static uint32_t ulCallCount = 0;
|
||||||
|
uint32_t ulLastCallCount;
|
||||||
|
|
||||||
|
/* Obtain the timer's ID, which should be a count of the number of times
|
||||||
|
this callback function has been executed. */
|
||||||
|
ulLastCallCount = ( uint32_t ) pvTimerGetTimerID( pxExpiredTimer );
|
||||||
|
configASSERT( ulLastCallCount == ulCallCount );
|
||||||
|
|
||||||
|
/* Increment the call count, then save it back as the timer's ID. This is
|
||||||
|
only done to test the vTimerSetTimerID() API function. */
|
||||||
|
ulLastCallCount++;
|
||||||
|
vTimerSetTimerID( pxExpiredTimer, ( void * ) ulLastCallCount );
|
||||||
|
ulCallCount++;
|
||||||
|
|
||||||
ucOneShotTimerCounter++;
|
ucOneShotTimerCounter++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue