COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
ax25class.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef AX25LIB
31 #define AX25LIB
32 
33 #include "support/configCosmos.h"
34 #include "support/cosmos-errno.h"
35 
36 #include <cstring>
37 #include <iostream>
38 
39 #define PACKETMAX 1024
40 
41 
43 {
44 
45 public:
46  struct __attribute__ ((packed)) packet_header
47  {
48  uint8_t destination_callsign[6];
49  uint8_t destination_stationID;
50  uint8_t source_callsign[6];
51  uint8_t source_stationID;
52  uint8_t control = 0x03;
53  uint8_t protocolID = 0xf0;
54  };
55 
57  {
58  packet_header header;
59  vector <uint8_t> data;
60  };
61 
62  Ax25Handle(string dest_call="", string sour_call="", uint8_t dest_stat=0x60, uint8_t sour_stat=0x61, uint8_t cont=0x03, uint8_t prot=0xf0);
63 
65  string get_destination_callsign();
66  void set_destination_stationID(uint8_t ID);
67  uint8_t get_destination_stationID();
68  void set_source_callsign(string source);
69  string get_source_callsign();
70  void set_source_stationID(uint8_t ID);
71  uint8_t get_source_stationID();
72  void set_control(uint8_t control_number);
73  uint8_t get_control();
74  void set_protocolID(uint8_t protocol);
75  uint8_t get_protocolID();
76  packet_header get_packetHeader();
77  vector <uint8_t> get_packetData();
78  int32_t set_packetData(vector <uint8_t> input);
79  int32_t set_raw_packet(vector <uint8_t> packet);
80  int32_t unload_packet();
81  int32_t load_packet();
82 
83 private:
84  packet_header header;
85  vector <uint8_t> data;
86  vector <uint8_t> raw_packet;
87  int32_t error;
88 
89  friend std::ostream& operator<<(std::ostream& out, Ax25Handle& K);
90 };
91 
92 //Functions to print packets
93 void print_ascii(unsigned char* packet, unsigned int count);
94 void print_hex(unsigned char* packet, unsigned int count);
95 
96 #endif
packet_header get_packetHeader()
Definition: ax25class.cpp:140
void set_destination_stationID(uint8_t ID)
Definition: ax25class.cpp:70
uint8_t get_source_stationID()
Definition: ax25class.cpp:113
void set_control(uint8_t control_number)
Definition: ax25class.cpp:118
Definition: ax25class.h:56
vector< uint8_t > data
Definition: ax25class.h:59
int count
Definition: rw_test.cpp:36
vector< uint8_t > get_packetData()
Definition: ax25class.cpp:145
packet_header header
Definition: ax25class.h:84
int32_t load_packet()
Definition: ax25class.cpp:162
void set_source_callsign(string source)
Definition: ax25class.cpp:81
static string destination
Definition: ax25_recv.cpp:43
uint8_t get_protocolID()
Definition: ax25class.cpp:135
Definition: pic_lib.h:128
packet_header header
Definition: ax25class.h:58
vector< uint8_t > data
Definition: ax25class.h:85
int32_t error
Definition: ax25class.h:87
string get_source_callsign()
Definition: ax25class.cpp:97
Definition: ax25class.h:42
friend std::ostream & operator<<(std::ostream &out, Ax25Handle &K)
Definition: ax25class.cpp:180
vector< uint8_t > raw_packet
Definition: ax25class.h:86
void set_source_stationID(uint8_t ID)
Definition: ax25class.cpp:107
Headers and definitions common to all COSMOS.
void set_destination_callsign(string destination)
Definition: ax25class.cpp:44
COSMOS Error Codes.
int32_t set_raw_packet(vector< uint8_t > packet)
Definition: ax25class.cpp:156
uint8_t get_control()
Definition: ax25class.cpp:124
int32_t unload_packet()
Definition: ax25class.cpp:172
Ax25Handle(string dest_call="", string sour_call="", uint8_t dest_stat=0x60, uint8_t sour_stat=0x61, uint8_t cont=0x03, uint8_t prot=0xf0)
Definition: ax25class.cpp:33
void print_hex(unsigned char *packet, unsigned int count)
static string source
Definition: ax25_recv.cpp:42
string get_destination_callsign()
Definition: ax25class.cpp:60
void print_ascii(unsigned char *packet, unsigned int count)
void set_protocolID(uint8_t protocol)
Definition: ax25class.cpp:129
uint8_t get_destination_stationID()
Definition: ax25class.cpp:76
int32_t set_packetData(vector< uint8_t > input)
Definition: ax25class.cpp:150