]> git.sur5r.net Git - freertos/commitdiff
Update FreeRTOS_FD_SET() to check there is enough space in the queue before adding...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 20:13:02 +0000 (20:13 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 20:13:02 +0000 (20:13 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2053 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/TraceMacros/Example1/DemoIPTrace.c
FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/TraceMacros/Example1/DemoIPTrace.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Nabto/readme.txt [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_Sockets.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/include/FreeRTOSIPConfigDefaults.h

index 4e9d09a2508a562f9e58bddc50d3c2c6d5d21b22..78a722e50c4135c06cdefdf56078a940c3765ecc 100644 (file)
@@ -105,17 +105,18 @@ xExampleDebugStatEntry_t xIPTraceValues[] =
 {\r
        /* Comment out array entries to remove individual trace items. */\r
 \r
+       { iptraceID_NETWORK_INTERFACE_RECEIVE,                  ( const uint8_t * const ) "Packets received by the network interface",                  prvIncrementEventCount, 0 },\r
+       { iptraceID_NETWORK_INTERFACE_TRANSMIT,                 ( const uint8_t * const ) "Count of transmitted packets",                                               prvIncrementEventCount, 0 },\r
+       { iptraceID_PACKET_DROPPED_TO_GENERATE_ARP,             ( const uint8_t * const ) "Count of packets dropped to generate ARP",                   prvIncrementEventCount, 0 },\r
        { iptraceID_NETWORK_BUFFER_OBTAINED,                    ( const uint8_t * const ) "Lowest ever available network buffers",                              prvStoreLowest, 0xffffUL },\r
        { iptraceID_NETWORK_EVENT_RECEIVED,                             ( const uint8_t * const ) "Lowest ever free space in network event queue",              prvStoreLowest, 0xffffUL },\r
        { iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER,    ( const uint8_t * const ) "Count of failed attempts to obtain a network buffer",prvIncrementEventCount, 0 },\r
        { iptraceID_ARP_TABLE_ENTRY_EXPIRED,                    ( const uint8_t * const ) "Count of expired ARP entries",                                               prvIncrementEventCount, 0 },\r
-       { iptraceID_PACKET_DROPPED_TO_GENERATE_ARP,             ( const uint8_t * const ) "Count of packets dropped to generate ARP",                   prvIncrementEventCount, 0 },\r
        { iptraceID_FAILED_TO_CREATE_SOCKET,                    ( const uint8_t * const ) "Count of failures to create a socket",                               prvIncrementEventCount, 0 },\r
        { iptraceID_RECVFROM_DISCARDING_BYTES,                  ( const uint8_t * const ) "Count of times recvfrom() has discarding bytes",             prvIncrementEventCount, 0 },\r
        { iptraceID_ETHERNET_RX_EVENT_LOST,                             ( const uint8_t * const ) "Count of lost Ethenret Rx events (event queue full?)",prvIncrementEventCount, 0 },\r
        { iptraceID_STACK_TX_EVENT_LOST,                                ( const uint8_t * const ) "Count of lost IP stack events (event queue full?)",  prvIncrementEventCount, 0 },\r
        { ipconfigID_BIND_FAILED,                                               ( const uint8_t * const ) "Count of failed calls to bind()",                                    prvIncrementEventCount, 0 },\r
-       { iptraceID_NETWORK_INTERFACE_TRANSMIT,                 ( const uint8_t * const ) "Count of transmitted packets",                                               prvIncrementEventCount, 0 },\r
        { iptraceID_RECVFROM_TIMEOUT,                                   ( const uint8_t * const ) "Count of receive timeouts",                                                  prvIncrementEventCount, 0 },\r
        { iptraceID_SENDTO_DATA_TOO_LONG,                               ( const uint8_t * const ) "Count of failed sends due to oversized payload",             prvIncrementEventCount, 0 },\r
        { iptraceID_SENDTO_SOCKET_NOT_BOUND,                    ( const uint8_t * const ) "Count of failed sends due to unbound socket",                prvIncrementEventCount, 0 },\r
index 8c14962eedf9867105d6a3b8bb1909b91fe4071c..e4205c312304025e75a47da91b1dd70975531b49 100644 (file)
@@ -85,18 +85,21 @@ typedef struct ExampleDebugStatEntry
 \r
 /* Unique identifiers used to locate the entry for each trace macro in the\r
 xIPTraceValues[] table defined in DemoIPTrace.c. */\r
-#define iptraceID_NETWORK_BUFFER_OBTAINED                                      1\r
-#define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR                     2\r
-#define iptraceID_NETWORK_EVENT_RECEIVED                                       3\r
-#define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER                      4\r
-#define iptraceID_ARP_TABLE_ENTRY_EXPIRED                                      5\r
-#define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP                       6\r
-#define iptraceID_FAILED_TO_CREATE_SOCKET                                      7\r
-#define iptraceID_RECVFROM_DISCARDING_BYTES                                    8\r
-#define iptraceID_ETHERNET_RX_EVENT_LOST                                       9\r
-#define iptraceID_STACK_TX_EVENT_LOST                                          10\r
-#define ipconfigID_BIND_FAILED                                                         11\r
-#define iptraceID_NETWORK_INTERFACE_TRANSMIT                           12\r
+#define iptraceID_NETWORK_INTERFACE_RECEIVE                                    0\r
+#define iptraceID_NETWORK_INTERFACE_TRANSMIT                           1\r
+#define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP                       2\r
+/* Do not change IDs above this line as the ID is shared with a FreeRTOS+Nabto\r
+demo. */\r
+#define iptraceID_NETWORK_BUFFER_OBTAINED                                      3\r
+#define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR                     4\r
+#define iptraceID_NETWORK_EVENT_RECEIVED                                       5\r
+#define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER                      6\r
+#define iptraceID_ARP_TABLE_ENTRY_EXPIRED                                      7\r
+#define iptraceID_FAILED_TO_CREATE_SOCKET                                      8\r
+#define iptraceID_RECVFROM_DISCARDING_BYTES                                    9\r
+#define iptraceID_ETHERNET_RX_EVENT_LOST                                       10\r
+#define iptraceID_STACK_TX_EVENT_LOST                                          11\r
+#define ipconfigID_BIND_FAILED                                                         12\r
 #define iptraceID_RECVFROM_TIMEOUT                                                     13\r
 #define iptraceID_SENDTO_DATA_TOO_LONG                                         14\r
 #define iptraceID_SENDTO_SOCKET_NOT_BOUND                                      15\r
@@ -136,6 +139,7 @@ configINCLUDE_DEMO_DEBUG_STATS setting in FreeRTOSIPConfig.h. */
        #define iptraceNO_BUFFER_FOR_SENDTO()                                                           vExampleDebugStatUpdate( iptraceID_NO_BUFFER_FOR_SENDTO, 0 )\r
        #define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR()                                          vExampleDebugStatUpdate( iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, 0 )\r
        #define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket )                         vExampleDebugStatUpdate( iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, 0 )\r
+       #define iptraceNETWORK_INTERFACE_RECEIVE()                                                      vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_RECEIVE, 0 )\r
 \r
        /*\r
         * The function that updates a line in the xIPTraceValues table.\r
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Nabto/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Nabto/readme.txt
new file mode 100644 (file)
index 0000000..b5d1bc5
--- /dev/null
@@ -0,0 +1,6 @@
+FreeRTOS+Nabto projects are currently provided in a separate \r
+download.  Following are links to the download page and the\r
+documentation for the demo that is included in the download.\r
+\r
+http://www.freertos.org/FreeRTOS-Plus/Nabto/download_freertos_plus_nabto.shtml\r
+http://www.freertos.org/FreeRTOS-Plus/Nabto/getting_started_with_FreeRTOS_Plus_Nabto.shtml
\ No newline at end of file
index 314c4daa45100427388ae360b146cd618e10b893..16c2e870a16cb509679dfa5e3fc8de764cd4a669 100644 (file)
@@ -186,21 +186,39 @@ xFreeRTOS_Socket_t *pxSocket;
        portBASE_TYPE FreeRTOS_FD_SET( xSocket_t xSocket, xSocketSet_t xSocketSet )\r
        {\r
        xFreeRTOS_Socket_t *pxSocket = ( xFreeRTOS_Socket_t * ) xSocket;\r
-       portBASE_TYPE xReturn;\r
-       \r
+       portBASE_TYPE xReturn = pdFALSE;\r
+       unsigned portBASE_TYPE uxMessagesWaiting;\r
+\r
+               configASSERT( xSocket );\r
+\r
                /* Is the socket already a member of a select group? */\r
                if( pxSocket->xSelectQueue == NULL )\r
                {\r
-                       /* Store a pointer to the select group in the socket for future \r
-                       reference. */\r
-                       pxSocket->xSelectQueue = ( xQueueHandle ) xSocketSet;\r
-                       xReturn = pdPASS;\r
-               }\r
-               else\r
-               {\r
-                       /* The socket is already a member of a select group so cannot be added\r
-                       to another. */\r
-                       xReturn = pdFAIL;\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               /* Are there packets queued on the socket already? */\r
+                               uxMessagesWaiting = uxQueueMessagesWaiting( pxSocket->xWaitingPacketSemaphore );\r
+\r
+                               /* Are there enough notification spaces in the select queue for the\r
+                               number of packets already queued on the socket? */\r
+                               if( uxQueueSpacesAvailable( ( xQueueHandle ) xSocketSet ) >= uxMessagesWaiting )\r
+                               {\r
+                                       /* Store a pointer to the select group in the socket for\r
+                                       future reference. */\r
+                                       pxSocket->xSelectQueue = ( xQueueHandle ) xSocketSet;\r
+\r
+                                       while( uxMessagesWaiting > 0 )\r
+                                       {\r
+                                               /* Add notifications of the number of packets that are\r
+                                               already queued on the socket to the select queue. */\r
+                                               xQueueSendFromISR( pxSocket->xSelectQueue, &pxSocket, NULL );\r
+                                               uxMessagesWaiting--;\r
+                                       }\r
+\r
+                                       xReturn = pdPASS;\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
                }\r
 \r
                return xReturn;\r
index 913cb4947fd41139644fa8c3cf64943990891911..6671ec211bdb007fd6f9921fb57e52a4f667148a 100644 (file)
@@ -147,4 +147,8 @@ from the FreeRTOSIPConfig.h configuration header file. */
        #define ipconfigNABTO_TASK_PRIORITY      ( ipconfigUDP_TASK_PRIORITY + 1 )\r
 #endif\r
 \r
+#ifndef ipconfigSUPPORT_SELECT_FUNCTION\r
+       #define ipconfigSUPPORT_SELECT_FUNCTION 0\r
+#endif\r
+\r
 #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */\r