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

#include <kisslib.h>

Collaboration diagram for KissHandle:

Classes

struct  packet_content
 

Public Member Functions

 KissHandle (string dest_call="", string sour_call="", uint8_t port=0, uint8_t comm=0, uint8_t dest_stat=0x60, uint8_t sour_stat=0x61, uint8_t cont=0x03, uint8_t prot=0xf0)
 
void set_port_number (uint8_t P)
 
uint8_t get_port_number ()
 
void set_command (uint8_t C)
 
uint8_t get_command ()
 
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 ()
 
int32_t set_data (vector< uint8_t > input)
 
vector< uint8_t > get_data ()
 
int32_t load_packet ()
 
int32_t unload_packet ()
 
int32_t set_raw_packet (vector< uint8_t > packet)
 
int32_t set_slip_packet (vector< uint8_t > packet)
 
vector< uint8_t > get_raw_packet ()
 
vector< uint8_t > get_slip_packet ()
 
int32_t get_error ()
 
struct __attribute__ ((packed)) packet_header
 

Private Attributes

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

Friends

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

Constructor & Destructor Documentation

KissHandle::KissHandle ( string  dest_call = "",
string  sour_call = "",
uint8_t  port = 0,
uint8_t  comm = 0,
uint8_t  dest_stat = 0x60,
uint8_t  sour_stat = 0x61,
uint8_t  cont = 0x03,
uint8_t  prot = 0xf0 
)
34 {
36  set_command(comm);
37  set_destination_callsign(dest_call);
38  set_destination_stationID(dest_stat);
39  set_source_callsign(sour_call);
40  set_source_stationID(sour_stat);
41  set_control(cont);
42  set_protocolID(prot);
43 }
static string port
Definition: add_radio.cpp:16
void set_command(uint8_t C)
Definition: kisslib.cpp:57
void set_source_callsign(string source)
Definition: kisslib.cpp:106
void set_source_stationID(uint8_t ID)
Definition: kisslib.cpp:132
void set_port_number(uint8_t P)
Definition: kisslib.cpp:46
void set_protocolID(uint8_t protocol)
Definition: kisslib.cpp:154
void set_destination_callsign(string destination)
Definition: kisslib.cpp:69
void set_control(uint8_t control_number)
Definition: kisslib.cpp:143
void set_destination_stationID(uint8_t ID)
Definition: kisslib.cpp:95

Member Function Documentation

