Free (GPLv2) TCP/IP stack developed by TASS Belgium

Dependents:   lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more

PicoTCP. Copyright (c) 2013 TASS Belgium NV.

Released under the GNU General Public License, version 2.

Different licensing models may exist, at the sole discretion of the Copyright holders.

Official homepage: http://www.picotcp.com

Bug tracker: https://github.com/tass-belgium/picotcp/issues

Development steps:

  • initial integration with mbed RTOS
  • generic mbed Ethernet driver
  • high performance NXP LPC1768 specific Ethernet driver
  • Multi-threading support for mbed RTOS
  • Berkeley sockets and integration with the New Socket API
  • Fork of the apps running on top of the New Socket API
  • Scheduling optimizations
  • Debugging/benchmarking/testing

Demo application (measuring TCP sender performance):

Import programlpc1768-picotcp-demo

A PicoTCP demo app testing the ethernet throughput on the lpc1768 mbed board.

Files at this revision

API Documentation at this revision

Comitter:
tass
Date:
Thu Jun 06 11:40:20 2013 +0000
Parent:
14:fe225a6f92c0
Commit message:
updated picotcp_select

Changed in this revision

Socket/TCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/pico_bsd_layer.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/TCPSocketConnection.cpp	Thu Jun 06 09:27:28 2013 +0000
+++ b/Socket/TCPSocketConnection.cpp	Thu Jun 06 11:40:20 2013 +0000
@@ -71,7 +71,6 @@
         TimeInterval timeout(_timeout);
         if (wait_writable(timeout) != 0)
         {
-            printf("Failed\n");
             return -1;
         }
     }
@@ -118,14 +117,13 @@
         TimeInterval timeout(_timeout);
         if (wait_readable(timeout) != 0)
         {
-            printf("Failed receiving\n");
             return -1;
         }
     }
-    
+
     int n = picotcp_read(_sock_fd, data, length);
     _is_connected = (picotcp_state(_sock_fd) == SOCK_CONNECTED);
-    
+
     return n;
 }
 
--- a/Socket/pico_bsd_layer.cpp	Thu Jun 06 09:27:28 2013 +0000
+++ b/Socket/pico_bsd_layer.cpp	Thu Jun 06 11:40:20 2013 +0000
@@ -98,7 +98,9 @@
         {
             SET_EVENT(sock->event, event);
             //printf("Locked...\n");
+            
             sock->mutex->lock();
+            
             RESET_EVENT(sock->event,event);
     
             if(! EVENT_PENDING(sock->revent,event) || EVENT_PENDING(sock->revent, PICO_SOCK_EV_ERR) || 
@@ -120,7 +122,10 @@
     if(!_sock)
     {
         if( (ev & PICO_SOCK_EV_ERR) || (ev & PICO_SOCK_EV_CLOSE) || (ev & PICO_SOCK_EV_FIN) )
+        {
+            printf("Ghost socket : %d\n",ev);
             pico_socket_close(sock);
+        }
         return;
     }
 
@@ -136,18 +141,15 @@
     }
     else
     {
-        printf("Unexpected event\n");
+        //printf("Unexpected event \n");
         // give semaphore back when -1 occurs or close requested
-        if( (ev & PICO_SOCK_EV_ERR) || (ev & PICO_SOCK_EV_CLOSE) || (ev & PICO_SOCK_EV_FIN) )
+        if( (ev & PICO_SOCK_EV_ERR) || (ev & PICO_SOCK_EV_CLOSE))
         {
-            printf("Exception\n");
+            printf("Exception %d\n",ev);
             
             _sock->state = SOCK_CLOSED;
-            if(_sock->state != SOCK_CLOSED)
-            {
-                pico_socket_close(_sock->sock);
+            pico_socket_close(_sock->sock);
                 //_sock->sock = NULL;
-            }
             _sock->mutex->unlock();
             globalLock.lock();
         }
@@ -346,7 +348,7 @@
     pico_free(_sock);
     
     
-    globalLock.unlock();
+   globalLock.unlock();
     return ret;
 }
 
@@ -495,21 +497,12 @@
     VALIDATE_NULL(_sock);
     
     // tell the dispatcher what events are you waiting for
-    if(read)
-        SET_EVENT(_sock->event,PICO_SOCK_EV_RD|PICO_SOCK_EV_CONN);
-    if(write)
-        SET_EVENT(_sock->event,PICO_SOCK_EV_WR);
-        
+    
     while (PICO_TIME_MS() < now + ms) {
         
-        if (_sock->mutex->lock(1) == false) {
-            //Thread::wait(1);
-            continue;
-        }
-             
-        if (read && EVENT_PENDING(_sock->revent,PICO_SOCK_EV_RD|PICO_SOCK_EV_CONN))
+        if (read && EVENT_PENDING(_sock->revent,PICO_SOCK_EV_RD))
         {
-            RESET_EVENT(_sock->revent,PICO_SOCK_EV_CONN|PICO_SOCK_EV_RD);
+            RESET_EVENT(_sock->revent,PICO_SOCK_EV_RD);
             ret++;
         }
         if (write && EVENT_PENDING(_sock->revent, PICO_SOCK_EV_WR))
@@ -520,15 +513,9 @@
         if (ret > 0)
             break;
         
-        
+        Thread::wait(1);
     }
     
-    if(read)
-        RESET_EVENT(_sock->event,PICO_SOCK_EV_CONN|PICO_SOCK_EV_RD);
-    if(write)
-        RESET_EVENT(_sock->event,PICO_SOCK_EV_WR);
-
-    
     return ret;
 }