SysIo  1.9.0
Embedded Library and tools
tnc.hpp
1 
9 #ifndef _SYSIO_TNC_HPP_
10 #define _SYSIO_TNC_HPP_
11 
12 #include <string>
13 #include <stdio.h>
14 #include <sysio/defs.h>
15 
16 struct xTnc;
17 
28 class Tnc {
29 
30 public:
31  enum {
32  SOH = 1,
33  STX = 2,
34  ETX = 3,
35  EOT = 4,
36  TXT = 5,
37  CRC = 6,
38  SUCCESS = 0,
39  CRC_ERROR = -1,
40  NOT_ENOUGH_MEMORY = -2,
41  OBJECT_NOT_FOUND = -3,
42  ILLEGAL_MSG = -4,
43  FILE_NOT_FOUND = -5,
44  IO_ERROR = -6,
45  };
46 
47  typedef enum {
48 
49  NO_PACKET = 0,
50  APRS_PACKET = 1,
51  SSDV_PACKET = 2,
52  UNKN_PACKET = 3
53  } ePacketType;
54 
55  Tnc(unsigned iRxBufferSize = 80);
56  ~Tnc ();
57  int getError();
58 
59  void setFdout (int fdo);
60  int getFdout() const;
61  void setFdin (int fdi);
62  int getFdin() const;
63 
64  int poll();
65  int getRxlen();
66  int getPacketType() const;
67  int getSsdvImageId() const;
68  int getSsdvPacketId() const;
69  const char * read() const;
70  int write (const char *buf);
71 
72  int write (const void *buf, unsigned count);
73  int read (void * buf, unsigned count);
74 
75 
76  void * malloc (unsigned nbytes);
77  void free (void *);
78  FILE *fopen (char * filename, char * mode);
79  int fclose (FILE *f);
80  unsigned fread(void *ptr, unsigned size, unsigned nobj, FILE * f);
81  unsigned fwrite(void *ptr, unsigned size, unsigned nobj, FILE * f);
82  int feof(FILE * f);
83  int ferror(FILE * f);
84 
85 private:
86  struct xTnc *p;
87  unsigned char *rx_buf;
88  unsigned rx_buf_size;
89  unsigned rx_len;
90  ePacketType pkt_type;
91  int ssdv_image_id;
92  int ssdv_packet_id;
93 };
99 /* ========================================================================== */
100 #endif /* _SYSIO_TNC_HPP_ */
Definition: tnc.h:64
Definition: tnc.hpp:28