CCSDS
tmtc_control.h
Go to the documentation of this file.
1
12#ifndef _TMTC_CONTROL_H_
13#define _TMTC_CONTROL_H_
14
15
16#include "configCCSDS.h"
17
18
19#include "ccsds_cltu.h"
22#include "ccsds_clcw.h"
23#include "ccsds_spacepacket.h"
24
25
26
27#ifdef configTMTC_MAX_TC_CHANNELS
28#define TMTC_MAX_TC_CHANNELS configTMTC_MAX_TC_CHANNELS
29#else
30#define TMTC_MAX_TC_CHANNELS 1
31#endif
32
33#ifdef configTMTC_MAX_TM_CHANNELS
34#define TMTC_MAX_TM_CHANNELS configTMTC_MAX_TM_CHANNELS
35#else
36#define TMTC_MAX_TM_CHANNELS 8
37#endif
38
39#ifdef configUSE_CLTU_SUPPORT
40#define USE_CLTU_SUPPORT configUSE_CLTU_SUPPORT
41#else
42#define USE_CLTU_SUPPORT 0
43#endif
44
45#ifdef configTMTC_MAX_SCIDS
46#define TMTC_MAX_SCIDS configTMTC_MAX_SCIDS
47#else
48#define TMTC_MAX_SCIDS 2
49#endif
50
51#ifdef configFARM_SLIDING_WINDOW_WIDTH
52#define FARM_SLIDING_WINDOW_WIDTH configFARM_SLIDING_WINDOW_WIDTH
53#else
54#define FARM_SLIDING_WINDOW_WIDTH 16
55#endif
56
57
58
59using namespace CCSDS;
60
61
63{
64 // Callback for TC for sending to reveicer
65 typedef void (TTfTcCallback)(void *p_Context, const uint8_t *pu8_Data, const uint16_t u16_DataSize);
66 typedef void (TTfTmOcfCallback)(const uint8_t u8_VirtualChannelID, void *p_Context, const uint32_t u32_Ocf);
67
68public:
69 static const uint8_t MaxTcChannels = TMTC_MAX_TC_CHANNELS;
70 static const uint8_t MaxTmChannels = TMTC_MAX_TM_CHANNELS;
71
72
73private:
74 uint8_t mu8_NumberOfSCIDs;
75 uint16_t mau16_SCIDs[TMTC_MAX_SCIDS];
76
77 TransferframeTm m_TfTm;
78 SpacePacket ma_Sp[MaxTmChannels];
79
80 uint8_t mau8_TcSpBuffer[SP_MAX_DATA_SIZE];
81 uint8_t mau8_TfTcBuffer[TC_TF_MAX_SIZE];
82 uint8_t mau8_FrameSeqNumber[MaxTcChannels]; // AD mode: N(s) - the TC FrameNumber + 1
83
84
85#if USE_CLTU_SUPPORT == 1
86 uint8_t mau8_CltuBuffer[CLTU_MAX_SIZE];
87#endif
88
89 struct
90 {
91 void *p_TfTmOcfContext;
92 TTfTmOcfCallback *p_TfTmOcfCallback;
93 } ma_TmCOP[MaxTmChannels];
94
95 struct
96 {
97 bool b_NoRfAvail;
98 bool b_NoBitLock;
99 bool b_LockOut;
100 bool b_Wait;
101 bool b_Retransmit;
102 uint8_t u8_FarmBCounter; // BD mode counter
103 uint8_t u8_NextFrameSeqNumber; // AD mode: N(s) - the TC FrameNumber + 1
104 } ma_COP[MaxTcChannels];
105
106 uint8_t mu8_TmMCFC;
107 uint8_t mau8_TmVCFC[MaxTmChannels];
108
109 // Callback for TC for sending to satellite
110 void *mp_TfTcContext;
111 TTfTcCallback *mp_TfTcCallback;
112
113
114
115 uint16_t mu16_ScIdErrorCount;
116 uint16_t mu16_VCFCErrorCount;
117 uint16_t mu16_MCFCErrorCount;
118
119
120
121public:
122 TmTcControl(const uint16_t *pu16_SCIDs = NULL, const uint8_t u8_NumberOfSCIDs = 0,
123 void *p_TfTcContext = NULL, TTfTcCallback *p_TfTcCallback = NULL,
124 void *p_VC0SpContext = NULL, SpacePacket::TSpCallback *p_VC0SpCallback = NULL);
125
126 int32_t setSCIDs(const uint16_t *pu16_SCIDs, const uint8_t u8_NumberOfSCIDs);
127
128 int32_t setTcCallback(void *p_TfTcContext, TTfTcCallback *p_TfTcCallback);
129
130 int32_t setTmOcfCallback(const uint8_t u8_VirtualChannelID, void *p_TfTmContext, TTfTmOcfCallback *p_TfTmOcfCallback);
131
132 int32_t setTmCallback(const uint8_t u8_VirtualChannelID,
133 void *p_SpContext, SpacePacket::TSpCallback *p_SpCallback);
134
135 uint16_t getTmScIdErrorCount(void);
136 uint16_t getTmMCFCErrorCount(void);
137 uint16_t getTmVCFCErrorCount(void);
138 uint16_t getTmSyncErrorCount(void);
139 uint16_t getTmChecksumErrorCount(void);
140 uint16_t getTmOverflowErrorCount(void);
141 void clearErrorCounters(void);
142
143
144 // Telemetry
145
146public:
147 void processTfTm(const uint8_t *pu8_Data, const uint16_t u16_DataSize);
148
149 static void TfTmCallback(void *p_Context, const uint16_t u16_SpacecraftID, const uint8_t u8_VirtualChannelID,
150 const uint8_t u8_MasterChannelFrameCount, const uint8_t u8_VirtualChannelFrameCount,
151 const bool b_TFSecHdrFlag, const uint16_t u16_FirstHdrPtr,
152 const uint8_t *pu8_Data, const uint16_t u16_DataSize,
153 const uint32_t u32_OCF);
154
155private:
156 void _TfTmCallback(const uint16_t u16_SpacecraftID, const uint8_t u8_VirtualChannelID,
157 const uint8_t u8_MasterChannelFrameCount, const uint8_t u8_VirtualChannelFrameCount,
158 const bool b_TFSecHdrFlag, const uint16_t u16_FirstHdrPtr,
159 const uint8_t *pu8_Data, const uint16_t u16_DataSize,
160 const uint32_t u32_OCF);
161
162
163
164 // Telecommand
165
166public:
167 int32_t sendTc(const uint8_t u8_VirtualChannelID, const bool b_BypassFlag, const uint16_t u16_APID, const uint16_t u16_ApidSeqNr,
168 const uint8_t *pu8_Data, const uint16_t u16_DataSize);
169
170 int32_t sendInitAD(const uint8_t u8_VirtualChannelID);
171
172private:
173 void _TfTmCallback(const bool b_BypassFlag, const bool b_CtrlCmdFlag,
174 const uint16_t u16_SpacecraftID, const uint8_t u8_VirtualChannelID,
175 const uint8_t u8_FrameSeqNumber,
176 const uint8_t *pu8_Data, const uint16_t u16_DataSize);
177
178 void _createAndSendTf(const uint8_t u8_VirtualChannelID, const bool b_BypassFlag, const bool b_CtrlCmFlag, const uint8_t *pu8_Data, const uint16_t u16_DataSize);
179
180};
181
182
183
184
185
186#endif /* _TMTC_CONTROL_H_ */
187
Include file of the Communications Link Control Word (CLCW) class.
Include file of the Communications Link Transmission Unit (CLTU) class.
Include file of the Space Packet (SP) class.
Include file of the Transfer Frame (TC) class.
Include file of the Transfer Frame (TM) class.
Class for handling the Space Packets as described in CCSDS 133.0-B-2.
Definition: ccsds_spacepacket.h:59
Class for handling the Transfer Frames for Telemetry as described in CCSDS 132.0-B-2.
Definition: ccsds_transferframe_tm.h:83
Definition: tmtc_control.h:63