5 #include "math/crclib.h"
7 #include "support/ax25class.h"
17 uint16_t spacecraft_id:10;
18 uint8_t virtual_channel_id:3;
20 uint8_t master_frame_cnt;
21 uint8_t virtual_frame_cnt;
22 uint16_t tf_data_field_status;
27 enum class TypeId : uint16_t {
31 DataObcBeacon = 0x101,
33 DataObcResponse = 0x103,
37 CommandObcReset = 0x181,
38 CommandObcReboot = 0x182,
39 CommandObcPing = 0x183,
40 CommandObcSetTime = 0x184,
41 CommandObcGetTimeHuman = 0x185,
42 CommandObcGetTimeBinary = 0x186,
43 CommandObcExternalCommand = 0x187,
44 CommandObcExternalTask = 0x188,
45 CommandObcInternalRequest = 0x189,
46 CommandObcSendBeacon = 0x18a,
47 CommandObcHalt = 0x18b,
48 CommandObcNop = 0x1ff,
51 DataEpsResponse = 0x201,
53 CommandEpsCommunicate = 0x281,
54 CommandEpsSwitchName = 0x282,
55 CommandEpsSwitchNumber = 0x283,
56 CommandEpsReset = 0x284,
57 CommandEpsState = 0x285,
58 CommandEpsWatchdog = 0x286,
59 CommandEpsSetTime = 0x287,
60 CommandEpsMinimumPower = 0x288,
61 CommandEpsSwitchNames = 0x289,
62 CommandEpsSwitchStatus = 0x28a,
65 DataAdcsResponse = 0x301,
67 CommandAdcsCommunicate = 0x381,
68 CommandAdcsState = 0x382,
69 CommandAdcsSetRunMode = 0x383,
70 CommandAdcsGetAdcsState = 0x384,
71 CommandAdcsOrbitParameters = 0x385,
74 DataFileCommand = 0x401,
75 DataFileMessage = 0x402,
76 DataFileQueue = 0x403,
77 DataFileCancel = 0x404,
78 DataFileComplete = 0x405,
79 DataFileReqMeta = 0x406,
80 DataFileReqData = 0x407,
81 DataFileMetaData = 0x408,
82 DataFileChunkData = 0x409,
83 DataFileReqComplete = 0x40a,
85 CommandFileListDirectory = 0x481,
86 CommandFileTransferFile = 0x482,
87 CommandFileTransferNode = 0x483,
88 CommandFileTransferRadio = 0x484,
89 CommandFileTransferList = 0x485,
93 CommandExecClearQueue = 0x581,
94 CommandExecSetOpsMode = 0x582,
95 CommandExecEnableChannel = 0x583,
96 CommandExecLoadCommand = 0x584,
97 CommandExecAddCommand = 0x585,
100 DataRadioTest = 0x701,
101 DataRadioResponse = 0x702,
102 CommandRadio = 0x780,
103 CommandRadioTest = 0x781,
104 CommandRadioCommunicate = 0x782,
105 CommandRadioAstrodevCommunicate = 0x783,
108 CommandCamera = 0x880,
109 CommandCameraOn = 0x881,
110 CommandCameraCapture = 0x882,
113 std::map<TypeId, string> TypeString = {
114 {TypeId::DataObcBeacon,
"Beacon"},
115 {TypeId::DataObcNop,
"Nop"},
116 {TypeId::DataObcPong,
"Pong"},
117 {TypeId::DataEpsResponse,
"EpsResponse"},
118 {TypeId::DataRadioResponse,
"RadioResponse"},
119 {TypeId::DataAdcsResponse,
"AdcsResponse"},
120 {TypeId::DataObcResponse,
"Response"},
121 {TypeId::DataRadioTest,
"Test"},
122 {TypeId::DataObcTime,
"Time"},
123 {TypeId::DataFileCommand,
"FileCommand"},
124 {TypeId::DataFileMessage,
"FileMessage"},
125 {TypeId::DataFileQueue,
"FileQueue"},
126 {TypeId::DataFileCancel,
"FileCancel"},
127 {TypeId::DataFileComplete,
"FileComplete"},
128 {TypeId::DataFileReqMeta,
"FileReqMeta"},
129 {TypeId::DataFileReqData,
"FileReqData"},
130 {TypeId::DataFileMetaData,
"FileMetaData"},
131 {TypeId::DataFileChunkData,
"FileChunkData"},
132 {TypeId::DataFileReqComplete,
"FileReqComplete"},
133 {TypeId::CommandObcReset,
"Reset"},
134 {TypeId::CommandObcReboot,
"Reboot"},
135 {TypeId::CommandObcSendBeacon,
"SendBeacon"},
136 {TypeId::CommandExecClearQueue,
"ClearQueue"},
137 {TypeId::CommandObcExternalCommand,
"ExternalCommand"},
138 {TypeId::CommandObcExternalTask,
"ExternalTask"},
139 {TypeId::CommandObcHalt,
"Halt"},
140 {TypeId::CommandRadioTest,
"TestRadio"},
141 {TypeId::CommandFileListDirectory,
"ListDirectory"},
142 {TypeId::CommandFileTransferFile,
"TransferFile"},
143 {TypeId::CommandFileTransferNode,
"TransferNode"},
144 {TypeId::CommandFileTransferRadio,
"TransferRadio"},
145 {TypeId::CommandFileTransferList,
"TransferList"},
146 {TypeId::CommandObcInternalRequest,
"InternalRequest"},
147 {TypeId::CommandObcPing,
"Ping"},
148 {TypeId::CommandObcSetTime,
"SetTime"},
149 {TypeId::CommandObcGetTimeHuman,
"GetTimeHuman"},
150 {TypeId::CommandObcGetTimeBinary,
"GetTimeBinary"},
151 {TypeId::CommandExecSetOpsMode,
"SetOpsMode"},
152 {TypeId::CommandExecEnableChannel,
"EnableChannel"},
153 {TypeId::CommandAdcsCommunicate,
"AdcsCommunicate"},
154 {TypeId::CommandAdcsState,
"AdcsState"},
155 {TypeId::CommandAdcsSetRunMode,
"AdcsSetRunMode"},
156 {TypeId::CommandAdcsGetAdcsState,
"AdcsGetAdcsState"},
157 {TypeId::CommandAdcsOrbitParameters,
"AdcsOrbitParameters"},
158 {TypeId::CommandEpsCommunicate,
"EpsCommunicate"},
159 {TypeId::CommandEpsSwitchName,
"EpsSwitchName"},
160 {TypeId::CommandEpsSwitchNumber,
"EpsSwitchNumber"},
161 {TypeId::CommandEpsReset,
"EpsReset"},
162 {TypeId::CommandEpsState,
"EpsState"},
163 {TypeId::CommandEpsWatchdog,
"EpsWatchdog"},
164 {TypeId::CommandEpsSetTime,
"EpsSetTime"},
165 {TypeId::CommandEpsMinimumPower,
"EpsMinimumPower"},
166 {TypeId::CommandEpsSwitchNames,
"EpsSwitchNames"},
167 {TypeId::CommandEpsSwitchStatus,
"EpsSwitchStatus"},
168 {TypeId::CommandExecLoadCommand,
"ExecLoadCommand"},
169 {TypeId::CommandExecAddCommand,
"ExecAddCommand"},
170 {TypeId::CommandRadioCommunicate,
"RadioCommunicate"},
171 {TypeId::CommandRadioAstrodevCommunicate,
"RadioAstrodevCommunicate"},
172 {TypeId::CommandCameraOn,
"CameraOn"},
173 {TypeId::CommandCameraCapture,
"CameraCapture"},
176 std::map<string, TypeId> StringType = {
177 {
"Beacon", TypeId::DataObcBeacon},
178 {
"Nop", TypeId::DataObcNop},
179 {
"Pong", TypeId::DataObcPong},
180 {
"EpsResponse", TypeId::DataEpsResponse},
181 {
"RadioResponse", TypeId::DataRadioResponse},
182 {
"AdcsResponse", TypeId::DataAdcsResponse},
183 {
"Response", TypeId::DataObcResponse},
184 {
"Test", TypeId::DataRadioTest},
185 {
"Time", TypeId::DataObcTime},
187 {
"FileCommand", TypeId::DataFileCommand},
188 {
"FileMessage", TypeId::DataFileMessage},
189 {
"FileQueue", TypeId::DataFileQueue},
190 {
"FileCancel", TypeId::DataFileCancel},
191 {
"FileComplete", TypeId::DataFileComplete},
192 {
"FileReqMeta", TypeId::DataFileReqMeta},
193 {
"FileReqData", TypeId::DataFileReqData},
194 {
"FileMetaData", TypeId::DataFileMetaData},
195 {
"FileChunkData", TypeId::DataFileChunkData},
196 {
"FileReqComplete", TypeId::DataFileReqComplete},
198 {
"Reset", TypeId::CommandObcReset},
199 {
"Reboot", TypeId::CommandObcReboot},
200 {
"SendBeacon", TypeId::CommandObcSendBeacon},
201 {
"ClearQueue", TypeId::CommandExecClearQueue},
202 {
"ExternalCommand", TypeId::CommandObcExternalCommand},
203 {
"ExternalTask", TypeId::CommandObcExternalTask},
204 {
"Halt", TypeId::CommandObcHalt},
205 {
"TestRadio", TypeId::CommandRadioTest},
206 {
"ListDirectory", TypeId::CommandFileListDirectory},
207 {
"TransferFile", TypeId::CommandFileTransferFile},
208 {
"TransferNode", TypeId::CommandFileTransferNode},
209 {
"TransferRadio", TypeId::CommandFileTransferRadio},
210 {
"TransferList", TypeId::CommandFileTransferList},
211 {
"InternalRequest", TypeId::CommandObcInternalRequest},
212 {
"Ping", TypeId::CommandObcPing},
213 {
"SetTime", TypeId::CommandObcSetTime},
214 {
"GetTimeHuman", TypeId::CommandObcGetTimeHuman},
215 {
"GetTimeBinary", TypeId::CommandObcGetTimeBinary},
216 {
"SetOpsMode", TypeId::CommandExecSetOpsMode},
217 {
"EnableChannel", TypeId::CommandExecEnableChannel},
218 {
"EpsCommunicate", TypeId::CommandEpsCommunicate},
219 {
"EpsSwitchName", TypeId::CommandEpsSwitchName},
220 {
"EpsSwitchNumber", TypeId::CommandEpsSwitchNumber},
221 {
"EpsReset", TypeId::CommandEpsReset},
222 {
"EpsState", TypeId::CommandEpsState},
223 {
"EpsWatchdog", TypeId::CommandEpsWatchdog},
224 {
"EpsSetTime", TypeId::CommandEpsSetTime},
225 {
"EpsMinimumPower", TypeId::CommandEpsMinimumPower},
226 {
"EpsSwitchNames", TypeId::CommandEpsSwitchNames},
227 {
"EpsSwitchStatus", TypeId::CommandEpsSwitchStatus},
228 {
"AdcsCommunicate", TypeId::CommandAdcsCommunicate},
229 {
"AdcsState", TypeId::CommandAdcsState},
230 {
"AdcsSetRunMode", TypeId::CommandAdcsSetRunMode},
231 {
"AdcsGetAdcsState", TypeId::CommandAdcsGetAdcsState},
232 {
"AdcsOrbitParameters", TypeId::CommandAdcsOrbitParameters},
233 {
"ExecLoadCommand", TypeId::CommandExecLoadCommand},
234 {
"ExecAddCommand", TypeId::CommandExecAddCommand},
235 {
"RadioCommunicate", TypeId::CommandRadioCommunicate},
236 {
"RadioAstrodevCommunicate", TypeId::CommandRadioAstrodevCommunicate},
237 {
"CameraOn", TypeId::CommandCameraOn},
238 {
"CameraCapture", TypeId::CommandCameraCapture},
245 uint16_t responsecount;
265 uint32_t response_id;
273 uint32_t test_id = 0;
275 uint32_t packet_id = 0;
280 TypeId type = TypeId::Blank;
282 uint8_t nodeorig = 254;
283 uint8_t nodedest = 255;
289 vector<uint8_t> packetized;
290 vector<uint8_t> wrapped;
294 enum class PacketStyle : uint8_t
302 PacketStyle style = PacketStyle::V2;
310 vector<uint8_t> atsm = {0x1a, 0xcf, 0xfc, 0x1d};
311 vector<uint8_t> atsmr = {0x58, 0xf3, 0x3f, 0xb8};
312 vector<uint8_t> satsm = {0x35, 0x2e, 0xf8, 0x53};
315 void Invert(vector<uint8_t>&
data);
318 int32_t Unwrap(
bool checkcrc=
true);
319 int32_t Unwrap(
bool checkcrc,
bool minimal_header);
320 int32_t RawUnPacketize(
bool invert=
false,
bool checkcrc=
true);
321 int32_t RawUnPacketize(
bool invert,
bool checkcrc,
bool minimal_header);
322 bool ASMUnPacketize();
323 bool ASMUnPacketize(
bool checkcrc,
bool descramble);
324 bool SLIPUnPacketize(
bool checkcrc=
true);
325 bool HDLCUnPacketize(
bool checkcrc=
true);
326 bool AX25UnPacketize(
bool checkcrc=
true);
328 bool Wrap(
bool calc_checksum);
332 bool ASMPacketize(uint16_t packet_wrapped_size,
bool scramble);
333 bool AX25Packetize(
string dest_call=
"",
string sour_call=
"", uint8_t flagcount=2, uint8_t dest_stat=0x60, uint8_t sour_stat=0x61, uint8_t cont=0x03, uint8_t prot=0xf0);
334 bool HDLCPacketize(uint8_t flagcount=10);
335 bool SLIPPacketize();
Definition: packetcomm.h:13
bool Wrap()
Wrap up header and payload Merge Cosmos::Support::PacketComm::data and ::Cosmos::Support::PacketComm:...
Definition: packetcomm.cpp:233
vector< uint8_t > data
Data of interest.
Definition: packetcomm.h:292
Headers and definitions common to all COSMOS Kernel.
COSMOS SLIP support include file.
Definition: packetcomm.h:305