COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Ax25Handle Class Reference

#include <ax25class.h>

Collaboration diagram for Ax25Handle:

Classes

struct  packet_content
 

Public Member Functions

struct __attribute__ ((packed)) packet_header
 
 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)
 
void set_destination_callsign (string destination)
 
string get_destination_callsign ()
 
void set_destination_stationID (uint8_t ID)
 
uint8_t get_destination_stationID ()
 
void set_source_callsign (string source)
 
string get_source_callsign ()
 
void set_source_stationID (uint8_t ID)
 
uint8_t get_source_stationID ()
 
void set_control (uint8_t control_number)
 
uint8_t get_control ()
 
void set_protocolID (uint8_t protocol)
 
uint8_t get_protocolID ()
 
packet_header get_packetHeader ()
 
vector< uint8_t > get_packetData ()
 
int32_t set_packetData (vector< uint8_t > input)
 
int32_t set_raw_packet (vector< uint8_t > packet)
 
int32_t unload_packet ()
 
int32_t load_packet ()
 

Private Attributes

packet_header header
 
vector< uint8_t > data
 
vector< uint8_t > raw_packet
 
int32_t error
 

Friends

std::ostream & operator<< (std::ostream &out, Ax25Handle &K)
 

Constructor & Destructor Documentation

Ax25Handle::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 
)
34 {
35  set_destination_callsign(dest_call);
36  set_destination_stationID(dest_stat);
37  set_source_callsign(sour_call);
38  set_source_stationID(sour_stat);
39  set_control(cont);
40  set_protocolID(prot);
41 }
void set_destination_stationID(uint8_t ID)
Definition: ax25class.cpp:70
void set_control(uint8_t control_number)
Definition: ax25class.cpp:118
void set_source_callsign(string source)
Definition: ax25class.cpp:81
void set_source_stationID(uint8_t ID)
Definition: ax25class.cpp:107
void set_destination_callsign(string destination)
Definition: ax25class.cpp:44
void set_protocolID(uint8_t protocol)
Definition: ax25class.cpp:129

Member Function Documentation

struct Ax25Handle::__attribute__ ( (packed)  )
inline
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  };
void Ax25Handle::set_destination_callsign ( string  destination)
45 {
46  for (uint16_t i=0; i<6; ++i)
47  {
48  if (i >= destination.length())
49  {
50  header.destination_callsign[i] = 0x20 << 1;
51  }
52  else
53  {
54  header.destination_callsign[i] = destination[i] << 1;
55  }
56  }
57  return;
58 }
int i
Definition: rw_test.cpp:37
packet_header header
Definition: ax25class.h:84
static string destination
Definition: ax25_recv.cpp:43
string Ax25Handle::get_destination_callsign ( )
61 {
62  string callsign;
63  for (uint8_t byte : header.destination_callsign)
64  {
65  callsign.push_back(byte >> 1);
66  }
67  return callsign;
68 }
packet_header header
Definition: ax25class.h:84
void Ax25Handle::set_destination_stationID ( uint8_t  ID)
71 {
72  header.destination_stationID = ID;
73  return;
74 }
packet_header header
Definition: ax25class.h:84
uint8_t Ax25Handle::get_destination_stationID ( )
77 {
78  return header.destination_stationID;
79 }
packet_header header
Definition: ax25class.h:84
void Ax25Handle::set_source_callsign ( string  source)
82 {
83  for (uint16_t i=0; i<6; ++i)
84  {
85  if (i >= source.length())
86  {
87  header.source_callsign[i] = 0x20 << 1;
88  }
89  else
90  {
91  header.source_callsign[i] = source[i] << 1;
92  }
93  }
94  return;
95 }
int i
Definition: rw_test.cpp:37
packet_header header
Definition: ax25class.h:84
static string source
Definition: ax25_recv.cpp:42
std::string Ax25Handle::get_source_callsign ( )
98 {
99  string callsign;
100  for (uint8_t byte : header.source_callsign)
101  {
102  callsign.push_back(byte >> 1);
103  }
104  return callsign;
105 }
packet_header header
Definition: ax25class.h:84
void Ax25Handle::set_source_stationID ( uint8_t  ID)
108 {
109  header.source_stationID = ID;
110  return;
111 }
packet_header header
Definition: ax25class.h:84
uint8_t Ax25Handle::get_source_stationID ( )
114 {
115  return header.source_stationID;
116 }
packet_header header
Definition: ax25class.h:84
void Ax25Handle::set_control ( uint8_t  control_number)
119 {
120  header.control = control_number;
121  return;
122 }
packet_header header
Definition: ax25class.h:84
uint8_t Ax25Handle::get_control ( )
125 {
126  return header.control;
127 }
packet_header header
Definition: ax25class.h:84
void Ax25Handle::set_protocolID ( uint8_t  protocol)
130 {
131  header.protocolID = protocol;
132  return;
133 }
packet_header header
Definition: ax25class.h:84
uint8_t Ax25Handle::get_protocolID ( )
136 {
137  return header.protocolID;
138 }
packet_header header
Definition: ax25class.h:84
Ax25Handle::packet_header Ax25Handle::get_packetHeader ( )
141 {
142  return header;
143 }
packet_header header
Definition: ax25class.h:84
vector< uint8_t > Ax25Handle::get_packetData ( )
146 {
147  return data;
148 }
vector< uint8_t > data
Definition: ax25class.h:85
int32_t Ax25Handle::set_packetData ( vector< uint8_t >  input)
151 {
152  data = input;
153  return 0;
154 }
vector< uint8_t > data
Definition: ax25class.h:85
int32_t Ax25Handle::set_raw_packet ( vector< uint8_t >  packet)
157 {
158  raw_packet = packet;
159  return 0;
160 }
vector< uint8_t > raw_packet
Definition: ax25class.h:86
int32_t Ax25Handle::unload_packet ( )
173 {
174  memcpy(&header, &raw_packet[0], 16);
175  data.resize(raw_packet.size() - 16);
176  memcpy(&data[0], &raw_packet[16], data.size());
177  return 0;
178 }
packet_header header
Definition: ax25class.h:84
vector< uint8_t > data
Definition: ax25class.h:85
vector< uint8_t > raw_packet
Definition: ax25class.h:86
int32_t Ax25Handle::load_packet ( )
163 {
164  int32_t tsize = 16 + data.size();
165  raw_packet.resize(tsize);
166  memcpy(&raw_packet[0], &header, 16);
167  memcpy(&raw_packet[16], &data[0], data.size());
168 
169  return tsize;
170 }
packet_header header
Definition: ax25class.h:84
vector< uint8_t > data
Definition: ax25class.h:85
vector< uint8_t > raw_packet
Definition: ax25class.h:86

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
Ax25Handle K 
)
friend
180  {
181  out<<"destination callsign=<"<< K.header.destination_callsign<<">"<<std::endl;
182  out<<"destination station ID="<< K.header.destination_stationID<<std::endl;
183  out<<"source callsign=<"<< K.header.source_callsign<<">"<<std::endl;
184  out<<"source station ID="<< K.header.source_stationID<<std::endl;
185  out<<"control="<< K.header.control<<std::endl;
186  out<<"protocol ID="<< K.header.protocolID<<std::endl;
187 
188  return out;
189 }
packet_header header
Definition: ax25class.h:84

Member Data Documentation

packet_header Ax25Handle::header
private
vector<uint8_t> Ax25Handle::data
private
vector<uint8_t> Ax25Handle::raw_packet
private
int32_t Ax25Handle::error
private

The documentation for this class was generated from the following files: