Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > BestEffortMessaging
diff LossyCom.h @ 1:826448e34e80
added data to message handler
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 08 Mar 2012 20:06:00 +0100 |
| parents | 29d8b41926f0 |
| children | b6dd31dbab8c |
line diff
1.1 --- a/LossyCom.h Wed Mar 07 19:46:37 2012 +0100 1.2 +++ b/LossyCom.h Thu Mar 08 20:06:00 2012 +0100 1.3 @@ -21,23 +21,27 @@ 1.4 1.5 #include <stdint.h> 1.6 1.7 - 1.8 +/*********************************** 1.9 + * General Defines 1.10 + ***********************************/ 1.11 +//never use this number as a endpoint! 1.12 +#define BROADCAST_ID 65535 1.13 1.14 /*********************************** 1.15 * Type Definitions 1.16 ***********************************/ 1.17 1.18 -#define BROADCAST_ID 65535 1.19 -#define ENDPOINT_ID_SHIFT 32 1.20 -#define TRIGGER_SHIFT 48 1.21 - 1.22 /* 1.23 * A message consists of the 1.24 - * 16bit saved trigger value when the message was sent 1.25 + * 16bit saved trigger value +1 when the message was sent 1.26 * 16bit receiver identifier, this is the index of the slot in the array 1.27 * 65536 is the broadcast identifier 1.28 * 32bit message body, the message format is defined by the endpoints 1.29 + * 1.30 + * | 16bit trigger value | 16bit receiverID | 32bit message body | 1.31 */ 1.32 +#define ENDPOINT_ID_SHIFT 32 1.33 +#define TRIGGER_SHIFT 48 1.34 typedef uint64_t lossyCom__msg_t; 1.35 typedef uint32_t lossyCom__msgBody_t; 1.36 typedef uint16_t lossyCom__endpointID_t; 1.37 @@ -47,7 +51,7 @@ 1.38 * Example: 1.39 * void handler_func(lossyCom__endpointID_t senderID, lossyCom__msgBody_t msg); 1.40 */ 1.41 -typedef void (*lossyCom__msgHandler) (lossyCom__endpointID_t, lossyCom__msgBody_t); 1.42 +typedef void (*lossyCom__msgHandler) (lossyCom__endpointID_t, lossyCom__msgBody_t, void*); 1.43 1.44 /* 1.45 * Central communication structure. 1.46 @@ -64,8 +68,9 @@ 1.47 typedef struct { 1.48 uint16_t localTriggerCopy; 1.49 lossyCom__endpointID_t endpointID; 1.50 - lossyCom__exchange_t* centralExchangePtr; 1.51 - lossyCom__msgHandler* msgHandler; 1.52 + lossyCom__exchange_t* centralExchange; 1.53 + lossyCom__msgHandler msgHandler; 1.54 + void* msgHandlerData; 1.55 } lossyCom__endpoint_t; 1.56 1.57 /*********************************** 1.58 @@ -77,7 +82,8 @@ 1.59 void lossyCom__initialize_endpoint(lossyCom__endpoint_t* localEndpoint, 1.60 lossyCom__exchange_t* exchange, 1.61 lossyCom__endpointID_t endpointID, 1.62 - lossyCom__msgHandler* msgHandler); 1.63 + lossyCom__msgHandler msgHandler, 1.64 + void* msgHandlerData); 1.65 1.66 void lossyCom__broadcastMsg(lossyCom__endpoint_t* localEndpoint, 1.67 lossyCom__msgBody_t msg);
