libHartwer - Documentation
Data Structures | Enumerations | Functions

bcs_tcp.h File Reference

Network routines as defined by Elefant Racing Bayreuth. More...

Go to the source code of this file.

Data Structures

struct  BCS_TCP_connection
 Struct representing a connection. More...
struct  BCS_TCP_package
 Struct representing a network package. More...

Enumerations

enum  BCS_TCP_ids {
  BCS_TCP_MS3_CAN, BCS_TCP_BOARD_CAN, BCS_TCP_PIN_IO, BCS_TCP_DISPLAYMSG,
  BCS_TCP_TELESEED
}
 

Enum containing package ids.

More...

Functions

Int32 BCS_TCP_closeConnection (BCS_TCP_connection *c)
 Closes an exisiting connection and stops listening at the port selected when calling BCS_TCP_waitForConnection.
Int32 BCS_TCP_create (BCS_TCP_package *p)
 Initializes a BCS_TCP_package variable.
Int32 BCS_TCP_delete (BCS_TCP_package *p)
 Deletes and frees a BCS_TCP_package.
BCS_TCP_ids BCS_TCP_getID (BCS_TCP_package *p)
 Gets the id of a package.
Int32 BCS_TCP_getSize (BCS_TCP_package *p)
 Gets the current size of a package's datablock.
char BCS_TCP_readChar (BCS_TCP_package *p)
 Reads a char from a received BCS_TCP_package.
Int32 BCS_TCP_readInt (BCS_TCP_package *p)
 Reads an int from a received BCS_TCP_package.
Int16 BCS_TCP_readShort (BCS_TCP_package *p)
 Reads a short from a received BCS_TCP_package.
Int32 BCS_TCP_receive (BCS_TCP_connection *c, BCS_TCP_package *p)
 Receives a package over a given connection.
Int32 BCS_TCP_send (BCS_TCP_connection *c, BCS_TCP_package *p)
 Sends a filled package over a given connection.
void BCS_TCP_setID (BCS_TCP_package *p, BCS_TCP_ids id)
 Sets the id of a package.
Int32 BCS_TCP_waitForConnection (const char *port, BCS_TCP_connection *c)
 When called this function will listen at the given port (just like a server) for incoming connection requests.
void BCS_TCP_writeChar (BCS_TCP_package *p, char c)
 Writes a char to an exisiting BCS_TCP_package.
void BCS_TCP_writeInt (BCS_TCP_package *p, Int32 i)
 Writes an int to an existing BCS_TCP_package.
void BCS_TCP_writeShort (BCS_TCP_package *p, Int16 i)
 Writes a short to an existing BCS_TCP_package.

Detailed Description

Date:
16.04.2009
Author:
Marius Zwicker This file provides server capabilities and package handling methods for tcp/ip transmission. Its counterpart is the connector class implemented in Java. All methods work according to the erb lan protokoll, i.e. a package consists of an id (2 bytes), size (4 bytes) and a datablock (length specified in size).

2 || 4 || ...

Transferring data should be handled the following way:

When receiving a package everything happens the other way round

Data can be read in the same order as it was written.

NOTE: You can't read from a package you created and can't write to a package you received. Still receiving and sending the same package is possible.


Enumeration Type Documentation

Enumerator:
BCS_TCP_MS3_CAN 

messages related to ecu

BCS_TCP_BOARD_CAN 

messages related to the whole board can network

BCS_TCP_PIN_IO 

messages related to simulation the digital inputs

BCS_TCP_DISPLAYMSG 

messages to transfer display messages for debugging

BCS_TCP_TELESEED 

< Data for Telemetry Client


Function Documentation

Int32 BCS_TCP_closeConnection ( BCS_TCP_connection c)
Parameters:
cPointer to BCS_TCP_connection that needs to be closed
Int32 BCS_TCP_create ( BCS_TCP_package p)

Should be called before every use.

Parameters:
pPointer to a BCS_TCP_package
Returns:
BCS Errorcodes
Int32 BCS_TCP_delete ( BCS_TCP_package p)

Make sure to call this function whenever a package is not needed. Otherwise you might geht memory leaks and run out of available memory.

Parameters:
pPointer to a BCS_TCP_package
Returns:
BCS Errorcodes
BCS_TCP_ids BCS_TCP_getID ( BCS_TCP_package p)
Parameters:
pPointer to a BCS_TCP_package
Returns:
Package id
Int32 BCS_TCP_getSize ( BCS_TCP_package p)
Parameters:
pPointer to a BCS_TCP_package
Returns:
Size of data part
char BCS_TCP_readChar ( BCS_TCP_package p)
Parameters:
pPointer to a BCS_TCP_package
Returns:
Read char
Int32 BCS_TCP_readInt ( BCS_TCP_package p)
Parameters:
pPointer to a BCS_TCP_package
Returns:
Read int
Int16 BCS_TCP_readShort ( BCS_TCP_package p)
Parameters:
pPointer to a BCS_TCP_package
Returns:
Read short
Int32 BCS_TCP_receive ( BCS_TCP_connection c,
BCS_TCP_package p 
)

Returns 2 (BCS_ERR_CONNECTIONCLOSED) when connection was closed by remote peer.

Parameters:
cPointer to an existing BCS_TCP_connection
pPointer to a BCS_TCP_package. Note: Does not need to be initialized, this will happen implicitly.
Int32 BCS_TCP_send ( BCS_TCP_connection c,
BCS_TCP_package p 
)
Parameters:
cPointer to a BCS_TCP_connection
pPointer to a BCS_TCP_package
Returns:
BCS errorcode
void BCS_TCP_setID ( BCS_TCP_package p,
BCS_TCP_ids  id 
)
Parameters:
pPointer to a BCS_TCP_package
idID selection
Int32 BCS_TCP_waitForConnection ( const char *  port,
BCS_TCP_connection c 
)

As soon as a request is made it will return and argument c will contain the new connection. At the moment only one connection to one client at a time is possible.

Parameters:
portPort number your server should listen at
cPointer to a connection variable
Returns:
BCS errorcode
void BCS_TCP_writeChar ( BCS_TCP_package p,
char  c 
)
Parameters:
pPointer to a BCS_TCP_package
cChar to be written
void BCS_TCP_writeInt ( BCS_TCP_package p,
Int32  i 
)
Parameters:
pPointer to a BCSP_TCP_package
iInt to be written
void BCS_TCP_writeShort ( BCS_TCP_package p,
Int16  i 
)
Parameters:
pPointer to a BCS_TCP_package
iShort to be written

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.