GNU Radio's SATNOGS Package
ax25.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4  *
5  * Copyright (C) 2016,2018 Libre Space Foundation <http://librespacefoundation.org/>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef INCLUDE_SATNOGS_AX25_H_
22 #define INCLUDE_SATNOGS_AX25_H_
23 
24 #include <satnogs/crc.h>
25 #include <satnogs/log.h>
26 #include <limits.h>
27 #include <stdint.h>
28 #include <string>
29 
30 namespace gr {
31 
32 namespace satnogs {
33 
34 class ax25 {
35 public:
36  static const size_t min_addr_len = 14;
37  static const size_t max_addr_len = (2 * 7 + 8 * 7);
38  static const size_t max_ctrl_len = 2;
39  static const size_t pid_len = 1;
40  static const size_t max_header_len = (max_addr_len + max_ctrl_len + pid_len);
41  static const uint8_t sync_flag = 0x7e;
42  static const size_t callsign_max_len = 6;
43 
44  /**
45  * AX.25 Frame types
46  */
47  typedef enum {
48  I_FRAME, //!< Information frame
49  S_FRAME, //!< Supervisory frame
50  U_FRAME, //!< Unnumbered frame
51  UI_FRAME //!< Unnumbered information frame
52  } frame_type_t;
53 
54  static uint16_t
55  crc(const uint8_t *buffer, size_t len)
56  {
57  return crc::crc16_ax25(buffer, len);
58  }
59 };
60 
61 } // namespace satnogs
62 } // namespace gr
63 
64 #endif /* INCLUDE_SATNOGS_AX25_H_ */
static const size_t max_header_len
Definition: ax25.h:40
Unnumbered information frame.
Definition: ax25.h:51
static const size_t callsign_max_len
Definition: ax25.h:42
static uint16_t crc(const uint8_t *buffer, size_t len)
Definition: ax25.h:55
static const size_t pid_len
Definition: ax25.h:39
static const size_t min_addr_len
Definition: ax25.h:36
frame_type_t
Definition: ax25.h:47
Definition: amsat_duv_decoder.h:29
static const size_t max_addr_len
Definition: ax25.h:37
static const uint8_t sync_flag
Definition: ax25.h:41
Information frame.
Definition: ax25.h:48
static uint16_t crc16_ax25(const uint8_t *data, size_t len)
Supervisory frame.
Definition: ax25.h:49
Unnumbered frame.
Definition: ax25.h:50
static const size_t max_ctrl_len
Definition: ax25.h:38
Definition: ax25.h:34