00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00119
00120
00121
00122
00123
00124 #include <lnp/lnp.h>
00125 #include <unistd.h>
00126 #include <stdlib.h>
00127 #include <string.h>
00128 #include <semaphore.h>
00129 #include <time.h>
00130
00136
00138 #define DEBUG 0
00139
00148 #define WRITE_WAIT_TIME 10
00149
00153 #define WRITE_TIMEOUT 100
00154
00156
00157
00162
00163 #define HEADER_SZ 3
00164
00167 typedef struct message_struct {
00169 unsigned char* txt;
00170
00172 unsigned char len;
00173
00176 sem_t sem_ack;
00177
00179 struct message_struct *next;
00180 } msg_s ;
00181
00182
00185 typedef struct site_struct {
00187 unsigned char id;
00188
00192 unsigned char status;
00193
00196 time_t timeout_wait;
00197
00199 struct site_struct *next;
00200
00202 msg_s * head;
00203 } site_s ;
00205
00206
00209
00211 unsigned char ab_source;
00212
00213
00224 int ab_awrite(const unsigned char* message, unsigned char length, unsigned char destination);
00225
00226
00237 int ab_swrite(const unsigned char* message, unsigned char length, unsigned char destination);
00238
00246 int init_ab_protocol_8(void (*u_portHandler) (const unsigned char *message, unsigned char length),
00247 unsigned char id);
00248
00267 int init_ab_protocol_16(void (*u_portHandler) (const unsigned char *message, unsigned short length),
00268 unsigned char id, unsigned char max_id);
00269
00283 int ab_swrite_16(const unsigned char* message, unsigned short length, unsigned char destination);
00284