Main Page | Data Structures | Directories | File List | Data Fields | Globals

comm.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define MAX_RETRIES   3
#define MAX_MSG_SIZE   1024
#define COMM_PERIOD_MS   50
#define COMM_PERIOD_US   (COMM_PERIOD_MS*1000)

Functions

int cartcomm_connect (char *host, int port)
 Connect to the cart.
void cartcomm_disconnect (int sockfd)
 Disconnect from the cart.
int cartcomm_synchronize (int sockfd)
 Synchronize with the cart.
int cartcomm_connect_sync (char *host, int port)
 Connect and synchronize to the cart.
int cartcomm_send_msg (int sockfd, char *buf)
 Send a message to the cart.
int cartcomm_read_msg (int sockfd, char *buf, int bufsize)
 Read a message from the cart.


Define Documentation

#define COMM_PERIOD_MS   50
 

Definition at line 7 of file comm.h.

#define COMM_PERIOD_US   (COMM_PERIOD_MS*1000)
 

Definition at line 8 of file comm.h.

Referenced by drive().

#define MAX_MSG_SIZE   1024
 

Definition at line 5 of file comm.h.

Referenced by cartcomm_read_msg().

#define MAX_RETRIES   3
 

Definition at line 4 of file comm.h.


Function Documentation

int cartcomm_connect char *  host,
int  port
 

Connect to the cart.

Parameters:
host host with which to connect
port port on which to connect
Returns:
socket's file descriptor number (or -1, on failure)

Definition at line 25 of file comm.c.

References DEBUG1, and DEBUG2.

Referenced by cartcomm_connect_sync().

int cartcomm_connect_sync char *  host,
int  port
 

Connect and synchronize to the cart.

Parameters:
host host with which to connect
port port on which to connect
Returns:
socket's file descriptor number (or -1, on failure)

Definition at line 143 of file comm.c.

References cartcomm_connect(), cartcomm_disconnect(), cartcomm_synchronize(), and DEBUG2.

Referenced by drive().

Here is the call graph for this function:

void cartcomm_disconnect int  sockfd  ) 
 

Disconnect from the cart.

Parameters:
sockfd socket's file descriptor number

Definition at line 85 of file comm.c.

Referenced by cartcomm_connect_sync(), and drive().

int cartcomm_read_msg int  sockfd,
char *  buf,
int  bufsize
 

Read a message from the cart.

Parameters:
sockfd socket's file descriptor number
buf buffer to read into
bufsize size of buf in bytes
Return values:
0 success
-1 failure
Note:
This function takes care of a variety of problems associated with using TCP as a datagram delivery protocol. We will gurantee that on success, we have a full frame; partial frames are discarded. If we have fallen behind, we will skip frames to get the latest frame available.
Warning:
This function blocks. Our read will timeout after 2x the communication cycle's length.

Definition at line 177 of file comm.c.

References DEBUG1, and MAX_MSG_SIZE.

Referenced by cartcomm_synchronize(), and drive().

int cartcomm_send_msg int  sockfd,
char *  buf
 

Send a message to the cart.

Parameters:
sockfd socket's file descriptor number
buf buffer containing the message to send
Return values:
0 success
-1 failure
Note:
We will retry up to MAX_RETRIES times to send the message.

Definition at line 240 of file comm.c.

References DEBUG1.

Referenced by cartcomm_synchronize(), and drive().

int cartcomm_synchronize int  sockfd  ) 
 

Synchronize with the cart.

Synchronization means we exchange messages back and forth with each other until the cart is happy with our communications.

Parameters:
sockfd socket's file descriptor number
Return values:
0 success
-1 failure

Definition at line 96 of file comm.c.

References cartcomm_decode_msg(), cartcomm_read_msg(), cartcomm_send_msg(), cframe_t, DEBUG1, DEBUG2, and cframe::status.

Referenced by cartcomm_connect_sync().

Here is the call graph for this function:


Generated on Thu Sep 6 13:13:12 2007 for driver by  doxygen 1.3.9.1