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