@@ -1,2 +1,2 | |||
|
1 | 1 | a586fe639ac179e95bdc150ebdbab0312f31dc30 LFR_basic-parameters |
|
2 | 72c4d5eb0bb95a1546beb2b22c8b88c31322ae31 header/lfr_common_headers | |
|
2 | bb9afa759d57093f7646d3be18f4a9923a4cbf84 header/lfr_common_headers |
@@ -1,112 +1,112 | |||
|
1 | 1 | TEMPLATE = app |
|
2 | 2 | # CONFIG += console v8 sim |
|
3 | 3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch |
|
4 | 4 | # lpp_dpu_destid |
|
5 | 5 | CONFIG += console verbose lpp_dpu_destid |
|
6 | 6 | CONFIG -= qt |
|
7 | 7 | |
|
8 | 8 | include(./sparc.pri) |
|
9 | 9 | |
|
10 | 10 | # flight software version |
|
11 | 11 | SWVERSION=-1-0 |
|
12 | 12 | DEFINES += SW_VERSION_N1=3 # major |
|
13 | 13 | DEFINES += SW_VERSION_N2=0 # minor |
|
14 | 14 | DEFINES += SW_VERSION_N3=0 # patch |
|
15 |
DEFINES += SW_VERSION_N4= |
|
|
15 | DEFINES += SW_VERSION_N4=4 # internal | |
|
16 | 16 | |
|
17 | 17 | # <GCOV> |
|
18 | 18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage |
|
19 | 19 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc |
|
20 | 20 | # </GCOV> |
|
21 | 21 | |
|
22 | 22 | # <CHANGE BEFORE FLIGHT> |
|
23 | 23 | contains( CONFIG, lpp_dpu_destid ) { |
|
24 | 24 | DEFINES += LPP_DPU_DESTID |
|
25 | 25 | } |
|
26 | 26 | # </CHANGE BEFORE FLIGHT> |
|
27 | 27 | |
|
28 | 28 | contains( CONFIG, debug_tch ) { |
|
29 | 29 | DEFINES += DEBUG_TCH |
|
30 | 30 | } |
|
31 | 31 | DEFINES += MSB_FIRST_TCH |
|
32 | 32 | |
|
33 | 33 | contains( CONFIG, vhdl_dev ) { |
|
34 | 34 | DEFINES += VHDL_DEV |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | contains( CONFIG, verbose ) { |
|
38 | 38 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | contains( CONFIG, debug_messages ) { |
|
42 | 42 | DEFINES += DEBUG_MESSAGES |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | contains( CONFIG, cpu_usage_report ) { |
|
46 | 46 | DEFINES += PRINT_TASK_STATISTICS |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | contains( CONFIG, stack_report ) { |
|
50 | 50 | DEFINES += PRINT_STACK_REPORT |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | contains( CONFIG, boot_messages ) { |
|
54 | 54 | DEFINES += BOOT_MESSAGES |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | #doxygen.target = doxygen |
|
58 | 58 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
59 | 59 | #QMAKE_EXTRA_TARGETS += doxygen |
|
60 | 60 | |
|
61 | 61 | TARGET = fsw |
|
62 | 62 | |
|
63 | 63 | INCLUDEPATH += \ |
|
64 | 64 | $${PWD}/../src \ |
|
65 | 65 | $${PWD}/../header \ |
|
66 | 66 | $${PWD}/../header/lfr_common_headers \ |
|
67 | 67 | $${PWD}/../header/processing \ |
|
68 | 68 | $${PWD}/../LFR_basic-parameters |
|
69 | 69 | |
|
70 | 70 | SOURCES += \ |
|
71 | 71 | ../src/wf_handler.c \ |
|
72 | 72 | ../src/tc_handler.c \ |
|
73 | 73 | ../src/fsw_misc.c \ |
|
74 | 74 | ../src/fsw_init.c \ |
|
75 | 75 | ../src/fsw_globals.c \ |
|
76 | 76 | ../src/fsw_spacewire.c \ |
|
77 | 77 | ../src/tc_load_dump_parameters.c \ |
|
78 | 78 | ../src/tm_lfr_tc_exe.c \ |
|
79 | 79 | ../src/tc_acceptance.c \ |
|
80 | 80 | ../src/processing/fsw_processing.c \ |
|
81 | 81 | ../src/processing/avf0_prc0.c \ |
|
82 | 82 | ../src/processing/avf1_prc1.c \ |
|
83 | 83 | ../src/processing/avf2_prc2.c \ |
|
84 | 84 | ../src/lfr_cpu_usage_report.c \ |
|
85 | 85 | ../LFR_basic-parameters/basic_parameters.c |
|
86 | 86 | |
|
87 | 87 | HEADERS += \ |
|
88 | 88 | ../header/wf_handler.h \ |
|
89 | 89 | ../header/tc_handler.h \ |
|
90 | 90 | ../header/grlib_regs.h \ |
|
91 | 91 | ../header/fsw_misc.h \ |
|
92 | 92 | ../header/fsw_init.h \ |
|
93 | 93 | ../header/fsw_spacewire.h \ |
|
94 | 94 | ../header/tc_load_dump_parameters.h \ |
|
95 | 95 | ../header/tm_lfr_tc_exe.h \ |
|
96 | 96 | ../header/tc_acceptance.h \ |
|
97 | 97 | ../header/processing/fsw_processing.h \ |
|
98 | 98 | ../header/processing/avf0_prc0.h \ |
|
99 | 99 | ../header/processing/avf1_prc1.h \ |
|
100 | 100 | ../header/processing/avf2_prc2.h \ |
|
101 | 101 | ../header/fsw_params_wf_handler.h \ |
|
102 | 102 | ../header/lfr_cpu_usage_report.h \ |
|
103 | 103 | ../header/lfr_common_headers/ccsds_types.h \ |
|
104 | 104 | ../header/lfr_common_headers/fsw_params.h \ |
|
105 | 105 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ |
|
106 | 106 | ../header/lfr_common_headers/fsw_params_processing.h \ |
|
107 | 107 | ../header/lfr_common_headers/TC_types.h \ |
|
108 | 108 | ../header/lfr_common_headers/tm_byte_positions.h \ |
|
109 | 109 | ../LFR_basic-parameters/basic_parameters.h \ |
|
110 | 110 | ../LFR_basic-parameters/basic_parameters_params.h \ |
|
111 | 111 | ../header/GscMemoryLPP.hpp |
|
112 | 112 |
@@ -1,463 +1,465 | |||
|
1 | 1 | /** Functions related to TeleCommand acceptance. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands parsing.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "tc_acceptance.h" |
|
11 | #include <stdio.h> | |
|
11 | 12 | |
|
12 | 13 | unsigned int lookUpTableForCRC[256]; |
|
13 | 14 | |
|
14 | 15 | //********************** |
|
15 | 16 | // GENERAL USE FUNCTIONS |
|
16 | 17 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
17 | 18 | { |
|
18 | 19 | /** This function generate the CRC for one byte and returns the value of the new syndrome. |
|
19 | 20 | * |
|
20 | 21 | * @param D is the current byte of data. |
|
21 | 22 | * @param Chk is the current syndrom value. |
|
22 | 23 | * |
|
23 | 24 | * @return the value of the new syndrome on two bytes. |
|
24 | 25 | * |
|
25 | 26 | */ |
|
26 | 27 | |
|
27 | 28 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
28 | 29 | } |
|
29 | 30 | |
|
30 | 31 | void initLookUpTableForCRC( void ) |
|
31 | 32 | { |
|
32 | 33 | /** This function is used to initiates the look-up table for fast CRC computation. |
|
33 | 34 | * |
|
34 | 35 | * The global table lookUpTableForCRC[256] is initiated. |
|
35 | 36 | * |
|
36 | 37 | */ |
|
37 | 38 | |
|
38 | 39 | unsigned int i; |
|
39 | 40 | unsigned int tmp; |
|
40 | 41 | |
|
41 | 42 | for (i=0; i<256; i++) |
|
42 | 43 | { |
|
43 | 44 | tmp = 0; |
|
44 | 45 | if((i & 1) != 0) { |
|
45 | 46 | tmp = tmp ^ 0x1021; |
|
46 | 47 | } |
|
47 | 48 | if((i & 2) != 0) { |
|
48 | 49 | tmp = tmp ^ 0x2042; |
|
49 | 50 | } |
|
50 | 51 | if((i & 4) != 0) { |
|
51 | 52 | tmp = tmp ^ 0x4084; |
|
52 | 53 | } |
|
53 | 54 | if((i & 8) != 0) { |
|
54 | 55 | tmp = tmp ^ 0x8108; |
|
55 | 56 | } |
|
56 | 57 | if((i & 16) != 0) { |
|
57 | 58 | tmp = tmp ^ 0x1231; |
|
58 | 59 | } |
|
59 | 60 | if((i & 32) != 0) { |
|
60 | 61 | tmp = tmp ^ 0x2462; |
|
61 | 62 | } |
|
62 | 63 | if((i & 64) != 0) { |
|
63 | 64 | tmp = tmp ^ 0x48c4; |
|
64 | 65 | } |
|
65 | 66 | if((i & 128) != 0) { |
|
66 | 67 | tmp = tmp ^ 0x9188; |
|
67 | 68 | } |
|
68 | 69 | lookUpTableForCRC[i] = tmp; |
|
69 | 70 | } |
|
70 | 71 | } |
|
71 | 72 | |
|
72 | 73 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
73 | 74 | { |
|
74 | 75 | /** This function calculates a two bytes Cyclic Redundancy Code. |
|
75 | 76 | * |
|
76 | 77 | * @param data points to a buffer containing the data on which to compute the CRC. |
|
77 | 78 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. |
|
78 | 79 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. |
|
79 | 80 | * |
|
80 | 81 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. |
|
81 | 82 | * |
|
82 | 83 | */ |
|
83 | 84 | |
|
84 | 85 | unsigned int Chk; |
|
85 | 86 | int j; |
|
86 | 87 | Chk = 0xffff; // reset the syndrom to all ones |
|
87 | 88 | for (j=0; j<sizeOfData; j++) { |
|
88 | 89 | Chk = Crc_opt(data[j], Chk); |
|
89 | 90 | } |
|
90 | 91 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
91 | 92 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
92 | 93 | } |
|
93 | 94 | |
|
94 | 95 | //********************* |
|
95 | 96 | // ACCEPTANCE FUNCTIONS |
|
96 | 97 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC) |
|
97 | 98 | { |
|
98 | 99 | /** This function parses TeleCommands. |
|
99 | 100 | * |
|
100 | 101 | * @param TC points to the TeleCommand that will be parsed. |
|
101 | 102 | * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet. |
|
102 | 103 | * |
|
103 | 104 | * @return Status code of the parsing. |
|
104 | 105 | * |
|
105 | 106 | * The parsing checks: |
|
106 | 107 | * - process id |
|
107 | 108 | * - category |
|
108 | 109 | * - length: a global check is performed and a per subtype check also |
|
109 | 110 | * - type |
|
110 | 111 | * - subtype |
|
111 | 112 | * - crc |
|
112 | 113 | * |
|
113 | 114 | */ |
|
114 | 115 | |
|
115 | 116 | int status; |
|
116 | 117 | int status_crc; |
|
117 | 118 | unsigned char pid; |
|
118 | 119 | unsigned char category; |
|
119 | 120 | unsigned int packetLength; |
|
120 | 121 | unsigned char packetType; |
|
121 | 122 | unsigned char packetSubtype; |
|
122 | 123 | unsigned char sid; |
|
123 | 124 | |
|
124 | 125 | status = CCSDS_TM_VALID; |
|
125 | 126 | |
|
126 | 127 | // APID check *** APID on 2 bytes |
|
127 | 128 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
128 | 129 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
129 | 130 | packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; |
|
130 | 131 | packetType = TCPacket->serviceType; |
|
131 | 132 | packetSubtype = TCPacket->serviceSubType; |
|
132 | 133 | sid = TCPacket->sourceID; |
|
133 | 134 | |
|
134 | 135 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID |
|
135 | 136 | { |
|
136 | 137 | status = ILLEGAL_APID; |
|
137 | 138 | } |
|
138 | 139 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY |
|
139 | 140 | { |
|
140 | 141 | if ( category != CCSDS_PACKET_CATEGORY ) |
|
141 | 142 | { |
|
142 | 143 | status = ILLEGAL_APID; |
|
143 | 144 | } |
|
144 | 145 | } |
|
145 | 146 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE |
|
146 | 147 | { |
|
147 | 148 | if (packetLength != estimatedPacketLength ) { |
|
148 | 149 | status = WRONG_LEN_PKT; |
|
149 | 150 | } |
|
150 | 151 | } |
|
151 | 152 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE |
|
152 | 153 | { |
|
153 | 154 | if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) { |
|
154 | 155 | status = WRONG_LEN_PKT; |
|
155 | 156 | } |
|
156 | 157 | } |
|
157 | 158 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE |
|
158 | 159 | { |
|
159 | 160 | status = tc_check_type( packetType ); |
|
160 | 161 | } |
|
161 | 162 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE |
|
162 | 163 | { |
|
163 | 164 | status = tc_check_type_subtype( packetType, packetSubtype ); |
|
164 | 165 | } |
|
165 | 166 | if (status == CCSDS_TM_VALID) // CHECK THE SID |
|
166 | 167 | { |
|
167 | 168 | status = tc_check_sid( sid ); |
|
168 | 169 | } |
|
169 | 170 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE |
|
170 | 171 | { |
|
171 | 172 | status = tc_check_length( packetSubtype, packetLength ); |
|
172 | 173 | } |
|
173 | 174 | status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC ); |
|
174 | 175 | if (status == CCSDS_TM_VALID ) // CHECK CRC |
|
175 | 176 | { |
|
176 | 177 | status = status_crc; |
|
177 | 178 | } |
|
178 | 179 | |
|
179 | 180 | return status; |
|
180 | 181 | } |
|
181 | 182 | |
|
182 | 183 | int tc_check_type( unsigned char packetType ) |
|
183 | 184 | { |
|
184 | 185 | /** This function checks that the type of a TeleCommand is valid. |
|
185 | 186 | * |
|
186 | 187 | * @param packetType is the type to check. |
|
187 | 188 | * |
|
188 | 189 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
189 | 190 | * |
|
190 | 191 | */ |
|
191 | 192 | |
|
192 | 193 | int status; |
|
193 | 194 | |
|
194 | 195 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) |
|
195 | 196 | { |
|
196 | 197 | status = CCSDS_TM_VALID; |
|
197 | 198 | } |
|
198 | 199 | else |
|
199 | 200 | { |
|
200 | 201 | status = ILL_TYPE; |
|
201 | 202 | } |
|
202 | 203 | |
|
203 | 204 | return status; |
|
204 | 205 | } |
|
205 | 206 | |
|
206 | 207 | int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ) |
|
207 | 208 | { |
|
208 | 209 | /** This function checks that the subtype of a TeleCommand is valid and coherent with the type. |
|
209 | 210 | * |
|
210 | 211 | * @param packetType is the type of the TC. |
|
211 | 212 | * @param packetSubType is the subtype to check. |
|
212 | 213 | * |
|
213 | 214 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. |
|
214 | 215 | * |
|
215 | 216 | */ |
|
216 | 217 | |
|
217 | 218 | int status; |
|
218 | 219 | |
|
219 | 220 | switch(packetType) |
|
220 | 221 | { |
|
221 | 222 | case TC_TYPE_GEN: |
|
222 | 223 | if ( (packetSubType == TC_SUBTYPE_RESET) |
|
223 | 224 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) |
|
224 | 225 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) |
|
225 | 226 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) |
|
226 | 227 | || (packetSubType == TC_SUBTYPE_DUMP) |
|
227 | 228 | || (packetSubType == TC_SUBTYPE_ENTER) |
|
228 | 229 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) |
|
229 | 230 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) |
|
230 | 231 | || (packetSubType == TC_SUBTYPE_LOAD_K) || (packetSubType == TC_SUBTYPE_DUMP_K) |
|
231 | 232 | || (packetSubType == TC_SUBTYPE_LOAD_FBINS) ) |
|
232 | 233 | { |
|
233 | 234 | status = CCSDS_TM_VALID; |
|
234 | 235 | } |
|
235 | 236 | else |
|
236 | 237 | { |
|
237 | 238 | status = ILL_SUBTYPE; |
|
238 | 239 | } |
|
239 | 240 | break; |
|
240 | 241 | |
|
241 | 242 | case TC_TYPE_TIME: |
|
242 | 243 | if (packetSubType == TC_SUBTYPE_UPDT_TIME) |
|
243 | 244 | { |
|
244 | 245 | status = CCSDS_TM_VALID; |
|
245 | 246 | } |
|
246 | 247 | else |
|
247 | 248 | { |
|
248 | 249 | status = ILL_SUBTYPE; |
|
249 | 250 | } |
|
250 | 251 | break; |
|
251 | 252 | |
|
252 | 253 | default: |
|
253 | 254 | status = ILL_SUBTYPE; |
|
254 | 255 | break; |
|
255 | 256 | } |
|
256 | 257 | |
|
257 | 258 | return status; |
|
258 | 259 | } |
|
259 | 260 | |
|
260 | 261 | int tc_check_sid( unsigned char sid ) |
|
261 | 262 | { |
|
262 | 263 | /** This function checks that the sid of a TeleCommand is valid. |
|
263 | 264 | * |
|
264 | 265 | * @param sid is the sid to check. |
|
265 | 266 | * |
|
266 | 267 | * @return Status code CCSDS_TM_VALID or CORRUPTED. |
|
267 | 268 | * |
|
268 | 269 | */ |
|
269 | 270 | |
|
270 | 271 | int status; |
|
271 | 272 | |
|
272 | 273 | if ( (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) |
|
273 | 274 | || (sid == SID_TC_BACKUP_MISSION_TIMELINE) |
|
274 | 275 | || (sid == SID_TC_DIRECT_CMD) || (sid == SID_TC_SPARE_GRD_SRC1) || (sid == SID_TC_SPARE_GRD_SRC2) |
|
275 | 276 | || (sid == SID_TC_OBCP) || (sid == SID_TC_SYSTEM_CONTROL) || (sid == SID_TC_AOCS) |
|
276 | 277 | || (sid == SID_TC_RPW_INTERNAL)) |
|
277 | 278 | { |
|
278 | 279 | status = CCSDS_TM_VALID; |
|
279 | 280 | } |
|
280 | 281 | else |
|
281 | 282 | { |
|
282 | 283 | status = WRONG_SRC_ID; |
|
283 | 284 | } |
|
284 | 285 | |
|
285 | 286 | return status; |
|
286 | 287 | } |
|
287 | 288 | |
|
288 | 289 | int tc_check_length( unsigned char packetSubType, unsigned int length ) |
|
289 | 290 | { |
|
290 | 291 | /** This function checks that the subtype and the length are compliant. |
|
291 | 292 | * |
|
292 | 293 | * @param packetSubType is the subtype to check. |
|
293 | 294 | * @param length is the length to check. |
|
294 | 295 | * |
|
295 | 296 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
296 | 297 | * |
|
297 | 298 | */ |
|
298 | 299 | |
|
299 | 300 | int status; |
|
300 | 301 | |
|
301 | 302 | status = LFR_SUCCESSFUL; |
|
302 | 303 | |
|
303 | 304 | switch(packetSubType) |
|
304 | 305 | { |
|
305 | 306 | case TC_SUBTYPE_RESET: |
|
306 | 307 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
307 | 308 | status = WRONG_LEN_PKT; |
|
308 | 309 | } |
|
309 | 310 | else { |
|
310 | 311 | status = CCSDS_TM_VALID; |
|
311 | 312 | } |
|
312 | 313 | break; |
|
313 | 314 | case TC_SUBTYPE_LOAD_COMM: |
|
314 | 315 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
315 | 316 | status = WRONG_LEN_PKT; |
|
316 | 317 | } |
|
317 | 318 | else { |
|
318 | 319 | status = CCSDS_TM_VALID; |
|
319 | 320 | } |
|
320 | 321 | break; |
|
321 | 322 | case TC_SUBTYPE_LOAD_NORM: |
|
322 | 323 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
323 | 324 | status = WRONG_LEN_PKT; |
|
324 | 325 | } |
|
325 | 326 | else { |
|
326 | 327 | status = CCSDS_TM_VALID; |
|
327 | 328 | } |
|
328 | 329 | break; |
|
329 | 330 | case TC_SUBTYPE_LOAD_BURST: |
|
330 | 331 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
331 | 332 | status = WRONG_LEN_PKT; |
|
332 | 333 | } |
|
333 | 334 | else { |
|
334 | 335 | status = CCSDS_TM_VALID; |
|
335 | 336 | } |
|
336 | 337 | break; |
|
337 | 338 | case TC_SUBTYPE_LOAD_SBM1: |
|
338 | 339 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
339 | 340 | status = WRONG_LEN_PKT; |
|
340 | 341 | } |
|
341 | 342 | else { |
|
342 | 343 | status = CCSDS_TM_VALID; |
|
343 | 344 | } |
|
344 | 345 | break; |
|
345 | 346 | case TC_SUBTYPE_LOAD_SBM2: |
|
346 | 347 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
347 | 348 | status = WRONG_LEN_PKT; |
|
348 | 349 | } |
|
349 | 350 | else { |
|
350 | 351 | status = CCSDS_TM_VALID; |
|
351 | 352 | } |
|
352 | 353 | break; |
|
353 | 354 | case TC_SUBTYPE_DUMP: |
|
354 | 355 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
355 | 356 | status = WRONG_LEN_PKT; |
|
356 | 357 | } |
|
357 | 358 | else { |
|
358 | 359 | status = CCSDS_TM_VALID; |
|
359 | 360 | } |
|
360 | 361 | break; |
|
361 | 362 | case TC_SUBTYPE_ENTER: |
|
362 | 363 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
363 | 364 | status = WRONG_LEN_PKT; |
|
364 | 365 | } |
|
365 | 366 | else { |
|
366 | 367 | status = CCSDS_TM_VALID; |
|
367 | 368 | } |
|
368 | 369 | break; |
|
369 | 370 | case TC_SUBTYPE_UPDT_INFO: |
|
370 | 371 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
371 | 372 | status = WRONG_LEN_PKT; |
|
372 | 373 | } |
|
373 | 374 | else { |
|
374 | 375 | status = CCSDS_TM_VALID; |
|
375 | 376 | } |
|
376 | 377 | break; |
|
377 | 378 | case TC_SUBTYPE_EN_CAL: |
|
378 | 379 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
379 | 380 | status = WRONG_LEN_PKT; |
|
380 | 381 | } |
|
381 | 382 | else { |
|
382 | 383 | status = CCSDS_TM_VALID; |
|
383 | 384 | } |
|
384 | 385 | break; |
|
385 | 386 | case TC_SUBTYPE_DIS_CAL: |
|
386 | 387 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
387 | 388 | status = WRONG_LEN_PKT; |
|
388 | 389 | } |
|
389 | 390 | else { |
|
390 | 391 | status = CCSDS_TM_VALID; |
|
391 | 392 | } |
|
392 | 393 | break; |
|
393 | 394 | case TC_SUBTYPE_LOAD_K: |
|
394 | 395 | if (length!=(TC_LEN_LOAD_K-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
395 | 396 | status = WRONG_LEN_PKT; |
|
396 | 397 | } |
|
397 | 398 | else { |
|
398 | 399 | status = CCSDS_TM_VALID; |
|
399 | 400 | } |
|
400 | 401 | break; |
|
401 | 402 | case TC_SUBTYPE_DUMP_K: |
|
402 | 403 | if (length!=(TC_LEN_DUMP_K-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
403 | 404 | status = WRONG_LEN_PKT; |
|
404 | 405 | } |
|
405 | 406 | else { |
|
406 | 407 | status = CCSDS_TM_VALID; |
|
407 | 408 | } |
|
408 | 409 | break; |
|
409 | 410 | case TC_SUBTYPE_LOAD_FBINS: |
|
410 | 411 | if (length!=(TC_LEN_LOAD_FBINS-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
411 | 412 | status = WRONG_LEN_PKT; |
|
412 | 413 | } |
|
413 | 414 | else { |
|
414 | 415 | status = CCSDS_TM_VALID; |
|
415 | 416 | } |
|
416 | 417 | break; |
|
417 | 418 | case TC_SUBTYPE_UPDT_TIME: |
|
418 | 419 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
419 | 420 | status = WRONG_LEN_PKT; |
|
420 | 421 | } |
|
421 | 422 | else { |
|
422 | 423 | status = CCSDS_TM_VALID; |
|
423 | 424 | } |
|
424 | 425 | break; |
|
425 | 426 | default: // if the subtype is not a legal value, return ILL_SUBTYPE |
|
426 | 427 | status = ILL_SUBTYPE; |
|
427 | 428 | break ; |
|
428 | 429 | } |
|
429 | 430 | |
|
430 | 431 | return status; |
|
431 | 432 | } |
|
432 | 433 | |
|
433 | 434 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length, unsigned char *computed_CRC ) |
|
434 | 435 | { |
|
435 | 436 | /** This function checks the CRC validity of the corresponding TeleCommand packet. |
|
436 | 437 | * |
|
437 | 438 | * @param TCPacket points to the TeleCommand packet to check. |
|
438 | 439 | * @param length is the length of the TC packet. |
|
439 | 440 | * |
|
440 | 441 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. |
|
441 | 442 | * |
|
442 | 443 | */ |
|
443 | 444 | |
|
444 | 445 | int status; |
|
445 | 446 | unsigned char * CCSDSContent; |
|
446 | 447 | |
|
447 | 448 | CCSDSContent = (unsigned char*) TCPacket->packetID; |
|
448 | 449 | GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
450 | ||
|
449 | 451 | if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { |
|
450 | 452 | status = INCOR_CHECKSUM; |
|
451 | 453 | } |
|
452 | 454 | else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { |
|
453 | 455 | status = INCOR_CHECKSUM; |
|
454 | 456 | } |
|
455 | 457 | else { |
|
456 | 458 | status = CCSDS_TM_VALID; |
|
457 | 459 | } |
|
458 | 460 | |
|
459 | 461 | return status; |
|
460 | 462 | } |
|
461 | 463 | |
|
462 | 464 | |
|
463 | 465 |
General Comments 0
You need to be logged in to leave comments.
Login now