Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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;
00180 Int32 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