Main Page | Modules | Data Structures | File List | Data Fields

Ab protocol interface

These functions should be called to get the AB protocol up and running. More...

Defines

#define DEBUG   0
 Set to 1 to get some debugging on LCD, although I do not recommend this.

#define WRITE_WAIT_TIME   10
#define WRITE_TIMEOUT   100

Functions

int init_ab_protocol_8 (void(*u_portHandler)(const unsigned char *message, unsigned char length), unsigned char id)
 Initialises everything needed for use of reliable protocol for short messages (<253 bytes).

int ab_awrite (const unsigned char *message, unsigned char length, unsigned char destination)
 Use this function to asynchronously send a message.

int ab_swrite (const unsigned char *message, unsigned char length, unsigned char destination)
 Use this function to synchronously send a message.

int init_ab_protocol_16 (void(*u_portHandler)(const unsigned char *message, unsigned short length), unsigned char id, unsigned char max_id)
 Initialises everything needed for use of reliable protocol for long messages (<65533 bytes).

int ab_swrite_16 (const unsigned char *message, unsigned short length, unsigned char destination)
 Use this function to synchronously send a long message.


Variables

unsigned char ab_source
 In your porthandler, you can use this variable to know from where the message comes.


Detailed Description

These functions should be called to get the AB protocol up and running.


Define Documentation

#define WRITE_TIMEOUT   100
 

Defines (in ticks) the waiting time for a retransmission to a certain site which did not send any acks Timeout is calculated as follows : WRITE_TIMEOUT + (random between 0 and WRITE_TIMEOUT)

Definition at line 153 of file ab.h.

#define WRITE_WAIT_TIME   10
 

Defines (in ticks) the waiting time for each loop in the send thread

A message to a site will AT MOST be delayed with this time before it will be sent

(of course, this is an estimate, since we are not running on a realtime OS, and threading may affect these values)

Definition at line 148 of file ab.h.


Function Documentation

int ab_awrite const unsigned char *  message,
unsigned char  length,
unsigned char  destination
 

Use this function to asynchronously send a message.

The message is added to the list and will be sent as soon as possible. The function returns immediately

Parameters:
message The message to send
length The length of the message
destination The destination for the message
Returns:
0 on success, 1 otherwise

Definition at line 410 of file ab.c.

int ab_swrite const unsigned char *  message,
unsigned char  length,
unsigned char  destination
 

Use this function to synchronously send a message.

The message is added to the list and will be sent as soon as possible. The function returns when an acknowledgment is received for the message

Parameters:
message The message to send
length The length of the message
destination The destination for the message
Returns:
0 on success, 1 otherwise

Definition at line 425 of file ab.c.

int ab_swrite_16 const unsigned char *  message,
unsigned short  length,
unsigned char  destination
 

Use this function to synchronously send a long message.

The message is added to the list and will be sent as soon as possible. The function returns when an acknowledgment is received for the message

Parameters:
message The message to send
length The length of the message
destination The destination for the message
Returns:
number of bytes sent, 0 on error
Remarks:
Can only be used in conjunction with init_ab_protocol_16. (In fact this function is built on top of init_ab_protocol_8, so you should definitely not use any other sending function)

int init_ab_protocol_16 void(*  u_portHandler)(const unsigned char *message, unsigned short length),
unsigned char  id,
unsigned char  max_id
 

Initialises everything needed for use of reliable protocol for long messages (<65533 bytes).

Parameters:
u_portHandler The function that will be called when a message is received. Since large messages may cause insufficient memory, a message NULL will be sent to the user when such an error occurs. In that case the message is lost.
id The id of the current site
max_id The highest id in the system
Returns:
0 on success 1, otherwise (memory allocation problems)
Remarks:
Can only be used with the function ab_swrite_16

A future release may take care of the NULL messages sent to the user in case of memory allocation problems, by not accepting the message, so that the sender must resend its message until enough memory is freed. For the moment, this is not the case, and the sender thinks that the message is handled correctely.

int init_ab_protocol_8 void(*  u_portHandler)(const unsigned char *message, unsigned char length),
unsigned char  id
 

Initialises everything needed for use of reliable protocol for short messages (<253 bytes).

Parameters:
u_portHandler The function that will be called when a message is received
id The id of the current site
Returns:
0 on success

Definition at line 353 of file ab.c.


Generated on Sat Mar 12 16:12:58 2005 for Alternating Bit by doxygen 1.3.3