AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
Liaisons par trames

Description détaillée

Ce module fournit des fonctions permettant des gérer les liaisons par trames avec contrôle d'erreur.
Les messages ont le format suivant:
<SOH><STX>[Data Hexa ASCII]<ETX>[CRC CCITT Hexa ASCII]<EOT>

Graphe de collaboration de Liaisons par trames:

Fonctions

int iTncError (struct xTnc *tnc)
 
int iTncPoll (struct xTnc *tnc)
 
ssize_t iTncWrite (struct xTnc *tnc, const void *buf, size_t count)
 
void vTncClear (struct xTnc *p)
 
void vTncInit (struct xTnc *p, FILE *fin, FILE *fout)
 

Macros

#define TNC_CRC   6
 
#define TNC_EOT   4
 
#define TNC_ETX   3
 
#define TNC_SOH   1
 
#define TNC_STX   2
 
#define TNC_TXT   5
 

Énumérations

enum  eTncError {
  TNC_SUCCESS = 0, TNC_CRC_ERROR = -1, TNC_NOT_ENOUGH_MEMORY = -2, TNC_OBJECT_NOT_FOUND = -3,
  TNC_ILLEGAL_MSG = -4, TNC_FILE_NOT_FOUND = -5, TNC_IO_ERROR = -6
}
 

Documentation du type de l'énumération

enum eTncError

List of error codes returned by the functions.

Définition à la ligne 60 du fichier tnc.h.

60  {
61 
62  TNC_SUCCESS = 0,
63  TNC_CRC_ERROR = -1,
64  TNC_NOT_ENOUGH_MEMORY = -2,
65  TNC_OBJECT_NOT_FOUND = -3,
66  TNC_ILLEGAL_MSG = -4,
67  TNC_FILE_NOT_FOUND = -5,
68  TNC_IO_ERROR = -6
69 
70 } eTncError;
eTncError
Definition: tnc.h:60

Documentation des fonctions

int iTncError ( struct xTnc *  tnc)

Retruns the last error code.

int iTncPoll ( struct xTnc *  tnc)

Check if there are any TNC messages to be processed. This function read available characters from the medium and search for any TNC messages. If a message is found, this function return true and the message can be read with iTncRead(). This function may be blocking if there are no available chars and the FILE used in tnc to access the medium is configured in blocking mode.

Paramètres
tncTNC object to operate on.
Renvoie
true if , negative value on error
Exemples:
net/tnc/master/demo_tnc_master.c, et net/tnc/slave/demo_tnc_slave.c.
ssize_t iTncWrite ( struct xTnc *  tnc,
const void *  buf,
size_t  count 
)

Send an TNC message

Paramètres
tncTNC object to operate on.
framemessage to send
Renvoie
TNC_SUCCESS, negative value on error
Exemples:
net/tnc/master/demo_tnc_master.c, et net/tnc/slave/demo_tnc_slave.c.
void vTncClear ( struct xTnc *  p)

Clear all fields of the object

void vTncInit ( struct xTnc *  p,
FILE *  fin,
FILE *  fout 
)

Create and initialize a new xTnc object

This object should be deleted with vTncDelete()

Renvoie
pointer on the object, NULL on error
Exemples:
net/tnc/master/demo_tnc_master.c, et net/tnc/slave/demo_tnc_slave.c.