SysIo  1.9.0
Embedded Library and tools
tnc.h
1 
9 #ifndef _SYSIO_TNC_H_
10 #define _SYSIO_TNC_H_
11 
12 #include <sysio/defs.h>
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 /* ========================================================================== */
18 #include <stdio.h>
19 
32 /* constants ================================================================ */
33 #define TNC_SOH 1
34 #define TNC_STX 2
35 #define TNC_ETX 3
36 #define TNC_EOT 4
37 #define TNC_TXT 5
38 #define TNC_CRC 6
39 
43 typedef enum {
44 
45  TNC_SUCCESS = 0,
46  TNC_CRC_ERROR = -1,
47  TNC_NOT_ENOUGH_MEMORY = -2,
48  TNC_OBJECT_NOT_FOUND = -3,
49  TNC_ILLEGAL_MSG = -4,
50  TNC_FILE_NOT_FOUND = -5,
51  TNC_IO_ERROR = -6
52 
53 } eTncError;
54 
55 //##############################################################################
56 //# #
57 //# xTnc Class #
58 //# #
59 //##############################################################################
60 
64 typedef struct xTnc {
65 
66  int fin;
67  int fout;
68  uint8_t *rxbuf;
69  size_t len;
70  uint16_t crc_rx;
71  uint16_t crc_tx;
72  int state;
73  uint8_t cnt;
74  uint8_t msb;
75 } xTnc;
76 
83 xTnc * xTncNew (size_t iRxBufferSize);
84 
90 void vTncDelete (xTnc *p);
91 
97 int iTncClear (xTnc *p);
98 
105 int iTncSetFdin (xTnc *p, int fdin);
106 
113 int iTncSetFdout (xTnc *p, int fdout);
114 
127 int iTncPoll(xTnc *tnc);
128 
136 ssize_t iTncWrite (xTnc *tnc, const void *buf, size_t count);
137 
141 int iTncError (xTnc *tnc);
142 
148 /* ========================================================================== */
149 #ifdef __cplusplus
150  }
151 #endif
152 
153 #endif /* _SYSIO_TNC_H_ */
Definition: tnc.h:64
uint16_t crc_tx
received from tx CRC
Definition: tnc.h:71
int iTncSetFdin(xTnc *p, int fdin)
void vTncDelete(xTnc *p)
int iTncPoll(xTnc *tnc)
eTncError
Definition: tnc.h:43
xTnc * xTncNew(size_t iRxBufferSize)
int iTncSetFdout(xTnc *p, int fdout)
int iTncClear(xTnc *p)
int fout
stream used to access the physical output
Definition: tnc.h:67
size_t len
buffer length
Definition: tnc.h:69
ssize_t iTncWrite(xTnc *tnc, const void *buf, size_t count)
int iTncError(xTnc *tnc)
uint8_t * rxbuf
buffer for payload
Definition: tnc.h:68
uint16_t crc_rx
computed rx CRC
Definition: tnc.h:70
struct xTnc xTnc
int fin
stream used to access the physical input
Definition: tnc.h:66