void KissHandle::set_port_number ( uint8_t  P)
47 {
48  header.port_number = P;
49  return;
50 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_port_number ( )
53 {
54  return header.port_number;
55 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_command ( uint8_t  C)
58 {
59  header.command = C;
60  return;
61 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_command ( )
64 {
65  return header.command;
66 
67 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_destination_callsign ( string  destination)
70 {
71  for (uint16_t i=0; i<6; ++i)
72  {
73  if (i >= destination.length())
74  {
75  header.destination_callsign[i] = 0x20 << 1;
76  }
77  else
78  {
79  header.destination_callsign[i] = destination[i] << 1;
80  }
81  }
82  return;
83 }
int i
Definition: rw_test.cpp:37
static string destination
Definition: ax25_recv.cpp:43
packet_header header
Definition: kisslib.h:99
string KissHandle::get_destination_callsign ( )
86 {
87  string callsign;
88  for (uint8_t byte : header.destination_callsign)
89  {
90  callsign.push_back(byte >> 1);
91  }
92  return callsign;
93 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_destination_stationID ( uint8_t  ID)
96 {
97  header.destination_stationID = ID;
98  return;
99 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_destination_stationID ( )
102 {
103  return header.destination_stationID;
104 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_source_callsign ( string  source)
107 {
108  for (uint16_t i=0; i<6; ++i)
109  {
110  if (i >= source.length())
111  {
112  header.source_callsign[i] = 0x20 << 1;
113  }
114  else
115  {
116  header.source_callsign[i] = source[i] << 1;
117  }
118  }
119  return;
120 }
int i
Definition: rw_test.cpp:37
packet_header header
Definition: kisslib.h:99
static string source
Definition: ax25_recv.cpp:42
std::string KissHandle::get_source_callsign ( )
123 {
124  string callsign;
125  for (uint8_t byte : header.source_callsign)
126  {
127  callsign.push_back(byte >> 1);
128  }
129  return callsign;
130 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_source_stationID ( uint8_t  ID)
133 {
134  header.source_stationID = ID;
135  return;
136 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_source_stationID ( )
139 {
140  return header.source_stationID;
141 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_control ( uint8_t  control_number)
144 {
145  header.control = control_number;
146  return;
147 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_control ( )
150 {
151  return header.control;
152 }
packet_header header
Definition: kisslib.h:99
void KissHandle::set_protocolID ( uint8_t  protocol)
155 {
156  header.protocolID = protocol;
157  return;
158 }
packet_header header
Definition: kisslib.h:99
uint8_t KissHandle::get_protocolID ( )
161 {
162  return header.protocolID;
163 }
packet_header header
Definition: kisslib.h:99
int32_t KissHandle::set_data ( vector< uint8_t >  input)
259 {
260  data = input;
261  return 0;
262 }
vector< uint8_t > data
Definition: kisslib.h:100
vector< uint8_t > KissHandle::get_data ( )
277 {
278  return data;
279 }
vector< uint8_t > data
Definition: kisslib.h:100
int32_t KissHandle::load_packet ( )
282 {
283  int32_t tsize = 17 + data.size();
284  raw_packet.resize(tsize);
285  memcpy(&raw_packet[0], &header, 17);
286  memcpy(&raw_packet[17], &data[0], data.size());
288 
289  return tsize;
290 }
int32_t slip_encode(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize)
Encode data in to SLIP packet.
Definition: sliplib.cpp:212
packet_header header
Definition: kisslib.h:99
vector< uint8_t > data
Definition: kisslib.h:100
vector< uint8_t > raw_packet
Definition: kisslib.h:101
vector< uint8_t > slip_packet
Definition: kisslib.h:102
int32_t KissHandle::unload_packet ( )
293 {
295  memcpy(&header, &raw_packet[0], 17);
296  data.resize(raw_packet.size() - 17);
297  memcpy(&data[0], &raw_packet[17], data.size());
298  return 0;
299 }
packet_header header
Definition: kisslib.h:99
int32_t slip_decode(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
Decode SLIP packet.
Definition: sliplib.cpp:109
vector< uint8_t > data
Definition: kisslib.h:100
vector< uint8_t > raw_packet
Definition: kisslib.h:101
vector< uint8_t > slip_packet
Definition: kisslib.h:102
int32_t KissHandle::set_raw_packet ( vector< uint8_t >  packet)
265 {
266  raw_packet = packet;
267  return 0;
268 }
vector< uint8_t > raw_packet
Definition: kisslib.h:101
int32_t KissHandle::set_slip_packet ( vector< uint8_t >  packet)
271 {
272  slip_packet = packet;
273  return 0;
274 }
vector< uint8_t > slip_packet
Definition: kisslib.h:102
vector< uint8_t > KissHandle::get_raw_packet ( )
307 {
308  return raw_packet;
309 }
vector< uint8_t > raw_packet
Definition: kisslib.h:101
vector< uint8_t > KissHandle::get_slip_packet ( )
312 {
313  return slip_packet;
314 }
vector< uint8_t > slip_packet
Definition: kisslib.h:102
int32_t KissHandle::get_error ( )
302 {
303  return error;
304 }
int32_t error
Definition: kisslib.h:103
struct KissHandle::__attribute__ ( (packed)  )
inline
81  {
82  unsigned command : 4;
83  unsigned port_number : 4;
84  uint8_t destination_callsign[6];
85  uint8_t destination_stationID;
86  uint8_t source_callsign[6];
87  uint8_t source_stationID;
88  uint8_t control = 0x03;
89  uint8_t protocolID = 0xf0;
90  };
string command
Definition: add_radio.cpp:27

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
KissHandle K 
)
friend
165  {
166  out<<"port_number= "<< K.header.port_number<<std::endl;
167  out<<"command="<< K.header.command<<std::endl;
168  out<<"destination callsign=<"<< K.header.destination_callsign<<">"<<std::endl;
169  out<<"destination station ID="<< K.header.destination_stationID<<std::endl;
170  out<<"source callsign=<"<< K.header.source_callsign<<">"<<std::endl;
171  out<<"source station ID="<< K.header.source_stationID<<std::endl;
172  out<<"control="<< K.header.control<<std::endl;
173  out<<"protocol ID="<< K.header.protocolID<<std::endl;
174 
175  return out;
176 }
packet_header header
Definition: kisslib.h:99

Member Data Documentation

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

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