CCSDS
tmtc_client.h
Go to the documentation of this file.
1
12#ifndef _TMTC_CLIENT_H_
13#define _TMTC_CLIENT_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
74{
75 // Callback for TM for sending to receiver
76 typedef void (TTfTmCallback)(void *p_Context, const uint8_t *pu8_Data, const uint16_t u16_DataSize);
77
78public:
79 static const uint8_t MaxTcChannels = TMTC_MAX_TC_CHANNELS;
80 static const uint8_t MaxTmChannels = TMTC_MAX_TM_CHANNELS;
81
82
83private:
84 uint8_t mu8_NumberOfSCIDs;
85 uint16_t mau16_SCIDs[TMTC_MAX_SCIDS];
86
87#if USE_CLTU_SUPPORT == 1
88 Cltu m_Cltu;
89#endif
90 TransferframeTc m_TfTc;
91 SpacePacket ma_Sp[MaxTcChannels];
92
93 uint8_t mau8_TfTmBuffer[TM_TF_TOTAL_SIZE];
94 uint8_t mau8_TmSpBuffer[SP_MAX_DATA_SIZE];
95
96 struct
97 {
98 bool b_NoRfAvail;
99 bool b_NoBitLock;
100 bool b_LockOut;
101 bool b_Wait;
102 bool b_Retransmit;
103 uint8_t u8_FarmBCounter; // BD mode counter
104 uint8_t u8_NextFrameSeqNumber; // AD mode: N(s) - the TC FrameNumber + 1
105 } ma_COP[MaxTcChannels];
106
107 uint8_t mu8_TmMCFC;
108 uint8_t mau8_TmVCFC[MaxTmChannels];
109 uint16_t mu16_IdleSpSequenceCount;
110
111 // Callback for TM for sending to reveicer
112 void *mp_TfTmContext;
113 TTfTmCallback *mp_TfTmCallback;
114
115 uint16_t mu16_ScIdErrorCount;
116 uint16_t mu16_VirtualChannelErrorCount;
117 uint16_t mu16_RetransmitErrorCount;
118 uint16_t mu16_LockoutErrorCount;
119
120
121
122public:
123 TmTcClient(const uint16_t *pu16_SCIDs, const uint8_t u8_NumberOfSCIDs,
124 void *p_TfTmContext = NULL, TTfTmCallback *p_TfTmCallback = NULL,
125 void *p_VC0SpContext = NULL, SpacePacket::TSpCallback *p_VC0SpCallback = NULL);
126
127 int32_t setTmCallback(void *p_TfTmContext, TTfTmCallback *p_TfTmCallback);
128
129 int32_t setTcCallback(const uint8_t u8_VirtualChannelID,
130 void *p_SpContext, SpacePacket::TSpCallback *p_SpCallback);
131
132 uint16_t getScIdErrorCount(void);
133 uint16_t getVirtualChannelErrorCount(void);
134 uint16_t getRetransmitErrorCount(void);
135 uint16_t getLockoutErrorCount(void);
136 void clearErrorCounters(void);
137
138
139 // Telecommand
140
141public:
142 void setSync(void);
143 void processTfTc(const uint8_t *pu8_Data, const uint16_t u16_DataSize);
144
145 static void TfTcCallback(void *p_Context,
146 const bool b_BypassFlag, const bool b_CtrlCmdFlag,
147 const uint16_t u16_SpacecraftID, const uint8_t u8_VirtualChannelID,
148 const uint8_t u8_FrameSeqNumber,
149 const uint8_t *pu8_Data, const uint16_t u16_DataSize);
150
151#if USE_CLTU_SUPPORT == 1
152 void processCltu(const uint8_t *pu8_Data, const uint16_t u16_DataSize);
153
154 static void StartOfTransmissionCallback(void *p_Context);
155
156 static void CltuCallback(void *p_Context, const uint8_t *pu8_Data, const uint16_t u16_DataSize);
157#endif
158
159private:
160 void _ctrlCmdUnlock(const uint8_t u8_VirtualChannelID);
161 void _ctrlCmdSetV(const uint8_t u8_VirtualChannelID, const uint8_t u8_R);
162
163 void _TfTcCallback(const bool b_BypassFlag, const bool b_CtrlCmdFlag,
164 const uint16_t u16_SpacecraftID, const uint8_t u8_VirtualChannelID,
165 const uint8_t u8_FrameSeqNumber,
166 const uint8_t *pu8_Data, const uint16_t u16_DataSize);
167
168#if USE_CLTU_SUPPORT == 1
169 void _StartOfTransmissionCallback(void);
170 void _CltuCallback(const uint8_t *pu8_Data, const uint16_t u16_DataSize);
171#endif
172
173
174
175 // Telemetry
176
177public:
178 int32_t sendTm(const uint8_t u8_VirtualChannelID, const uint16_t u16_APID, const uint16_t u16_ApidSeqNr,
179 const uint8_t *pu8_Data, const uint16_t u16_DataSize);
180 int32_t sendIdle(void);
181
182private:
183 void _setFrameSequenceNumber(const uint8_t mu8_TcFrameSeqNr);
184
185};
186
187
188
189
190
191#endif /* _TMTC_CLIENT_H_ */
192
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 Communications Link Transmission Unit (CLTU) as described in CCSDS 231....
Definition: ccsds_cltu.h:38
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 Telecommand as described in CCSDS 232.0-B-3.
Definition: ccsds_transferframe_tc.h:77
Class which implements a Frame Acceptance and Reporting Mechanism (FARM) on the spacecraft.
Definition: tmtc_client.h:74