@@ -1,70 +1,70 | |||
|
1 | 1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
2 | 2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "wf_handler.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | #include "fsw_misc.h" |
|
11 | 11 | #include "basic_parameters_params.h" |
|
12 | 12 | #include "avf0_prc0.h" |
|
13 | 13 | |
|
14 | 14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
15 | 15 | |
|
16 | 16 | extern unsigned short sequenceCounterParameterDump; |
|
17 | 17 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
18 | 18 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
19 | 19 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
20 | 20 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
21 | 21 | extern float k_coeff_intercalib_f2[ ]; |
|
22 | 22 | |
|
23 | 23 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
24 | 24 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
25 | 25 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | 26 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | 27 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
28 | 28 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
29 | 29 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | 30 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
31 | 31 | int action_dump_par(rtems_id queue_id ); |
|
32 | 32 | |
|
33 | 33 | // NORMAL |
|
34 | 34 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
35 | 35 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
36 | 36 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
37 | 37 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
38 | 38 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
39 | 39 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
40 | 40 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
41 | 41 | |
|
42 | 42 | // BURST |
|
43 | 43 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
44 | 44 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
45 | 45 | |
|
46 | 46 | // SBM1 |
|
47 | 47 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
48 | 48 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
49 | 49 | |
|
50 | 50 | // SBM2 |
|
51 | 51 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
52 | 52 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
53 | 53 | |
|
54 | 54 | // TC_LFR_UPDATE_INFO |
|
55 | 55 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
56 | 56 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
57 | 57 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
58 | 58 | |
|
59 | 59 | // FBINS_MASK |
|
60 | 60 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
61 | 61 | |
|
62 | 62 | // KCOEFFICIENTS |
|
63 |
int set_sy_lfr_kcoeff( |
|
|
63 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
|
64 | 64 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
65 | 65 | |
|
66 | 66 | void init_parameter_dump( void ); |
|
67 | 67 | void init_kcoefficients_dump( void ); |
|
68 | 68 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
69 | 69 | |
|
70 | 70 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,1139 +1,1142 | |||
|
1 | 1 | /** Functions to load and dump parameters in the LFR registers. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
7 | 7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
8 | 8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
9 | 9 | * TC_LFR_LOAD_BURST_PAR\n |
|
10 | 10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
11 | 11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
12 | 12 | * |
|
13 | 13 | */ |
|
14 | 14 | |
|
15 | 15 | #include "tc_load_dump_parameters.h" |
|
16 | 16 | |
|
17 | 17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
18 | 18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
19 | 19 | ring_node kcoefficient_node_1; |
|
20 | 20 | ring_node kcoefficient_node_2; |
|
21 | 21 | |
|
22 | 22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
23 | 23 | { |
|
24 | 24 | /** This function updates the LFR registers with the incoming common parameters. |
|
25 | 25 | * |
|
26 | 26 | * @param TC points to the TeleCommand packet that is being processed |
|
27 | 27 | * |
|
28 | 28 | * |
|
29 | 29 | */ |
|
30 | 30 | |
|
31 | 31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
32 | 32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
33 | 33 | set_wfp_data_shaping( ); |
|
34 | 34 | return LFR_SUCCESSFUL; |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
38 | 38 | { |
|
39 | 39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
40 | 40 | * |
|
41 | 41 | * @param TC points to the TeleCommand packet that is being processed |
|
42 | 42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
43 | 43 | * |
|
44 | 44 | */ |
|
45 | 45 | |
|
46 | 46 | int result; |
|
47 | 47 | int flag; |
|
48 | 48 | rtems_status_code status; |
|
49 | 49 | |
|
50 | 50 | flag = LFR_SUCCESSFUL; |
|
51 | 51 | |
|
52 | 52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
53 | 53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
54 | 54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
55 | 55 | flag = LFR_DEFAULT; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
59 | 59 | if (flag == LFR_SUCCESSFUL) |
|
60 | 60 | { |
|
61 | 61 | flag = check_common_par_consistency( TC, queue_id ); |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
65 | 65 | if (flag == LFR_SUCCESSFUL) |
|
66 | 66 | { |
|
67 | 67 | result = set_sy_lfr_n_swf_l( TC ); |
|
68 | 68 | result = set_sy_lfr_n_swf_p( TC ); |
|
69 | 69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
70 | 70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
71 | 71 | result = set_sy_lfr_n_asm_p( TC ); |
|
72 | 72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | return flag; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
79 | 79 | { |
|
80 | 80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
81 | 81 | * |
|
82 | 82 | * @param TC points to the TeleCommand packet that is being processed |
|
83 | 83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
84 | 84 | * |
|
85 | 85 | */ |
|
86 | 86 | |
|
87 | 87 | int flag; |
|
88 | 88 | rtems_status_code status; |
|
89 | 89 | unsigned char sy_lfr_b_bp_p0; |
|
90 | 90 | unsigned char sy_lfr_b_bp_p1; |
|
91 | 91 | float aux; |
|
92 | 92 | |
|
93 | 93 | flag = LFR_SUCCESSFUL; |
|
94 | 94 | |
|
95 | 95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
96 | 96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
97 | 97 | flag = LFR_DEFAULT; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
101 | 101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
102 | 102 | |
|
103 | 103 | // sy_lfr_b_bp_p0 |
|
104 | 104 | if (flag == LFR_SUCCESSFUL) |
|
105 | 105 | { |
|
106 | 106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
107 | 107 | { |
|
108 | 108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
109 | 109 | flag = WRONG_APP_DATA; |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | // sy_lfr_b_bp_p1 |
|
113 | 113 | if (flag == LFR_SUCCESSFUL) |
|
114 | 114 | { |
|
115 | 115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
116 | 116 | { |
|
117 | 117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
118 | 118 | flag = WRONG_APP_DATA; |
|
119 | 119 | } |
|
120 | 120 | } |
|
121 | 121 | //**************************************************************** |
|
122 | 122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
123 | 123 | if (flag == LFR_SUCCESSFUL) |
|
124 | 124 | { |
|
125 | 125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
126 | 126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
127 | 127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
128 | 128 | if (aux > FLOAT_EQUAL_ZERO) |
|
129 | 129 | { |
|
130 | 130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
131 | 131 | flag = LFR_DEFAULT; |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | // SET HTE PARAMETERS |
|
136 | 136 | if (flag == LFR_SUCCESSFUL) |
|
137 | 137 | { |
|
138 | 138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
139 | 139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | return flag; |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
146 | 146 | { |
|
147 | 147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
148 | 148 | * |
|
149 | 149 | * @param TC points to the TeleCommand packet that is being processed |
|
150 | 150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
151 | 151 | * |
|
152 | 152 | */ |
|
153 | 153 | |
|
154 | 154 | int flag; |
|
155 | 155 | rtems_status_code status; |
|
156 | 156 | unsigned char sy_lfr_s1_bp_p0; |
|
157 | 157 | unsigned char sy_lfr_s1_bp_p1; |
|
158 | 158 | float aux; |
|
159 | 159 | |
|
160 | 160 | flag = LFR_SUCCESSFUL; |
|
161 | 161 | |
|
162 | 162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
163 | 163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
164 | 164 | flag = LFR_DEFAULT; |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
168 | 168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
169 | 169 | |
|
170 | 170 | // sy_lfr_s1_bp_p0 |
|
171 | 171 | if (flag == LFR_SUCCESSFUL) |
|
172 | 172 | { |
|
173 | 173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
174 | 174 | { |
|
175 | 175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
176 | 176 | flag = WRONG_APP_DATA; |
|
177 | 177 | } |
|
178 | 178 | } |
|
179 | 179 | // sy_lfr_s1_bp_p1 |
|
180 | 180 | if (flag == LFR_SUCCESSFUL) |
|
181 | 181 | { |
|
182 | 182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
183 | 183 | { |
|
184 | 184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
185 | 185 | flag = WRONG_APP_DATA; |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | //****************************************************************** |
|
189 | 189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
190 | 190 | if (flag == LFR_SUCCESSFUL) |
|
191 | 191 | { |
|
192 | 192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
193 | 193 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | 194 | { |
|
195 | 195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
196 | 196 | flag = LFR_DEFAULT; |
|
197 | 197 | } |
|
198 | 198 | } |
|
199 | 199 | |
|
200 | 200 | // SET THE PARAMETERS |
|
201 | 201 | if (flag == LFR_SUCCESSFUL) |
|
202 | 202 | { |
|
203 | 203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | 204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return flag; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | 211 | { |
|
212 | 212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
213 | 213 | * |
|
214 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 215 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
216 | 216 | * |
|
217 | 217 | */ |
|
218 | 218 | |
|
219 | 219 | int flag; |
|
220 | 220 | rtems_status_code status; |
|
221 | 221 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | 222 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | 223 | float aux; |
|
224 | 224 | |
|
225 | 225 | flag = LFR_SUCCESSFUL; |
|
226 | 226 | |
|
227 | 227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | 228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | 229 | flag = LFR_DEFAULT; |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | 233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | 234 | |
|
235 | 235 | // sy_lfr_s2_bp_p0 |
|
236 | 236 | if (flag == LFR_SUCCESSFUL) |
|
237 | 237 | { |
|
238 | 238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | 239 | { |
|
240 | 240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
241 | 241 | flag = WRONG_APP_DATA; |
|
242 | 242 | } |
|
243 | 243 | } |
|
244 | 244 | // sy_lfr_s2_bp_p1 |
|
245 | 245 | if (flag == LFR_SUCCESSFUL) |
|
246 | 246 | { |
|
247 | 247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | 248 | { |
|
249 | 249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
250 | 250 | flag = WRONG_APP_DATA; |
|
251 | 251 | } |
|
252 | 252 | } |
|
253 | 253 | //****************************************************************** |
|
254 | 254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | 255 | if (flag == LFR_SUCCESSFUL) |
|
256 | 256 | { |
|
257 | 257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | 258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | 259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
260 | 260 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | 261 | { |
|
262 | 262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
263 | 263 | flag = LFR_DEFAULT; |
|
264 | 264 | } |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | // SET THE PARAMETERS |
|
268 | 268 | if (flag == LFR_SUCCESSFUL) |
|
269 | 269 | { |
|
270 | 270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | 271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | 272 | } |
|
273 | 273 | |
|
274 | 274 | return flag; |
|
275 | 275 | } |
|
276 | 276 | |
|
277 | 277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | 278 | { |
|
279 | 279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | 280 | * |
|
281 | 281 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | 282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
283 | 283 | * |
|
284 | 284 | */ |
|
285 | 285 | |
|
286 | 286 | int flag; |
|
287 | 287 | |
|
288 | 288 | flag = LFR_DEFAULT; |
|
289 | 289 | |
|
290 | flag = set_sy_lfr_kcoeff( TC ); | |
|
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
|
291 | 291 | |
|
292 | 292 | return flag; |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | 296 | { |
|
297 | 297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | 298 | * |
|
299 | 299 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | 300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
301 | 301 | * |
|
302 | 302 | */ |
|
303 | 303 | |
|
304 | 304 | int flag; |
|
305 | 305 | |
|
306 | 306 | flag = LFR_DEFAULT; |
|
307 | 307 | |
|
308 | 308 | flag = set_sy_lfr_fbins( TC ); |
|
309 | 309 | |
|
310 | 310 | return flag; |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff) |
|
314 | 314 | { |
|
315 | 315 | printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n", |
|
316 | 316 | freq, |
|
317 | 317 | bin, |
|
318 | 318 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ], |
|
319 | 319 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ], |
|
320 | 320 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ], |
|
321 | 321 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ], |
|
322 | 322 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]); |
|
323 | 323 | } |
|
324 | 324 | |
|
325 | 325 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
326 | 326 | { |
|
327 | 327 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
328 | 328 | * |
|
329 | 329 | * @param TC points to the TeleCommand packet that is being processed |
|
330 | 330 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
331 | 331 | * |
|
332 | 332 | */ |
|
333 | 333 | |
|
334 | 334 | unsigned int address; |
|
335 | 335 | rtems_status_code status; |
|
336 | 336 | unsigned int freq; |
|
337 | 337 | unsigned int bin; |
|
338 | 338 | unsigned int coeff; |
|
339 | 339 | unsigned char *kCoeffPtr; |
|
340 | 340 | unsigned char *kCoeffDumpPtr; |
|
341 | 341 | |
|
342 | 342 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
343 | 343 | // F0 => 11 bins |
|
344 | 344 | // F1 => 13 bins |
|
345 | 345 | // F2 => 12 bins |
|
346 | 346 | // 36 bins to dump in two packets (30 bins max per packet) |
|
347 | 347 | |
|
348 | 348 | //********* |
|
349 | 349 | // PACKET 1 |
|
350 | 350 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
351 | 351 | kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
352 | 352 | kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
353 | 353 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
354 | 354 | for( freq=0; |
|
355 | 355 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
356 | 356 | freq++ ) |
|
357 | 357 | { |
|
358 | 358 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
359 | 359 | bin = freq; |
|
360 | 360 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
361 | 361 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
362 | 362 | { |
|
363 | 363 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
364 | 364 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
365 | 365 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
366 | 366 | } |
|
367 | 367 | } |
|
368 | 368 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
369 | 369 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
370 | 370 | freq++ ) |
|
371 | 371 | { |
|
372 | 372 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
373 | 373 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
374 | 374 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
375 | 375 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
376 | 376 | { |
|
377 | 377 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
378 | 378 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
379 | 379 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
380 | 380 | } |
|
381 | 381 | } |
|
382 | 382 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
383 | 383 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
384 | 384 | freq++ ) |
|
385 | 385 | { |
|
386 | 386 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
387 | 387 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
388 | 388 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
389 | 389 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
390 | 390 | { |
|
391 | 391 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
392 | 392 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
393 | 393 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
394 | 394 | } |
|
395 | 395 | } |
|
396 | 396 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
397 | 397 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
398 | 398 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
399 | 399 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
400 | 400 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
401 | 401 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
402 | 402 | // SEND DATA |
|
403 | 403 | kcoefficient_node_1.status = 1; |
|
404 | 404 | address = (unsigned int) &kcoefficient_node_1; |
|
405 | 405 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
406 | 406 | if (status != RTEMS_SUCCESSFUL) { |
|
407 | 407 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
408 | 408 | } |
|
409 | 409 | |
|
410 | 410 | //******** |
|
411 | 411 | // PACKET 2 |
|
412 | 412 | // 6 F2 bins |
|
413 | 413 | kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
414 | 414 | kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
415 | 415 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
416 | 416 | for( freq=0; freq<6; freq++ ) |
|
417 | 417 | { |
|
418 | 418 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
419 | 419 | bin = freq + 6; |
|
420 | 420 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
421 | 421 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
422 | 422 | { |
|
423 | 423 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
424 | 424 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
425 | 425 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
426 | 426 | } |
|
427 | 427 | } |
|
428 | 428 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
429 | 429 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
430 | 430 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
431 | 431 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
432 | 432 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
433 | 433 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
434 | 434 | // SEND DATA |
|
435 | 435 | kcoefficient_node_2.status = 1; |
|
436 | 436 | address = (unsigned int) &kcoefficient_node_2; |
|
437 | 437 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
438 | 438 | if (status != RTEMS_SUCCESSFUL) { |
|
439 | 439 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
440 | 440 | } |
|
441 | 441 | |
|
442 | 442 | return status; |
|
443 | 443 | } |
|
444 | 444 | |
|
445 | 445 | int action_dump_par( rtems_id queue_id ) |
|
446 | 446 | { |
|
447 | 447 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
448 | 448 | * |
|
449 | 449 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
450 | 450 | * |
|
451 | 451 | * @return RTEMS directive status codes: |
|
452 | 452 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
453 | 453 | * - RTEMS_INVALID_ID - invalid queue id |
|
454 | 454 | * - RTEMS_INVALID_SIZE - invalid message size |
|
455 | 455 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
456 | 456 | * - RTEMS_UNSATISFIED - out of message buffers |
|
457 | 457 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
458 | 458 | * |
|
459 | 459 | */ |
|
460 | 460 | |
|
461 | 461 | int status; |
|
462 | 462 | |
|
463 | 463 | // UPDATE TIME |
|
464 | 464 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
465 | 465 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
466 | 466 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
467 | 467 | |
|
468 | 468 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
469 | 469 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
470 | 470 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
471 | 471 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
472 | 472 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
473 | 473 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
474 | 474 | // SEND DATA |
|
475 | 475 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
476 | 476 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
477 | 477 | if (status != RTEMS_SUCCESSFUL) { |
|
478 | 478 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
479 | 479 | } |
|
480 | 480 | |
|
481 | 481 | return status; |
|
482 | 482 | } |
|
483 | 483 | |
|
484 | 484 | //*********************** |
|
485 | 485 | // NORMAL MODE PARAMETERS |
|
486 | 486 | |
|
487 | 487 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
488 | 488 | { |
|
489 | 489 | unsigned char msb; |
|
490 | 490 | unsigned char lsb; |
|
491 | 491 | int flag; |
|
492 | 492 | float aux; |
|
493 | 493 | rtems_status_code status; |
|
494 | 494 | |
|
495 | 495 | unsigned int sy_lfr_n_swf_l; |
|
496 | 496 | unsigned int sy_lfr_n_swf_p; |
|
497 | 497 | unsigned int sy_lfr_n_asm_p; |
|
498 | 498 | unsigned char sy_lfr_n_bp_p0; |
|
499 | 499 | unsigned char sy_lfr_n_bp_p1; |
|
500 | 500 | unsigned char sy_lfr_n_cwf_long_f3; |
|
501 | 501 | |
|
502 | 502 | flag = LFR_SUCCESSFUL; |
|
503 | 503 | |
|
504 | 504 | //*************** |
|
505 | 505 | // get parameters |
|
506 | 506 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
507 | 507 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
508 | 508 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
509 | 509 | |
|
510 | 510 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
511 | 511 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
512 | 512 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
513 | 513 | |
|
514 | 514 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
515 | 515 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
516 | 516 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
517 | 517 | |
|
518 | 518 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
519 | 519 | |
|
520 | 520 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
521 | 521 | |
|
522 | 522 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
523 | 523 | |
|
524 | 524 | //****************** |
|
525 | 525 | // check consistency |
|
526 | 526 | // sy_lfr_n_swf_l |
|
527 | 527 | if (sy_lfr_n_swf_l != 2048) |
|
528 | 528 | { |
|
529 | 529 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
530 | 530 | flag = WRONG_APP_DATA; |
|
531 | 531 | } |
|
532 | 532 | // sy_lfr_n_swf_p |
|
533 | 533 | if (flag == LFR_SUCCESSFUL) |
|
534 | 534 | { |
|
535 | 535 | if ( sy_lfr_n_swf_p < 16 ) |
|
536 | 536 | { |
|
537 | 537 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
538 | 538 | flag = WRONG_APP_DATA; |
|
539 | 539 | } |
|
540 | 540 | } |
|
541 | 541 | // sy_lfr_n_bp_p0 |
|
542 | 542 | if (flag == LFR_SUCCESSFUL) |
|
543 | 543 | { |
|
544 | 544 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
545 | 545 | { |
|
546 | 546 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
547 | 547 | flag = WRONG_APP_DATA; |
|
548 | 548 | } |
|
549 | 549 | } |
|
550 | 550 | // sy_lfr_n_asm_p |
|
551 | 551 | if (flag == LFR_SUCCESSFUL) |
|
552 | 552 | { |
|
553 | 553 | if (sy_lfr_n_asm_p == 0) |
|
554 | 554 | { |
|
555 | 555 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
556 | 556 | flag = WRONG_APP_DATA; |
|
557 | 557 | } |
|
558 | 558 | } |
|
559 | 559 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
560 | 560 | if (flag == LFR_SUCCESSFUL) |
|
561 | 561 | { |
|
562 | 562 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
563 | 563 | if (aux > FLOAT_EQUAL_ZERO) |
|
564 | 564 | { |
|
565 | 565 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
566 | 566 | flag = WRONG_APP_DATA; |
|
567 | 567 | } |
|
568 | 568 | } |
|
569 | 569 | // sy_lfr_n_bp_p1 |
|
570 | 570 | if (flag == LFR_SUCCESSFUL) |
|
571 | 571 | { |
|
572 | 572 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
573 | 573 | { |
|
574 | 574 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
575 | 575 | flag = WRONG_APP_DATA; |
|
576 | 576 | } |
|
577 | 577 | } |
|
578 | 578 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
579 | 579 | if (flag == LFR_SUCCESSFUL) |
|
580 | 580 | { |
|
581 | 581 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
582 | 582 | if (aux > FLOAT_EQUAL_ZERO) |
|
583 | 583 | { |
|
584 | 584 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
585 | 585 | flag = LFR_DEFAULT; |
|
586 | 586 | } |
|
587 | 587 | } |
|
588 | 588 | // sy_lfr_n_cwf_long_f3 |
|
589 | 589 | |
|
590 | 590 | return flag; |
|
591 | 591 | } |
|
592 | 592 | |
|
593 | 593 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
594 | 594 | { |
|
595 | 595 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
596 | 596 | * |
|
597 | 597 | * @param TC points to the TeleCommand packet that is being processed |
|
598 | 598 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
599 | 599 | * |
|
600 | 600 | */ |
|
601 | 601 | |
|
602 | 602 | int result; |
|
603 | 603 | |
|
604 | 604 | result = LFR_SUCCESSFUL; |
|
605 | 605 | |
|
606 | 606 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
607 | 607 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
608 | 608 | |
|
609 | 609 | return result; |
|
610 | 610 | } |
|
611 | 611 | |
|
612 | 612 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
613 | 613 | { |
|
614 | 614 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
615 | 615 | * |
|
616 | 616 | * @param TC points to the TeleCommand packet that is being processed |
|
617 | 617 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
618 | 618 | * |
|
619 | 619 | */ |
|
620 | 620 | |
|
621 | 621 | int result; |
|
622 | 622 | |
|
623 | 623 | result = LFR_SUCCESSFUL; |
|
624 | 624 | |
|
625 | 625 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
626 | 626 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
627 | 627 | |
|
628 | 628 | return result; |
|
629 | 629 | } |
|
630 | 630 | |
|
631 | 631 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
632 | 632 | { |
|
633 | 633 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
634 | 634 | * |
|
635 | 635 | * @param TC points to the TeleCommand packet that is being processed |
|
636 | 636 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
637 | 637 | * |
|
638 | 638 | */ |
|
639 | 639 | |
|
640 | 640 | int result; |
|
641 | 641 | |
|
642 | 642 | result = LFR_SUCCESSFUL; |
|
643 | 643 | |
|
644 | 644 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
645 | 645 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
646 | 646 | |
|
647 | 647 | return result; |
|
648 | 648 | } |
|
649 | 649 | |
|
650 | 650 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
651 | 651 | { |
|
652 | 652 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
653 | 653 | * |
|
654 | 654 | * @param TC points to the TeleCommand packet that is being processed |
|
655 | 655 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
656 | 656 | * |
|
657 | 657 | */ |
|
658 | 658 | |
|
659 | 659 | int status; |
|
660 | 660 | |
|
661 | 661 | status = LFR_SUCCESSFUL; |
|
662 | 662 | |
|
663 | 663 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
664 | 664 | |
|
665 | 665 | return status; |
|
666 | 666 | } |
|
667 | 667 | |
|
668 | 668 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
669 | 669 | { |
|
670 | 670 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
671 | 671 | * |
|
672 | 672 | * @param TC points to the TeleCommand packet that is being processed |
|
673 | 673 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
674 | 674 | * |
|
675 | 675 | */ |
|
676 | 676 | |
|
677 | 677 | int status; |
|
678 | 678 | |
|
679 | 679 | status = LFR_SUCCESSFUL; |
|
680 | 680 | |
|
681 | 681 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
682 | 682 | |
|
683 | 683 | return status; |
|
684 | 684 | } |
|
685 | 685 | |
|
686 | 686 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
687 | 687 | { |
|
688 | 688 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
689 | 689 | * |
|
690 | 690 | * @param TC points to the TeleCommand packet that is being processed |
|
691 | 691 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
692 | 692 | * |
|
693 | 693 | */ |
|
694 | 694 | |
|
695 | 695 | int status; |
|
696 | 696 | |
|
697 | 697 | status = LFR_SUCCESSFUL; |
|
698 | 698 | |
|
699 | 699 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
700 | 700 | |
|
701 | 701 | return status; |
|
702 | 702 | } |
|
703 | 703 | |
|
704 | 704 | //********************** |
|
705 | 705 | // BURST MODE PARAMETERS |
|
706 | 706 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
707 | 707 | { |
|
708 | 708 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
709 | 709 | * |
|
710 | 710 | * @param TC points to the TeleCommand packet that is being processed |
|
711 | 711 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
712 | 712 | * |
|
713 | 713 | */ |
|
714 | 714 | |
|
715 | 715 | int status; |
|
716 | 716 | |
|
717 | 717 | status = LFR_SUCCESSFUL; |
|
718 | 718 | |
|
719 | 719 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
720 | 720 | |
|
721 | 721 | return status; |
|
722 | 722 | } |
|
723 | 723 | |
|
724 | 724 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
725 | 725 | { |
|
726 | 726 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
727 | 727 | * |
|
728 | 728 | * @param TC points to the TeleCommand packet that is being processed |
|
729 | 729 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
730 | 730 | * |
|
731 | 731 | */ |
|
732 | 732 | |
|
733 | 733 | int status; |
|
734 | 734 | |
|
735 | 735 | status = LFR_SUCCESSFUL; |
|
736 | 736 | |
|
737 | 737 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
738 | 738 | |
|
739 | 739 | return status; |
|
740 | 740 | } |
|
741 | 741 | |
|
742 | 742 | //********************* |
|
743 | 743 | // SBM1 MODE PARAMETERS |
|
744 | 744 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
745 | 745 | { |
|
746 | 746 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
747 | 747 | * |
|
748 | 748 | * @param TC points to the TeleCommand packet that is being processed |
|
749 | 749 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
750 | 750 | * |
|
751 | 751 | */ |
|
752 | 752 | |
|
753 | 753 | int status; |
|
754 | 754 | |
|
755 | 755 | status = LFR_SUCCESSFUL; |
|
756 | 756 | |
|
757 | 757 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
758 | 758 | |
|
759 | 759 | return status; |
|
760 | 760 | } |
|
761 | 761 | |
|
762 | 762 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
763 | 763 | { |
|
764 | 764 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
765 | 765 | * |
|
766 | 766 | * @param TC points to the TeleCommand packet that is being processed |
|
767 | 767 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
768 | 768 | * |
|
769 | 769 | */ |
|
770 | 770 | |
|
771 | 771 | int status; |
|
772 | 772 | |
|
773 | 773 | status = LFR_SUCCESSFUL; |
|
774 | 774 | |
|
775 | 775 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
776 | 776 | |
|
777 | 777 | return status; |
|
778 | 778 | } |
|
779 | 779 | |
|
780 | 780 | //********************* |
|
781 | 781 | // SBM2 MODE PARAMETERS |
|
782 | 782 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
783 | 783 | { |
|
784 | 784 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
785 | 785 | * |
|
786 | 786 | * @param TC points to the TeleCommand packet that is being processed |
|
787 | 787 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
788 | 788 | * |
|
789 | 789 | */ |
|
790 | 790 | |
|
791 | 791 | int status; |
|
792 | 792 | |
|
793 | 793 | status = LFR_SUCCESSFUL; |
|
794 | 794 | |
|
795 | 795 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
796 | 796 | |
|
797 | 797 | return status; |
|
798 | 798 | } |
|
799 | 799 | |
|
800 | 800 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
801 | 801 | { |
|
802 | 802 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
803 | 803 | * |
|
804 | 804 | * @param TC points to the TeleCommand packet that is being processed |
|
805 | 805 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
806 | 806 | * |
|
807 | 807 | */ |
|
808 | 808 | |
|
809 | 809 | int status; |
|
810 | 810 | |
|
811 | 811 | status = LFR_SUCCESSFUL; |
|
812 | 812 | |
|
813 | 813 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
814 | 814 | |
|
815 | 815 | return status; |
|
816 | 816 | } |
|
817 | 817 | |
|
818 | 818 | //******************* |
|
819 | 819 | // TC_LFR_UPDATE_INFO |
|
820 | 820 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
821 | 821 | { |
|
822 | 822 | unsigned int status; |
|
823 | 823 | |
|
824 | 824 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
825 | 825 | || (mode == LFR_MODE_BURST) |
|
826 | 826 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
827 | 827 | { |
|
828 | 828 | status = LFR_SUCCESSFUL; |
|
829 | 829 | } |
|
830 | 830 | else |
|
831 | 831 | { |
|
832 | 832 | status = LFR_DEFAULT; |
|
833 | 833 | } |
|
834 | 834 | |
|
835 | 835 | return status; |
|
836 | 836 | } |
|
837 | 837 | |
|
838 | 838 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
839 | 839 | { |
|
840 | 840 | unsigned int status; |
|
841 | 841 | |
|
842 | 842 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
843 | 843 | || (mode == TDS_MODE_BURST) |
|
844 | 844 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
845 | 845 | || (mode == TDS_MODE_LFM)) |
|
846 | 846 | { |
|
847 | 847 | status = LFR_SUCCESSFUL; |
|
848 | 848 | } |
|
849 | 849 | else |
|
850 | 850 | { |
|
851 | 851 | status = LFR_DEFAULT; |
|
852 | 852 | } |
|
853 | 853 | |
|
854 | 854 | return status; |
|
855 | 855 | } |
|
856 | 856 | |
|
857 | 857 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
858 | 858 | { |
|
859 | 859 | unsigned int status; |
|
860 | 860 | |
|
861 | 861 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
862 | 862 | || (mode == THR_MODE_BURST)) |
|
863 | 863 | { |
|
864 | 864 | status = LFR_SUCCESSFUL; |
|
865 | 865 | } |
|
866 | 866 | else |
|
867 | 867 | { |
|
868 | 868 | status = LFR_DEFAULT; |
|
869 | 869 | } |
|
870 | 870 | |
|
871 | 871 | return status; |
|
872 | 872 | } |
|
873 | 873 | |
|
874 | 874 | //*********** |
|
875 | 875 | // FBINS MASK |
|
876 | 876 | |
|
877 | 877 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
878 | 878 | { |
|
879 | 879 | int status; |
|
880 | 880 | unsigned int k; |
|
881 | 881 | unsigned char *fbins_mask_dump; |
|
882 | 882 | unsigned char *fbins_mask_TC; |
|
883 | 883 | |
|
884 | 884 | status = LFR_SUCCESSFUL; |
|
885 | 885 | |
|
886 | 886 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
887 | 887 | fbins_mask_TC = TC->dataAndCRC; |
|
888 | 888 | |
|
889 | 889 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
890 | 890 | { |
|
891 | 891 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
892 | 892 | } |
|
893 | 893 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
894 | 894 | { |
|
895 | 895 | unsigned char *auxPtr; |
|
896 | 896 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
897 | 897 | printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]); |
|
898 | 898 | } |
|
899 | 899 | |
|
900 | 900 | |
|
901 | 901 | return status; |
|
902 | 902 | } |
|
903 | 903 | |
|
904 | 904 | //************** |
|
905 | 905 | // KCOEFFICIENTS |
|
906 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC ) | |
|
906 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
|
907 | 907 | { |
|
908 | 908 | unsigned int i; |
|
909 | 909 | unsigned short sy_lfr_kcoeff_frequency; |
|
910 | 910 | unsigned short bin; |
|
911 | 911 | unsigned short *freqPtr; |
|
912 | 912 | float *kcoeffPtr_norm; |
|
913 | 913 | float *kcoeffPtr_sbm; |
|
914 | 914 | int status; |
|
915 | 915 | unsigned char *kcoeffLoadPtr; |
|
916 | 916 | unsigned char *kcoeffNormPtr; |
|
917 | 917 | unsigned char *kcoeffSbmPtr_a; |
|
918 | 918 | unsigned char *kcoeffSbmPtr_b; |
|
919 | 919 | |
|
920 | 920 | status = LFR_SUCCESSFUL; |
|
921 | 921 | |
|
922 | 922 | kcoeffPtr_norm = NULL; |
|
923 | 923 | kcoeffPtr_sbm = NULL; |
|
924 | 924 | bin = 0; |
|
925 | 925 | |
|
926 | 926 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
927 | 927 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
928 | 928 | |
|
929 | 929 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
930 | 930 | { |
|
931 | 931 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
932 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10, | |
|
933 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); | |
|
934 | status = LFR_DEFAULT; | |
|
932 | 935 | } |
|
933 | 936 | else |
|
934 | 937 | { |
|
935 | 938 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
936 | 939 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
937 | 940 | { |
|
938 | 941 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
939 | 942 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
940 | 943 | bin = sy_lfr_kcoeff_frequency; |
|
941 | 944 | } |
|
942 | 945 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
943 | 946 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
944 | 947 | { |
|
945 | 948 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
946 | 949 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
947 | 950 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
948 | 951 | } |
|
949 | 952 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
950 | 953 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
951 | 954 | { |
|
952 | 955 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
953 | 956 | kcoeffPtr_sbm = NULL; |
|
954 | 957 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
955 | 958 | } |
|
956 | 959 | } |
|
957 | 960 | |
|
958 | 961 | printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin); |
|
959 | 962 | |
|
960 | 963 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
961 | 964 | { |
|
962 | 965 | for (i=0; i<NB_K_COEFF_PER_BIN; i++) |
|
963 | 966 | { |
|
964 | 967 | // destination |
|
965 | 968 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + i ]; |
|
966 | 969 | // source |
|
967 | 970 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * i]; |
|
968 | 971 | // copy source to destination |
|
969 | 972 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
970 | 973 | } |
|
971 | 974 | } |
|
972 | 975 | |
|
973 | 976 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
974 | 977 | { |
|
975 | 978 | for (i=0; i<NB_K_COEFF_PER_BIN; i++) |
|
976 | 979 | { |
|
977 | 980 | // destination |
|
978 | 981 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 ]; |
|
979 | 982 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + i) * 2 + 1 ]; |
|
980 | 983 | // source |
|
981 | 984 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * i]; |
|
982 | 985 | // copy source to destination |
|
983 | 986 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
984 | 987 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
985 | 988 | } |
|
986 | 989 | } |
|
987 | 990 | |
|
988 | 991 | return status; |
|
989 | 992 | } |
|
990 | 993 | |
|
991 | 994 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
992 | 995 | { |
|
993 | 996 | destination[0] = source[0]; |
|
994 | 997 | destination[1] = source[1]; |
|
995 | 998 | destination[2] = source[2]; |
|
996 | 999 | destination[3] = source[3]; |
|
997 | 1000 | } |
|
998 | 1001 | |
|
999 | 1002 | //********** |
|
1000 | 1003 | // init dump |
|
1001 | 1004 | |
|
1002 | 1005 | void init_parameter_dump( void ) |
|
1003 | 1006 | { |
|
1004 | 1007 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1005 | 1008 | * |
|
1006 | 1009 | */ |
|
1007 | 1010 | |
|
1008 | 1011 | unsigned int k; |
|
1009 | 1012 | |
|
1010 | 1013 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1011 | 1014 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1012 | 1015 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1013 | 1016 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1014 | 1017 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1015 | 1018 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1016 | 1019 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1017 | 1020 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1018 | 1021 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1019 | 1022 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1020 | 1023 | // DATA FIELD HEADER |
|
1021 | 1024 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1022 | 1025 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1023 | 1026 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1024 | 1027 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1025 | 1028 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1026 | 1029 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1027 | 1030 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1028 | 1031 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1029 | 1032 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1030 | 1033 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1031 | 1034 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1032 | 1035 | |
|
1033 | 1036 | //****************** |
|
1034 | 1037 | // COMMON PARAMETERS |
|
1035 | 1038 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1036 | 1039 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1037 | 1040 | |
|
1038 | 1041 | //****************** |
|
1039 | 1042 | // NORMAL PARAMETERS |
|
1040 | 1043 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1041 | 1044 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1042 | 1045 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1043 | 1046 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1044 | 1047 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1045 | 1048 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1046 | 1049 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1047 | 1050 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1048 | 1051 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1049 | 1052 | |
|
1050 | 1053 | //***************** |
|
1051 | 1054 | // BURST PARAMETERS |
|
1052 | 1055 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1053 | 1056 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1054 | 1057 | |
|
1055 | 1058 | //**************** |
|
1056 | 1059 | // SBM1 PARAMETERS |
|
1057 | 1060 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
1058 | 1061 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1059 | 1062 | |
|
1060 | 1063 | //**************** |
|
1061 | 1064 | // SBM2 PARAMETERS |
|
1062 | 1065 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1063 | 1066 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1064 | 1067 | |
|
1065 | 1068 | //************ |
|
1066 | 1069 | // FBINS MASKS |
|
1067 | 1070 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1068 | 1071 | { |
|
1069 | 1072 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1070 | 1073 | } |
|
1071 | 1074 | } |
|
1072 | 1075 | |
|
1073 | 1076 | void init_kcoefficients_dump( void ) |
|
1074 | 1077 | { |
|
1075 | 1078 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1076 | 1079 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1077 | 1080 | |
|
1078 | 1081 | kcoefficient_node_1.previous = NULL; |
|
1079 | 1082 | kcoefficient_node_1.next = NULL; |
|
1080 | 1083 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1081 | 1084 | kcoefficient_node_1.coarseTime = 0x00; |
|
1082 | 1085 | kcoefficient_node_1.fineTime = 0x00; |
|
1083 | 1086 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1084 | 1087 | kcoefficient_node_1.status = 0x00; |
|
1085 | 1088 | |
|
1086 | 1089 | kcoefficient_node_2.previous = NULL; |
|
1087 | 1090 | kcoefficient_node_2.next = NULL; |
|
1088 | 1091 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1089 | 1092 | kcoefficient_node_2.coarseTime = 0x00; |
|
1090 | 1093 | kcoefficient_node_2.fineTime = 0x00; |
|
1091 | 1094 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1092 | 1095 | kcoefficient_node_2.status = 0x00; |
|
1093 | 1096 | } |
|
1094 | 1097 | |
|
1095 | 1098 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1096 | 1099 | { |
|
1097 | 1100 | unsigned int k; |
|
1098 | 1101 | unsigned int packetLength; |
|
1099 | 1102 | |
|
1100 | 1103 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1101 | 1104 | |
|
1102 | 1105 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1103 | 1106 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1104 | 1107 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1105 | 1108 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1106 | 1109 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1107 | 1110 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1108 | 1111 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1109 | 1112 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1110 | 1113 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1111 | 1114 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1112 | 1115 | // DATA FIELD HEADER |
|
1113 | 1116 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1114 | 1117 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1115 | 1118 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1116 | 1119 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1117 | 1120 | kcoefficients_dump->time[0] = 0x00; |
|
1118 | 1121 | kcoefficients_dump->time[1] = 0x00; |
|
1119 | 1122 | kcoefficients_dump->time[2] = 0x00; |
|
1120 | 1123 | kcoefficients_dump->time[3] = 0x00; |
|
1121 | 1124 | kcoefficients_dump->time[4] = 0x00; |
|
1122 | 1125 | kcoefficients_dump->time[5] = 0x00; |
|
1123 | 1126 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1124 | 1127 | |
|
1125 | 1128 | kcoefficients_dump->pkt_cnt = 2; |
|
1126 | 1129 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1127 | 1130 | kcoefficients_dump->blk_nr = blk_nr; |
|
1128 | 1131 | |
|
1129 | 1132 | //****************** |
|
1130 | 1133 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1131 | 1134 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1132 | 1135 | for (k=0; k<3900; k++) |
|
1133 | 1136 | { |
|
1134 | 1137 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1135 | 1138 | } |
|
1136 | 1139 | } |
|
1137 | 1140 | |
|
1138 | 1141 | |
|
1139 | 1142 |
General Comments 0
You need to be logged in to leave comments.
Login now