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