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 RTOSgeneric mbed Ethernet driverhigh performance NXP LPC1768 specific Ethernet driverMulti-threading support for mbed RTOSBerkeley sockets and integration with the New Socket APIFork of the apps running on top of the New Socket APIScheduling 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.
Revision 42:13e557b44f68, committed 2013-07-17
- Comitter:
- tass
- Date:
- Wed Jul 17 07:28:27 2013 +0000
- Parent:
- 41:4c18c62b31b9
- Child:
- 43:5f2146814b83
- Commit message:
- Debug can be enabled now by defining eth_dbg or ptsock_dbg.; Made DHCP callback go to failed branch when error is reported.
Changed in this revision
--- a/EthernetInterface/EthernetInterface.cpp Tue Jul 16 07:41:44 2013 +0000 +++ b/EthernetInterface/EthernetInterface.cpp Wed Jul 17 07:28:27 2013 +0000 @@ -41,6 +41,8 @@ #include "pico_dhcp_client.h" #include "pico_dns_client.h" +#define eth_dbg(...) + void (*linkCb)(uint32_t link) = NULL; } @@ -63,7 +65,7 @@ void *id = NULL; struct pico_ip4 address, gateway, zero = {}; - if (PICO_DHCP_SUCCESS != code) + if (PICO_DHCP_ERROR == code) goto fail; id = pico_dhcp_get_identifier(dhcp_xid); @@ -87,7 +89,7 @@ return; fail: - printf("DHCP request failed!\n"); + eth_dbg("DHCP request failed!\n"); dhcp_retval = -1; dhcp_mx.unlock(); } @@ -107,9 +109,9 @@ } if(lpc_eth) - printf("Ethernet initialized...\n"); + eth_dbg("Ethernet initialized...\n"); else - printf("Failed to start Ethernet...\n"); + eth_dbg("Failed to start Ethernet...\n"); }
--- a/Socket/bsd/stack_endpoint.cpp Tue Jul 16 07:41:44 2013 +0000 +++ b/Socket/bsd/stack_endpoint.cpp Wed Jul 17 07:28:27 2013 +0000 @@ -49,7 +49,7 @@ while ((ep->events & ep->revents) == 0) { ep->queue->get(time); if ((time != osWaitForever) && (PICO_TIME_MS() > in_time + time)) { - printf("TIMEOUT in critical select... (ev:%04x rev:%04x \n", ep->events, ep->revents); + ptsock_dbg("TIMEOUT in critical select... (ev:%04x rev:%04x \n", ep->events, ep->revents); if(lock) PicoTcpLock->lock(); return 0; } @@ -63,10 +63,10 @@ struct stack_endpoint *ep = (struct stack_endpoint *)s->priv; if (!ep) { if (ep_accepting != NULL) { - //printf("Delivering %02x to accepting socket...\n", ev); + ptsock_dbg("Delivering %02x to accepting socket...\n", ev); ep = ep_accepting; } else { - printf("WAKEUP: socket not found! ev=%04x\n", ev); + ptsock_dbg("WAKEUP: socket not found! ev=%04x\n", ev); return; } } @@ -78,7 +78,7 @@ { if(pico_err == PICO_ERR_ECONNRESET) { - printf("Connection reset by peer...\n"); + ptsock_dbg("Connection reset by peer...\n"); ep->state = SOCK_RESET_BY_PEER; pico_socket_close(ep->s); ep->s->priv = NULL; @@ -108,10 +108,10 @@ delete(ep->queue); pico_free(ep); ep = NULL; - printf("Error opening socket!\n"); + ptsock_dbg("Error opening socket!\n"); } else { ep->s->priv = ep; - printf("Added socket (open)\n"); + ptsock_dbg("Added socket (open)\n"); ep->state = SOCK_OPEN; ep->queue = new Queue<void,1>(); } @@ -193,15 +193,15 @@ ep->events = PICO_SOCK_EV_CONN | PICO_SOCK_EV_ERR; __critical_select(ep, osWaitForever, 1); if (ep->revents & PICO_SOCK_EV_CONN) { - printf("Calling Accept\n"); + ptsock_dbg("Calling Accept\n"); aep->s = pico_socket_accept(ep->s, (struct pico_ip4 *)(&cli_addr->sin_addr.s_addr), &cli_addr->sin_port); - printf("Accept returned\n"); + ptsock_dbg("Accept returned\n"); aep->s->priv = aep; ep->revents &= (~PICO_SOCK_EV_CONN); aep->revents = 0; // set this to 0 to allow seq connections aep->revents |= PICO_SOCK_EV_WR; aep->state = SOCK_CONNECTED; - printf("Added socket (accept)\n"); + ptsock_dbg("Added socket (accept)\n"); *len = sizeof(struct sockaddr_in); ptsock_dbg("Established. sock state: %x\n", aep->s->state); @@ -369,7 +369,7 @@ PicoTcpLock->lock(); while (tot_len < len) { retval = pico_socket_write(ep->s, ((uint8_t *)buf) + tot_len , len - tot_len); - //retval = pico_socket_read(ep->s, ((uint8_t *)buf) + tot_len , len - tot_len); + if (retval == 0) { if (tot_len < len) ep->revents &= ~PICO_SOCK_EV_WR; @@ -423,7 +423,7 @@ pico_socket_close(ep->s); ep->s->priv = NULL; } - printf("Socket closed!\n"); + ptsock_dbg("Socket closed!\n"); delete(ep->queue); pico_free(ep); PicoTcpLock->unlock(); @@ -473,7 +473,7 @@ if (serverThread == NULL) { PicoTcpLock = new Mutex(); PicoTcpEvents = new Queue<void,32>(); - printf (" *** PicoTCP initialized *** \n"); + ptsock_dbg (" *** PicoTCP initialized *** \n"); serverThread = new Thread(pico_wrapper_loop); serverThread->set_priority(osPriorityIdle); }