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.
modules/pico_dev_loop.c@152:a3d286bf94e5, 2015-09-28 (annotated)
- Committer:
- tass
- Date:
- Mon Sep 28 13:16:18 2015 +0200
- Revision:
- 152:a3d286bf94e5
- Parent:
- 149:5f4cb161cec3
Mercurial: latest development version of PicoTCP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tass | 68:0847e35d08a6 | 1 | /********************************************************************* |
tass | 152:a3d286bf94e5 | 2 | PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. |
TASS Belgium NV |
131:4758606c9316 | 3 | See LICENSE and COPYING for usage. |
tass | 68:0847e35d08a6 | 4 | |
TASS Belgium NV |
131:4758606c9316 | 5 | Authors: Daniele Lacamera |
TASS Belgium NV |
131:4758606c9316 | 6 | *********************************************************************/ |
tass | 68:0847e35d08a6 | 7 | |
tass | 68:0847e35d08a6 | 8 | |
tass | 68:0847e35d08a6 | 9 | #include "pico_device.h" |
tass | 68:0847e35d08a6 | 10 | #include "pico_dev_loop.h" |
tass | 68:0847e35d08a6 | 11 | #include "pico_stack.h" |
tass | 68:0847e35d08a6 | 12 | |
tass | 68:0847e35d08a6 | 13 | |
tass | 68:0847e35d08a6 | 14 | #define LOOP_MTU 1500 |
tass | 68:0847e35d08a6 | 15 | static uint8_t l_buf[LOOP_MTU]; |
TASS Belgium NV |
131:4758606c9316 | 16 | static int l_bufsize = 0; |
tass | 68:0847e35d08a6 | 17 | |
tass | 68:0847e35d08a6 | 18 | |
tass | 68:0847e35d08a6 | 19 | static int pico_loop_send(struct pico_device *dev, void *buf, int len) |
tass | 68:0847e35d08a6 | 20 | { |
TASS Belgium NV |
131:4758606c9316 | 21 | IGNORE_PARAMETER(dev); |
TASS Belgium NV |
131:4758606c9316 | 22 | if (len > LOOP_MTU) |
TASS Belgium NV |
131:4758606c9316 | 23 | return 0; |
tass | 68:0847e35d08a6 | 24 | |
TASS Belgium NV |
131:4758606c9316 | 25 | if (l_bufsize == 0) { |
TASS Belgium NV |
131:4758606c9316 | 26 | memcpy(l_buf, buf, (size_t)len); |
TASS Belgium NV |
131:4758606c9316 | 27 | l_bufsize += len; |
TASS Belgium NV |
131:4758606c9316 | 28 | return len; |
TASS Belgium NV |
131:4758606c9316 | 29 | } |
TASS Belgium NV |
131:4758606c9316 | 30 | |
TASS Belgium NV |
131:4758606c9316 | 31 | return 0; |
tass | 68:0847e35d08a6 | 32 | } |
tass | 68:0847e35d08a6 | 33 | |
tass | 68:0847e35d08a6 | 34 | static int pico_loop_poll(struct pico_device *dev, int loop_score) |
tass | 68:0847e35d08a6 | 35 | { |
TASS Belgium NV |
131:4758606c9316 | 36 | if (loop_score <= 0) |
TASS Belgium NV |
131:4758606c9316 | 37 | return 0; |
tass | 68:0847e35d08a6 | 38 | |
TASS Belgium NV |
131:4758606c9316 | 39 | if (l_bufsize > 0) { |
TASS Belgium NV |
131:4758606c9316 | 40 | pico_stack_recv(dev, l_buf, (uint32_t)l_bufsize); |
TASS Belgium NV |
131:4758606c9316 | 41 | l_bufsize = 0; |
TASS Belgium NV |
131:4758606c9316 | 42 | loop_score--; |
TASS Belgium NV |
131:4758606c9316 | 43 | } |
TASS Belgium NV |
131:4758606c9316 | 44 | |
TASS Belgium NV |
131:4758606c9316 | 45 | return loop_score; |
tass | 68:0847e35d08a6 | 46 | } |
tass | 68:0847e35d08a6 | 47 | |
tass | 68:0847e35d08a6 | 48 | |
tass | 68:0847e35d08a6 | 49 | struct pico_device *pico_loop_create(void) |
tass | 68:0847e35d08a6 | 50 | { |
tass picotcp@tass.be | 149:5f4cb161cec3 | 51 | struct pico_device *loop = PICO_ZALLOC(sizeof(struct pico_device)); |
TASS Belgium NV |
131:4758606c9316 | 52 | if (!loop) |
TASS Belgium NV |
131:4758606c9316 | 53 | return NULL; |
tass | 68:0847e35d08a6 | 54 | |
tass picotcp@tass.be | 149:5f4cb161cec3 | 55 | if( 0 != pico_device_init(loop, "loop", NULL)) { |
TASS Belgium NV |
131:4758606c9316 | 56 | dbg ("Loop init failed.\n"); |
tass picotcp@tass.be | 149:5f4cb161cec3 | 57 | pico_device_destroy(loop); |
TASS Belgium NV |
131:4758606c9316 | 58 | return NULL; |
TASS Belgium NV |
131:4758606c9316 | 59 | } |
TASS Belgium NV |
131:4758606c9316 | 60 | |
TASS Belgium NV |
131:4758606c9316 | 61 | loop->send = pico_loop_send; |
TASS Belgium NV |
131:4758606c9316 | 62 | loop->poll = pico_loop_poll; |
TASS Belgium NV |
131:4758606c9316 | 63 | dbg("Device %s created.\n", loop->name); |
tass picotcp@tass.be | 149:5f4cb161cec3 | 64 | return loop; |
tass | 68:0847e35d08a6 | 65 | } |
tass | 68:0847e35d08a6 | 66 |