AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
ax25.h
1 
34 #ifndef _AVRIO_AX25_H_
35 #define _AVRIO_AX25_H_
36 
37 #include <avrio/defs.h>
38 
39 __BEGIN_C_DECLS
40 /* ========================================================================== */
41 #include <stdio.h>
42 #include "avrio-board-ax25.h"
43 #include <avrio/hdlc.h>
44 
60 /* constants ================================================================ */
64 #define AX25_MIN_FRAME_LEN 18
65 
70 #define AX25_CTRL_UI 0x03
71 
76 #define AX25_PID_NOLAYER3 0xF0
77 
81 #define AX25_MAX_RPT 8
82 
83 /* macros =================================================================== */
89 #define AX25_CALL(str, id) {.call = (str), .ssid = (id) }
90 
106 #define AX25_PATH(dst, src, ...) { dst, src, ## __VA_ARGS__ }
107 
118 #define vAx25Send(ax25, dst, src, buf, len) vAx25SendVia(ax25, ({static xAx25Node __path[]={dst, src}; __path;}), 2, buf, len)
119 
120 /* structures =============================================================== */
121 struct xAx25Frame; // fwd declaration
122 struct xAx25;
123 
124 /* types ==================================================================== */
128 typedef void (*vAx25CallBack)(struct xAx25Frame *msg);
129 
133 typedef struct xAx25Node
134 {
135  char call[6];
136  uint8_t ssid;
137 } xAx25Node;
138 
142 typedef struct xAx25Frame
143 {
146  #if CONFIG_AX25_RPT_LST
147  xAx25Node rpt_lst[AX25_MAX_RPT];
148  uint8_t rpt_cnt;
149  uint8_t rpt_flags;
150  #define AX25_REPEATED(msg, idx) ((msg)->rpt_flags & _BV(idx))
151  #endif
152  uint16_t ctrl;
153  uint8_t pid;
154  const uint8_t *info;
155  size_t len;
156 } xAx25Frame;
157 
163 typedef struct xAx25
164 {
166  FILE *fin;
167  FILE *fout;
168  size_t frm_len;
169  uint16_t crc_in;
170  uint16_t crc_out;
172  bool sync;
173  bool escape;
174 } xAx25;
175 
176 /* internal public functions ================================================ */
185 void vAx25Init (struct xAx25 *ax25, FILE *fin, FILE *fout, vAx25CallBack hook);
186 
201 void vAx25Poll (struct xAx25 *ax25);
202 
212 void vAx25SendVia (struct xAx25 *ax25, const xAx25Node *path, size_t path_len, const void *_buf, size_t len);
213 
220 void vAx25Print (FILE *f, const xAx25Frame *msg);
221 
222 #if defined(__DOXYGEN__)
223 /*
224  * __DOXYGEN__ defined
225  * Partie documentation ne devant pas être compilée.
226  * ===========================================================================*/
227 
243 #define CONFIG_AX25_FRAME_BUF_LEN
244 
251 #define CONFIG_AX25_RPT_LST
252 
253 /* ========================================================================== */
254 #endif /* __DOXYGEN__ defined */
255 
260 /* ========================================================================== */
261 __END_C_DECLS
262 #endif /* _AVRIO_AX25_H_ */
uint16_t crc_out
CRC calculé en sortie.
Definition: ax25.h:170
const uint8_t * info
Pointeur sur les informations (payload)
Definition: ax25.h:154
xAx25Node dst
Destination de la trame.
Definition: ax25.h:145
vAx25CallBack hook
Fonction de traitement des trames reçues.
Definition: ax25.h:171
bool sync
Vrai si un flag HDLC de début de trame a été reçu.
Definition: ax25.h:172
void vAx25Init(struct xAx25 *ax25, FILE *fin, FILE *fout, vAx25CallBack hook)
uint16_t ctrl
Champs contrôle AX25.
Definition: ax25.h:152
Definition: ax25.h:163
void(* vAx25CallBack)(struct xAx25Frame *msg)
Definition: ax25.h:128
void vAx25Print(FILE *f, const xAx25Frame *msg)
char call[6]
Indicatif composé d&#39;au plus 6 caractères ASCII (lettres et chiffres)
Definition: ax25.h:135
struct xAx25Frame xAx25Frame
bool escape
Vrai si un cacractère d&#39;échappement a été reçu.
Definition: ax25.h:173
struct xAx25Node xAx25Node
uint8_t pid
Champs d&#39;identification du protocole AX25.
Definition: ax25.h:153
xAx25Node src
Source de la trame.
Definition: ax25.h:144
FILE * fout
Fichier pour accèder à la couche physique en sortie.
Definition: ax25.h:167
#define CONFIG_AX25_FRAME_BUF_LEN
Taille buffer de réception.
Definition: ax25.h:243
uint8_t ssid
Identifiant de sous-station (0 à 15)
Definition: ax25.h:136
void vAx25Poll(struct xAx25 *ax25)
size_t frm_len
Nombre d&#39;octets reçus.
Definition: ax25.h:168
void vAx25SendVia(struct xAx25 *ax25, const xAx25Node *path, size_t path_len, const void *_buf, size_t len)
struct xAx25 xAx25
size_t len
Nombre d&#39;octets du payload.
Definition: ax25.h:155
uint16_t crc_in
CRC calculé en entrée.
Definition: ax25.h:169
FILE * fin
Fichier pour accèder à la couche physique en entrée.
Definition: ax25.h:166
#define AX25_MAX_RPT
Definition: ax25.h:81