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@131:4758606c9316, 2013-12-16 (annotated)
- Committer:
- TASS Belgium NV
- Date:
- Mon Dec 16 11:25:54 2013 +0100
- Revision:
- 131:4758606c9316
- Parent:
- 70:cd218dd180e5
- Child:
- 149:5f4cb161cec3
Syncronized with master branch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tass | 68:0847e35d08a6 | 1 | /********************************************************************* |
TASS Belgium NV |
131:4758606c9316 | 2 | PicoTCP. Copyright (c) 2012 TASS Belgium NV. 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 | /* Public interface: create/destroy. */ |
tass | 68:0847e35d08a6 | 49 | |
tass | 68:0847e35d08a6 | 50 | void pico_loop_destroy(struct pico_device *dev) |
tass | 68:0847e35d08a6 | 51 | { |
TASS Belgium NV |
131:4758606c9316 | 52 | IGNORE_PARAMETER(dev); |
tass | 68:0847e35d08a6 | 53 | } |
tass | 68:0847e35d08a6 | 54 | |
tass | 68:0847e35d08a6 | 55 | struct pico_device *pico_loop_create(void) |
tass | 68:0847e35d08a6 | 56 | { |
TASS Belgium NV |
131:4758606c9316 | 57 | struct pico_device *loop = pico_zalloc(sizeof(struct pico_device)); |
TASS Belgium NV |
131:4758606c9316 | 58 | if (!loop) |
TASS Belgium NV |
131:4758606c9316 | 59 | return NULL; |
tass | 68:0847e35d08a6 | 60 | |
TASS Belgium NV |
131:4758606c9316 | 61 | if( 0 != pico_device_init((struct pico_device *)loop, "loop", NULL)) { |
TASS Belgium NV |
131:4758606c9316 | 62 | dbg ("Loop init failed.\n"); |
TASS Belgium NV |
131:4758606c9316 | 63 | pico_loop_destroy((struct pico_device *)loop); |
TASS Belgium NV |
131:4758606c9316 | 64 | return NULL; |
TASS Belgium NV |
131:4758606c9316 | 65 | } |
TASS Belgium NV |
131:4758606c9316 | 66 | |
TASS Belgium NV |
131:4758606c9316 | 67 | loop->send = pico_loop_send; |
TASS Belgium NV |
131:4758606c9316 | 68 | loop->poll = pico_loop_poll; |
TASS Belgium NV |
131:4758606c9316 | 69 | loop->destroy = pico_loop_destroy; |
TASS Belgium NV |
131:4758606c9316 | 70 | dbg("Device %s created.\n", loop->name); |
TASS Belgium NV |
131:4758606c9316 | 71 | return (struct pico_device *)loop; |
tass | 68:0847e35d08a6 | 72 | } |
tass | 68:0847e35d08a6 | 73 |