Stripped down version of Segundos NetService library (http://mbed.org/users/segundo/libraries/NetServices ). I have removed all NetServices, and all functions which had been disabled. Use this version when you need only pure TCP or UDP functions - this library compiles faster.

Dependencies:   lwip lwip-sys

Dependents:   christmasLights device_server pop3demo device_server_udp ... more

Committer:
hlipka
Date:
Mon Jan 10 21:03:11 2011 +0000
Revision:
0:8b387bed54c2
initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 0:8b387bed54c2 1 /*
hlipka 0:8b387bed54c2 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
hlipka 0:8b387bed54c2 3 * All rights reserved.
hlipka 0:8b387bed54c2 4 *
hlipka 0:8b387bed54c2 5 * Redistribution and use in source and binary forms, with or without modification,
hlipka 0:8b387bed54c2 6 * are permitted provided that the following conditions are met:
hlipka 0:8b387bed54c2 7 *
hlipka 0:8b387bed54c2 8 * 1. Redistributions of source code must retain the above copyright notice,
hlipka 0:8b387bed54c2 9 * this list of conditions and the following disclaimer.
hlipka 0:8b387bed54c2 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
hlipka 0:8b387bed54c2 11 * this list of conditions and the following disclaimer in the documentation
hlipka 0:8b387bed54c2 12 * and/or other materials provided with the distribution.
hlipka 0:8b387bed54c2 13 * 3. The name of the author may not be used to endorse or promote products
hlipka 0:8b387bed54c2 14 * derived from this software without specific prior written permission.
hlipka 0:8b387bed54c2 15 *
hlipka 0:8b387bed54c2 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
hlipka 0:8b387bed54c2 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
hlipka 0:8b387bed54c2 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
hlipka 0:8b387bed54c2 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
hlipka 0:8b387bed54c2 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
hlipka 0:8b387bed54c2 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
hlipka 0:8b387bed54c2 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
hlipka 0:8b387bed54c2 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
hlipka 0:8b387bed54c2 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
hlipka 0:8b387bed54c2 25 * OF SUCH DAMAGE.
hlipka 0:8b387bed54c2 26 *
hlipka 0:8b387bed54c2 27 * This file is part of the lwIP TCP/IP stack.
hlipka 0:8b387bed54c2 28 */
hlipka 0:8b387bed54c2 29
hlipka 0:8b387bed54c2 30 /*
hlipka 0:8b387bed54c2 31 * This is the interface to the platform specific serial IO module
hlipka 0:8b387bed54c2 32 * It needs to be implemented by those platforms which need SLIP or PPP
hlipka 0:8b387bed54c2 33 */
hlipka 0:8b387bed54c2 34
hlipka 0:8b387bed54c2 35 #ifndef __SIO_H__
hlipka 0:8b387bed54c2 36 #define __SIO_H__
hlipka 0:8b387bed54c2 37
hlipka 0:8b387bed54c2 38 #include "lwip/arch.h"
hlipka 0:8b387bed54c2 39
hlipka 0:8b387bed54c2 40 #ifdef __cplusplus
hlipka 0:8b387bed54c2 41 extern "C" {
hlipka 0:8b387bed54c2 42 #endif
hlipka 0:8b387bed54c2 43
hlipka 0:8b387bed54c2 44 /* If you want to define sio_fd_t elsewhere or differently,
hlipka 0:8b387bed54c2 45 define this in your cc.h file. */
hlipka 0:8b387bed54c2 46 #ifndef __sio_fd_t_defined
hlipka 0:8b387bed54c2 47 typedef void * sio_fd_t;
hlipka 0:8b387bed54c2 48 #endif
hlipka 0:8b387bed54c2 49
hlipka 0:8b387bed54c2 50 /* The following functions can be defined to something else in your cc.h file
hlipka 0:8b387bed54c2 51 or be implemented in your custom sio.c file. */
hlipka 0:8b387bed54c2 52
hlipka 0:8b387bed54c2 53 #ifndef sio_open
hlipka 0:8b387bed54c2 54 /**
hlipka 0:8b387bed54c2 55 * Opens a serial device for communication.
hlipka 0:8b387bed54c2 56 *
hlipka 0:8b387bed54c2 57 * @param devnum device number
hlipka 0:8b387bed54c2 58 * @return handle to serial device if successful, NULL otherwise
hlipka 0:8b387bed54c2 59 */
hlipka 0:8b387bed54c2 60 sio_fd_t sio_open(u8_t devnum);
hlipka 0:8b387bed54c2 61 #endif
hlipka 0:8b387bed54c2 62
hlipka 0:8b387bed54c2 63 #ifndef sio_send
hlipka 0:8b387bed54c2 64 /**
hlipka 0:8b387bed54c2 65 * Sends a single character to the serial device.
hlipka 0:8b387bed54c2 66 *
hlipka 0:8b387bed54c2 67 * @param c character to send
hlipka 0:8b387bed54c2 68 * @param fd serial device handle
hlipka 0:8b387bed54c2 69 *
hlipka 0:8b387bed54c2 70 * @note This function will block until the character can be sent.
hlipka 0:8b387bed54c2 71 */
hlipka 0:8b387bed54c2 72 void sio_send(u8_t c, sio_fd_t fd);
hlipka 0:8b387bed54c2 73 #endif
hlipka 0:8b387bed54c2 74
hlipka 0:8b387bed54c2 75 #ifndef sio_recv
hlipka 0:8b387bed54c2 76 /**
hlipka 0:8b387bed54c2 77 * Receives a single character from the serial device.
hlipka 0:8b387bed54c2 78 *
hlipka 0:8b387bed54c2 79 * @param fd serial device handle
hlipka 0:8b387bed54c2 80 *
hlipka 0:8b387bed54c2 81 * @note This function will block until a character is received.
hlipka 0:8b387bed54c2 82 */
hlipka 0:8b387bed54c2 83 u8_t sio_recv(sio_fd_t fd);
hlipka 0:8b387bed54c2 84 #endif
hlipka 0:8b387bed54c2 85
hlipka 0:8b387bed54c2 86 #ifndef sio_read
hlipka 0:8b387bed54c2 87 /**
hlipka 0:8b387bed54c2 88 * Reads from the serial device.
hlipka 0:8b387bed54c2 89 *
hlipka 0:8b387bed54c2 90 * @param fd serial device handle
hlipka 0:8b387bed54c2 91 * @param data pointer to data buffer for receiving
hlipka 0:8b387bed54c2 92 * @param len maximum length (in bytes) of data to receive
hlipka 0:8b387bed54c2 93 * @return number of bytes actually received - may be 0 if aborted by sio_read_abort
hlipka 0:8b387bed54c2 94 *
hlipka 0:8b387bed54c2 95 * @note This function will block until data can be received. The blocking
hlipka 0:8b387bed54c2 96 * can be cancelled by calling sio_read_abort().
hlipka 0:8b387bed54c2 97 */
hlipka 0:8b387bed54c2 98 u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
hlipka 0:8b387bed54c2 99 #endif
hlipka 0:8b387bed54c2 100
hlipka 0:8b387bed54c2 101 #ifndef sio_tryread
hlipka 0:8b387bed54c2 102 /**
hlipka 0:8b387bed54c2 103 * Tries to read from the serial device. Same as sio_read but returns
hlipka 0:8b387bed54c2 104 * immediately if no data is available and never blocks.
hlipka 0:8b387bed54c2 105 *
hlipka 0:8b387bed54c2 106 * @param fd serial device handle
hlipka 0:8b387bed54c2 107 * @param data pointer to data buffer for receiving
hlipka 0:8b387bed54c2 108 * @param len maximum length (in bytes) of data to receive
hlipka 0:8b387bed54c2 109 * @return number of bytes actually received
hlipka 0:8b387bed54c2 110 */
hlipka 0:8b387bed54c2 111 u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len);
hlipka 0:8b387bed54c2 112 #endif
hlipka 0:8b387bed54c2 113
hlipka 0:8b387bed54c2 114 #ifndef sio_write
hlipka 0:8b387bed54c2 115 /**
hlipka 0:8b387bed54c2 116 * Writes to the serial device.
hlipka 0:8b387bed54c2 117 *
hlipka 0:8b387bed54c2 118 * @param fd serial device handle
hlipka 0:8b387bed54c2 119 * @param data pointer to data to send
hlipka 0:8b387bed54c2 120 * @param len length (in bytes) of data to send
hlipka 0:8b387bed54c2 121 * @return number of bytes actually sent
hlipka 0:8b387bed54c2 122 *
hlipka 0:8b387bed54c2 123 * @note This function will block until all data can be sent.
hlipka 0:8b387bed54c2 124 */
hlipka 0:8b387bed54c2 125 u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
hlipka 0:8b387bed54c2 126 #endif
hlipka 0:8b387bed54c2 127
hlipka 0:8b387bed54c2 128 #ifndef sio_read_abort
hlipka 0:8b387bed54c2 129 /**
hlipka 0:8b387bed54c2 130 * Aborts a blocking sio_read() call.
hlipka 0:8b387bed54c2 131 *
hlipka 0:8b387bed54c2 132 * @param fd serial device handle
hlipka 0:8b387bed54c2 133 */
hlipka 0:8b387bed54c2 134 void sio_read_abort(sio_fd_t fd);
hlipka 0:8b387bed54c2 135 #endif
hlipka 0:8b387bed54c2 136
hlipka 0:8b387bed54c2 137 #ifdef __cplusplus
hlipka 0:8b387bed54c2 138 }
hlipka 0:8b387bed54c2 139 #endif
hlipka 0:8b387bed54c2 140
hlipka 0:8b387bed54c2 141 #endif /* __SIO_H__ */