##// END OF EJS Templates
105 corrected
paul -
r210:b3827d47ca2e R3
parent child
Show More
@@ -1,510 +1,514
1 1 /** Functions to send TM packets related to TC parsing and execution.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to send appropriate TM packets after parsing and execution:
7 7 * - TM_LFR_TC_EXE_SUCCESS
8 8 * - TM_LFR_TC_EXE_INCONSISTENT
9 9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
10 10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
11 11 * - TM_LFR_TC_EXE_ERROR
12 12 * - TM_LFR_TC_EXE_CORRUPTED
13 13 *
14 14 */
15 15
16 16 #include "tm_lfr_tc_exe.h"
17 17
18 18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
19 19 {
20 20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
21 21 *
22 22 * @param TC points to the TeleCommand packet that is being processed
23 23 * @param queue_id is the id of the queue which handles TM
24 24 *
25 25 * @return RTEMS directive status code:
26 26 * - RTEMS_SUCCESSFUL - message sent successfully
27 27 * - RTEMS_INVALID_ID - invalid queue id
28 28 * - RTEMS_INVALID_SIZE - invalid message size
29 29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
30 30 * - RTEMS_UNSATISFIED - out of message buffers
31 31 * - RTEMS_TOO_MANY - queue s limit has been reached
32 32 *
33 33 */
34 34
35 35 rtems_status_code status;
36 36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
37 37 unsigned char messageSize;
38 38
39 39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
40 40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
45 45 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 49 // DATA FIELD HEADER
50 50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 51 TM.serviceType = TM_TYPE_TC_EXE;
52 52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 53 TM.destinationID = TC->sourceID;
54 54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
55 55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
56 56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
57 57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
58 58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
59 59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
60 60 //
61 61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 62 TM.telecommand_pkt_id[1] = TC->packetID[1];
63 63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
64 64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
65 65
66 66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
67 67
68 68 // SEND DATA
69 69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
70 70 if (status != RTEMS_SUCCESSFUL) {
71 71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
72 72 }
73 73
74 74 // UPDATE HK FIELDS
75 75 update_last_TC_exe( TC, TM.time );
76 76
77 77 return status;
78 78 }
79 79
80 80 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
81 81 unsigned char byte_position, unsigned char rcv_value )
82 82 {
83 83 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
84 84 *
85 85 * @param TC points to the TeleCommand packet that is being processed
86 86 * @param queue_id is the id of the queue which handles TM
87 87 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
88 88 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
89 89 *
90 90 * @return RTEMS directive status code:
91 91 * - RTEMS_SUCCESSFUL - message sent successfully
92 92 * - RTEMS_INVALID_ID - invalid queue id
93 93 * - RTEMS_INVALID_SIZE - invalid message size
94 94 * - RTEMS_INVALID_ADDRESS - buffer is NULL
95 95 * - RTEMS_UNSATISFIED - out of message buffers
96 96 * - RTEMS_TOO_MANY - queue s limit has been reached
97 97 *
98 98 */
99 99
100 100 rtems_status_code status;
101 101 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
102 102 unsigned char messageSize;
103 103
104 104 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
105 105 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
106 106 TM.reserved = DEFAULT_RESERVED;
107 107 TM.userApplication = CCSDS_USER_APP;
108 108 // PACKET HEADER
109 109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
110 110 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
111 111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
112 112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
113 113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
114 114 // DATA FIELD HEADER
115 115 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
116 116 TM.serviceType = TM_TYPE_TC_EXE;
117 117 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
118 118 TM.destinationID = TC->sourceID;
119 119 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
120 120 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
121 121 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
122 122 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
123 123 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
124 124 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
125 125 //
126 126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
127 127 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
128 128 TM.telecommand_pkt_id[0] = TC->packetID[0];
129 129 TM.telecommand_pkt_id[1] = TC->packetID[1];
130 130 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
131 131 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
132 132 TM.tc_service = TC->serviceType; // type of the rejected TC
133 133 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
134 134 TM.byte_position = byte_position;
135 135 TM.rcv_value = (unsigned char) rcv_value;
136 136
137 137 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
138 138
139 139 // SEND DATA
140 140 status = rtems_message_queue_send( queue_id, &TM, messageSize);
141 141 if (status != RTEMS_SUCCESSFUL) {
142 142 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
143 143 }
144 144
145 145 // UPDATE HK FIELDS
146 146 update_last_TC_rej( TC, TM.time );
147 147
148 148 return status;
149 149 }
150 150
151 151 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 152 {
153 153 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
154 154 *
155 155 * @param TC points to the TeleCommand packet that is being processed
156 156 * @param queue_id is the id of the queue which handles TM
157 157 *
158 158 * @return RTEMS directive status code:
159 159 * - RTEMS_SUCCESSFUL - message sent successfully
160 160 * - RTEMS_INVALID_ID - invalid queue id
161 161 * - RTEMS_INVALID_SIZE - invalid message size
162 162 * - RTEMS_INVALID_ADDRESS - buffer is NULL
163 163 * - RTEMS_UNSATISFIED - out of message buffers
164 164 * - RTEMS_TOO_MANY - queue s limit has been reached
165 165 *
166 166 */
167 167
168 168 rtems_status_code status;
169 169 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
170 170 unsigned char messageSize;
171 171
172 172 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
173 173 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
174 174 TM.reserved = DEFAULT_RESERVED;
175 175 TM.userApplication = CCSDS_USER_APP;
176 176 // PACKET HEADER
177 177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
178 178 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
179 179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
180 180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
181 181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
182 182 // DATA FIELD HEADER
183 183 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
184 184 TM.serviceType = TM_TYPE_TC_EXE;
185 185 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
186 186 TM.destinationID = TC->sourceID; // default destination id
187 187 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
188 188 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
189 189 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
190 190 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
191 191 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
192 192 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
193 193 //
194 194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
195 195 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
196 196 TM.telecommand_pkt_id[0] = TC->packetID[0];
197 197 TM.telecommand_pkt_id[1] = TC->packetID[1];
198 198 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
199 199 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
200 200 TM.tc_service = TC->serviceType; // type of the rejected TC
201 201 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
202 202 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
203 203 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
204 204
205 205 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
206 206
207 207 // SEND DATA
208 208 status = rtems_message_queue_send( queue_id, &TM, messageSize);
209 209 if (status != RTEMS_SUCCESSFUL) {
210 210 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
211 211 }
212 212
213 213 // UPDATE HK FIELDS
214 214 update_last_TC_rej( TC, TM.time );
215 215
216 216 return status;
217 217 }
218 218
219 219 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
220 220 {
221 221 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
222 222 *
223 223 * @param TC points to the TeleCommand packet that is being processed
224 224 * @param queue_id is the id of the queue which handles TM
225 225 *
226 226 * @return RTEMS directive status code:
227 227 * - RTEMS_SUCCESSFUL - message sent successfully
228 228 * - RTEMS_INVALID_ID - invalid queue id
229 229 * - RTEMS_INVALID_SIZE - invalid message size
230 230 * - RTEMS_INVALID_ADDRESS - buffer is NULL
231 231 * - RTEMS_UNSATISFIED - out of message buffers
232 232 * - RTEMS_TOO_MANY - queue s limit has been reached
233 233 *
234 234 */
235 235
236 236 rtems_status_code status;
237 237 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
238 238 unsigned char messageSize;
239 239
240 240 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
241 241 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
242 242 TM.reserved = DEFAULT_RESERVED;
243 243 TM.userApplication = CCSDS_USER_APP;
244 244 // PACKET HEADER
245 245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
246 246 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
247 247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
248 248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
249 249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
250 250 // DATA FIELD HEADER
251 251 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
252 252 TM.serviceType = TM_TYPE_TC_EXE;
253 253 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
254 254 TM.destinationID = TC->sourceID; // default destination id
255 255 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
256 256 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
257 257 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
258 258 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
259 259 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
260 260 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
261 261 //
262 262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
263 263 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
264 264 TM.telecommand_pkt_id[0] = TC->packetID[0];
265 265 TM.telecommand_pkt_id[1] = TC->packetID[1];
266 266 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
267 267 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
268 268 TM.tc_service = TC->serviceType; // type of the rejected TC
269 269 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
270 270
271 271 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
272 272
273 273 // SEND DATA
274 274 status = rtems_message_queue_send( queue_id, &TM, messageSize);
275 275 if (status != RTEMS_SUCCESSFUL) {
276 276 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
277 277 }
278 278
279 279 // UPDATE HK FIELDS
280 280 update_last_TC_rej( TC, TM.time );
281 281
282 282 return status;
283 283 }
284 284
285 285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
286 286 {
287 287 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
288 288 *
289 289 * @param TC points to the TeleCommand packet that is being processed
290 290 * @param queue_id is the id of the queue which handles TM
291 291 *
292 292 * @return RTEMS directive status code:
293 293 * - RTEMS_SUCCESSFUL - message sent successfully
294 294 * - RTEMS_INVALID_ID - invalid queue id
295 295 * - RTEMS_INVALID_SIZE - invalid message size
296 296 * - RTEMS_INVALID_ADDRESS - buffer is NULL
297 297 * - RTEMS_UNSATISFIED - out of message buffers
298 298 * - RTEMS_TOO_MANY - queue s limit has been reached
299 299 *
300 300 */
301 301
302 302 rtems_status_code status;
303 303 Packet_TM_LFR_TC_EXE_ERROR_t TM;
304 304 unsigned char messageSize;
305 305
306 306 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
307 307 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
308 308 TM.reserved = DEFAULT_RESERVED;
309 309 TM.userApplication = CCSDS_USER_APP;
310 310 // PACKET HEADER
311 311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
312 312 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
313 313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
314 314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
315 315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
316 316 // DATA FIELD HEADER
317 317 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
318 318 TM.serviceType = TM_TYPE_TC_EXE;
319 319 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
320 320 TM.destinationID = TC->sourceID; // default destination id
321 321 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
322 322 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
323 323 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
324 324 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
325 325 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
326 326 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
327 327 //
328 328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
329 329 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
330 330 TM.telecommand_pkt_id[0] = TC->packetID[0];
331 331 TM.telecommand_pkt_id[1] = TC->packetID[1];
332 332 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
333 333 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
334 334 TM.tc_service = TC->serviceType; // type of the rejected TC
335 335 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
336 336
337 337 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
338 338
339 339 // SEND DATA
340 340 status = rtems_message_queue_send( queue_id, &TM, messageSize);
341 341 if (status != RTEMS_SUCCESSFUL) {
342 342 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
343 343 }
344 344
345 345 // UPDATE HK FIELDS
346 346 update_last_TC_rej( TC, TM.time );
347 347
348 348 return status;
349 349 }
350 350
351 351 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
352 352 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
353 353 unsigned char destinationID )
354 354 {
355 355 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
356 356 *
357 357 * @param TC points to the TeleCommand packet that is being processed
358 358 * @param queue_id is the id of the queue which handles TM
359 359 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
360 360 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
361 361 *
362 362 * @return RTEMS directive status code:
363 363 * - RTEMS_SUCCESSFUL - message sent successfully
364 364 * - RTEMS_INVALID_ID - invalid queue id
365 365 * - RTEMS_INVALID_SIZE - invalid message size
366 366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 367 * - RTEMS_UNSATISFIED - out of message buffers
368 368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 369 *
370 370 */
371 371
372 372 rtems_status_code status;
373 373 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
374 374 unsigned char messageSize;
375 375 unsigned int packetLength;
376 unsigned int estimatedPacketLength;
376 377 unsigned char *packetDataField;
377 378
378 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
379 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter written in the TC
380 estimatedPacketLength = (unsigned int) (currentTC_LEN_RCV[0] * 256 + currentTC_LEN_RCV[1]);
379 381 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
380 382
381 383 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
382 384 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
383 385 TM.reserved = DEFAULT_RESERVED;
384 386 TM.userApplication = CCSDS_USER_APP;
385 387 // PACKET HEADER
386 388 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
387 389 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
388 390 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
389 391 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
390 392 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
391 393 // DATA FIELD HEADER
392 394 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
393 395 TM.serviceType = TM_TYPE_TC_EXE;
394 396 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
395 397 TM.destinationID = destinationID;
396 398 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
397 399 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
398 400 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
399 401 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
400 402 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
401 403 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
402 404 //
403 405 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
404 406 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
405 407 TM.telecommand_pkt_id[0] = TC->packetID[0];
406 408 TM.telecommand_pkt_id[1] = TC->packetID[1];
407 409 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
408 410 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
409 411 TM.tc_service = TC->serviceType; // type of the rejected TC
410 412 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
411 413 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
412 414 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
413 415 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
414 416 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
415 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
416 TM.rcv_crc[1] = packetDataField[ packetLength ];
417 // TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
418 // TM.rcv_crc[1] = packetDataField[ packetLength ];
419 TM.rcv_crc[0] = packetDataField[ estimatedPacketLength - 1 ];
420 TM.rcv_crc[1] = packetDataField[ estimatedPacketLength ];
417 421 TM.computed_crc[0] = computed_CRC[0];
418 422 TM.computed_crc[1] = computed_CRC[1];
419 423
420 424 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
421 425
422 426 // SEND DATA
423 427 status = rtems_message_queue_send( queue_id, &TM, messageSize);
424 428 if (status != RTEMS_SUCCESSFUL) {
425 429 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
426 430 }
427 431
428 432 // UPDATE HK FIELDS
429 433 update_last_TC_rej( TC, TM.time );
430 434
431 435 return status;
432 436 }
433 437
434 438 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
435 439 {
436 440 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
437 441 *
438 442 * @param packet_sequence_control points to the packet sequence control which will be incremented
439 443 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
440 444 *
441 445 * If the destination ID is not known, a dedicated counter is incremented.
442 446 *
443 447 */
444 448
445 449 unsigned short sequence_cnt;
446 450 unsigned short segmentation_grouping_flag;
447 451 unsigned short new_packet_sequence_control;
448 452 unsigned char i;
449 453
450 454 switch (destination_id)
451 455 {
452 456 case SID_TC_GROUND:
453 457 i = GROUND;
454 458 break;
455 459 case SID_TC_MISSION_TIMELINE:
456 460 i = MISSION_TIMELINE;
457 461 break;
458 462 case SID_TC_TC_SEQUENCES:
459 463 i = TC_SEQUENCES;
460 464 break;
461 465 case SID_TC_RECOVERY_ACTION_CMD:
462 466 i = RECOVERY_ACTION_CMD;
463 467 break;
464 468 case SID_TC_BACKUP_MISSION_TIMELINE:
465 469 i = BACKUP_MISSION_TIMELINE;
466 470 break;
467 471 case SID_TC_DIRECT_CMD:
468 472 i = DIRECT_CMD;
469 473 break;
470 474 case SID_TC_SPARE_GRD_SRC1:
471 475 i = SPARE_GRD_SRC1;
472 476 break;
473 477 case SID_TC_SPARE_GRD_SRC2:
474 478 i = SPARE_GRD_SRC2;
475 479 break;
476 480 case SID_TC_OBCP:
477 481 i = OBCP;
478 482 break;
479 483 case SID_TC_SYSTEM_CONTROL:
480 484 i = SYSTEM_CONTROL;
481 485 break;
482 486 case SID_TC_AOCS:
483 487 i = AOCS;
484 488 break;
485 489 case SID_TC_RPW_INTERNAL:
486 490 i = RPW_INTERNAL;
487 491 break;
488 492 default:
489 493 i = GROUND;
490 494 break;
491 495 }
492 496
493 497 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
494 498 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
495 499
496 500 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
497 501
498 502 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
499 503 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
500 504
501 505 // increment the sequence counter
502 506 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX )
503 507 {
504 508 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
505 509 }
506 510 else
507 511 {
508 512 sequenceCounters_TC_EXE[ i ] = 0;
509 513 }
510 514 }
General Comments 0
You need to be logged in to leave comments. Login now