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.
pull/4/head
Richard Barry 10 years ago
parent 03213b9e4a
commit d39c0d5926

@ -185,13 +185,16 @@ configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
used. */
#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
tasks.
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */
#define configECHO_SERVER_ADDR0 10
#define configECHO_SERVER_ADDR1 134
#define configECHO_SERVER_ADDR2 134
#define configECHO_SERVER_ADDR3 71
#define configECHO_SERVER_ADDR0 172
#define configECHO_SERVER_ADDR1 25
#define configECHO_SERVER_ADDR2 218
#define configECHO_SERVER_ADDR3 100
/* Default MAC address configuration. The demo creates a virtual network
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_Sockets.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\NetworkInterface\WinPCap\NetworkInterface.c" />
<ClCompile Include="..\Common\FreeRTOS_Plus_UDP_Demos\CLICommands\CLI-commands.c" />

@ -109,6 +109,9 @@
<ClCompile Include="DemoTasks\SelectServer.c">
<Filter>Demo App Source\DemoTasks</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\FreeRTOS-Plus-UDP\portable\BufferManagement\BufferAllocation_1.c">
<Filter>FreeRTOS+\FreeRTOS+UDP\portable</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="FreeRTOSConfig.h">

@ -630,6 +630,7 @@ static uint8_t *prvCreatePartDHCPMessage( struct freertos_sockaddr *pxAddress, x
xDHCPMessage_t *pxDHCPMessage;
const size_t xRequiredBufferSize = sizeof( xDHCPMessage_t ) + xOptionsArraySize;
uint8_t *pucUDPPayloadBuffer;
static uint8_t ucUseBroadcastFlag = pdFALSE;
/* 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
@ -649,7 +650,19 @@ uint8_t *pucUDPPayloadBuffer;
pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH;
pxDHCPMessage->ulTransactionID = ulTransactionId;
pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE;
/* 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 ) );
/* Copy in the const part of the options options. */

@ -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
never get used does not matter (the buffers will not get used if the dynamic
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. */
extern xQueueHandle xNetworkEventQueue;
@ -472,10 +472,18 @@ eFrameProcessingResult_t eResult;
void vNetworkInterfaceAllocateRAMToBuffers( xNetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFERS ] )
{
BaseType_t x;
xNetworkBufferDescriptor_t **ppxStartOfBuffer;
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

@ -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. */
tmrdemoONE_SHOT_TIMER_PERIOD, /* The period for the 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. */
if( xOneShotTimer == NULL )
@ -1062,9 +1062,22 @@ uint32_t ulTimerID;
static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer )
{
/* The parameter is not used in this case as only one timer uses this
callback function. */
( void ) pxExpiredTimer;
/* A count is kept of the number of times this callback function is executed.
The count is stored as the timer's ID. This is only done to test the
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++;
}

Loading…
Cancel
Save