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