libHartwer - Documentation

bcs_tcp.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2008-2011 Marius Zwicker / Elefant Racing Bayreuth. 
00003 * All rights reserved.
00004 *
00005 * @ERB_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 * 
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 * 
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 *      http://www.elefantracing.de
00020 *
00021 * @ERB_OPEN_LICENSE_HEADER_END@
00022 */
00023 
00056 #ifndef BCS_TCP_H_
00057 #define BCS_TCP_H_
00058 
00059 #ifdef __cplusplus
00060 extern "C" {
00061 #endif
00062 
00063 #include "bcs_errorcodes.h"
00064 #include <sys/socket.h>
00065 
00069 typedef enum {
00070        BCS_TCP_MS3_CAN, 
00071        BCS_TCP_BOARD_CAN, 
00072        BCS_TCP_PIN_IO, 
00073        BCS_TCP_DISPLAYMSG, 
00074        BCS_TCP_TELESEED 
00075 } BCS_TCP_ids;
00076 
00080 typedef struct {
00081        Int32 m_size, m_pos;
00082        Int16 m_id;
00083        char * m_data;
00084 } BCS_TCP_package;
00085 
00092 Int32 BCS_TCP_create(BCS_TCP_package * p);
00093 
00101 Int32 BCS_TCP_delete(BCS_TCP_package * p);
00102 
00109 void BCS_TCP_writeInt(BCS_TCP_package * p, Int32 i);
00110 
00117 void BCS_TCP_writeShort(BCS_TCP_package * p, Int16 i);
00118 
00125 void BCS_TCP_writeChar(BCS_TCP_package * p, char c);
00126 
00133 Int16 BCS_TCP_readShort(BCS_TCP_package * p);
00134 
00141 Int32 BCS_TCP_readInt(BCS_TCP_package * p);
00142 
00149 char BCS_TCP_readChar(BCS_TCP_package * p);
00150 
00157 void BCS_TCP_setID(BCS_TCP_package * p, BCS_TCP_ids id);
00158 
00165 BCS_TCP_ids BCS_TCP_getID(BCS_TCP_package * p);
00166 
00173 Int32 BCS_TCP_getSize(BCS_TCP_package * p);
00174 
00178 typedef struct {
00179        Int32 receive_fd; // listen on receive_fd
00180        Int32 send_fd; // new connection at send_fd
00181        struct sockaddr_storage client_addr;
00182 } BCS_TCP_connection;
00183 
00193 Int32 BCS_TCP_waitForConnection(const char * port, BCS_TCP_connection * c);
00194 
00202 Int32 BCS_TCP_send(BCS_TCP_connection * c, BCS_TCP_package * p);
00203 
00211 Int32 BCS_TCP_receive( BCS_TCP_connection * c, BCS_TCP_package * p );
00212 
00218 Int32 BCS_TCP_closeConnection( BCS_TCP_connection * c);
00219 
00220 #ifdef __cplusplus
00221 }
00222 #endif
00223 
00224 #endif /* BCS_TCP_H_ */

Generated on Fri Feb 11 2011 18:25:46 for libHartwer by Doxygen 1.7.3
Content © 2009-2011 Elefant Racing Bayreuth & MLBA (About) – Design © 2010 Emzeat. All Rights reserved.