This diff has been collapsed as it changes many lines, (681 lines changed) Show them Hide them | |||||
@@ -0,0 +1,681 | |||||
|
1 | #! /usr/bin/tclsh | |||
|
2 | # | |||
|
3 | # TCL script to scan disassembled programs against the "LEON3FT Stale Cache | |||
|
4 | # Entry After Store with Data Tag Parity Error" errata, GRLIB-TN-0009. | |||
|
5 | # | |||
|
6 | # The following Cobham components are affected by GRLIB-TN-0009: | |||
|
7 | # - GR712RC | |||
|
8 | # - LEON3FT-RTAX (all versions) | |||
|
9 | # - UT699 | |||
|
10 | # - UT699E | |||
|
11 | # - UT700 | |||
|
12 | # | |||
|
13 | # For information on how custom LEON3 systems may be affected, see | |||
|
14 | # GRLIB-TN-0009. | |||
|
15 | # | |||
|
16 | # Copyright (C) 2016, Cobham Gaisler | |||
|
17 | # | |||
|
18 | # Usage: sparc-elf-objdump -d program | leon3ft-b2bst-scan.tcl | |||
|
19 | # | |||
|
20 | # Command line parameters: | |||
|
21 | # -nonote: Do not print NOTE messages. | |||
|
22 | # -noinfo: Do not print INFO messages. | |||
|
23 | # -silent: Do not print NOTE or INFO messages. | |||
|
24 | # | |||
|
25 | # Return values: | |||
|
26 | # 0: No potential error locations found. | |||
|
27 | # 1: At least one potential error location found. | |||
|
28 | # | |||
|
29 | # Rev. history: | |||
|
30 | # rev 1, MH, Initial revision, based on ut699scan.tcl. Add scanning for | |||
|
31 | # store-store errata, reorganize comments | |||
|
32 | # rev 2, MA, Restruction and clean-up, fixed Sequence B. | |||
|
33 | # rev 3, MA, Added decoding of casa instruction, exit status and verbosity | |||
|
34 | # parameters. | |||
|
35 | # rev 4, MA, Reduced false warnings due to Store into Alternate space | |||
|
36 | # instructions which can not trig the errata. Script renamed to | |||
|
37 | # leon3ft-b2bst-scan.tcl. | |||
|
38 | # | |||
|
39 | # Note 1: Two modes are available with respect to call/ret (dslot_mode): | |||
|
40 | # 1) ret, and call are assumed not to have stores in their delay slots. | |||
|
41 | # The tool will warn if any such operations are found in the delay | |||
|
42 | # slot of ret,call during the scan | |||
|
43 | # 0) ret and call may have stores in their delay slots | |||
|
44 | # The tool will not warn if any such operations are found in the | |||
|
45 | # delay slot during the scan. Instead it will assume this | |||
|
46 | # possibility exists when evaluating insns following a function call | |||
|
47 | # | |||
|
48 | ||||
|
49 | ### CONFIGURATION | |||
|
50 | set b2bst_seqa_scan 1; # enable/disable scanning for Sequence A | |||
|
51 | set b2bst_seqb_scan 1; # enable/disable scanning for Sequence B | |||
|
52 | # set dslot_mode 0; # assume store can be in delay slot of call,jmpl | |||
|
53 | set dslot_mode 1; # do not allow store in delay slot of call,jmpl | |||
|
54 | ### | |||
|
55 | ||||
|
56 | # Mask values for types of output messages | |||
|
57 | set MSG_INFO 1; # Information on things to check manually. | |||
|
58 | set MSG_NOTE 2; # Notices on branch following | |||
|
59 | set msglevel [expr {$MSG_INFO | $MSG_NOTE}] | |||
|
60 | ||||
|
61 | set errata_desc "LEON3FT Stale Cache Entry After Store with Data Tag Parity Error" | |||
|
62 | set util_rev 4 | |||
|
63 | set util_date "20170215" | |||
|
64 | ||||
|
65 | set b2bst_seqa_desc "Sequence A" | |||
|
66 | set b2bst_seqb_desc "Sequence B" | |||
|
67 | ||||
|
68 | set op_count 0 | |||
|
69 | set lineskip_count 0 | |||
|
70 | set line_count 0 | |||
|
71 | set err_count 0 | |||
|
72 | set fn_count 0 | |||
|
73 | set fninst_count 0 | |||
|
74 | ||||
|
75 | proc puts_info {str} { | |||
|
76 | global msglevel MSG_INFO | |||
|
77 | if {$msglevel & $MSG_INFO} { puts "INFO: $str" } | |||
|
78 | } | |||
|
79 | ||||
|
80 | proc puts_note {str} { | |||
|
81 | global msglevel MSG_NOTE | |||
|
82 | if {$msglevel & $MSG_NOTE} { puts "NOTE: $str" } | |||
|
83 | } | |||
|
84 | ||||
|
85 | # ---------------------------------------------------------------------------- | |||
|
86 | # Routine that decodes specified opcode and returns list of | |||
|
87 | # 0 :optype Class of opcode | |||
|
88 | # one of call,jmpl,branch,sethi,ld,st,atomic,alu,fpop,save,restore | |||
|
89 | # 1 :target-reg Register modified by op | |||
|
90 | # 2 :source-reg1 First source register (rs1) | |||
|
91 | # 3 :source-reg2 Second source register (rs2) | |||
|
92 | # 4 :store-reg Source register for store data | |||
|
93 | # regs are numbered 0-31 integer regs, 32-63 FP regs | |||
|
94 | # 5 :double-flag | |||
|
95 | # ORed mask: 8) target-reg is DP, 4) sreg1 is DP, 2) sreg2 is DP, 1) store-reg is DP | |||
|
96 | # 6 :immed Immediate operand | |||
|
97 | # 7 :nnpc1 Next instructions nPC if branch not taken (normal case), normally nPC+4 | |||
|
98 | # 8 :nnpc2 Next instruction's nPC if branch is taken, if not branch then nnpc2=nnpc1 | |||
|
99 | # 9 :annul | |||
|
100 | # ORed mask: next inst annulled if 2) branch not taken 1) branch taken | |||
|
101 | # 10:bubbles Number of extra cycles spent in decode stage (bubbles inserted) | |||
|
102 | proc decode_inst { opcode {pc "0x00000000"} {npc "0x00000004"}} { | |||
|
103 | # Some "sta" instructions do not trig the errata. The related ASI:s are | |||
|
104 | # defined here. | |||
|
105 | set safeasi [list 0x02 0x03 0x04 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x13 0x14 0x15 0x18 0x19 0x1c 0x1d 0x1e] | |||
|
106 | #Default values if no cond matches | |||
|
107 | set opname "unknown" | |||
|
108 | set destreg 0 | |||
|
109 | set sreg1 0 | |||
|
110 | set sreg2 0 | |||
|
111 | set streg 0 | |||
|
112 | set dblflag 0 | |||
|
113 | set immed 0 | |||
|
114 | ||||
|
115 | if { [string is integer $npc] } { | |||
|
116 | set nnpc1 [format "0x%08x" [ expr {$npc+4} ] ] | |||
|
117 | } else { | |||
|
118 | set nnpc1 "$npc+4" | |||
|
119 | } | |||
|
120 | set nnpc2 $nnpc1 | |||
|
121 | set annul 0 | |||
|
122 | set bubbles 0 | |||
|
123 | #Decode | |||
|
124 | set op1 [ expr {$opcode >> 30} ] | |||
|
125 | if { $op1 == 1 } { | |||
|
126 | set opname "call" | |||
|
127 | set disp [ expr { ($opcode & 0x3fffffff)<<2 } ] | |||
|
128 | set nnpc1 [ format "0x%08x" [ expr { $pc + $disp } ] ] | |||
|
129 | set nnpc2 $nnpc1 | |||
|
130 | } elseif { $op1 == 0 } { | |||
|
131 | set op2 [ expr {($opcode >> 22) & 7} ] | |||
|
132 | # NOTE: 2=Bicc, 6=FBcc, 7=CBcc | |||
|
133 | if { $op2 == 2 || $op2 == 6 } { | |||
|
134 | set opname "branch" | |||
|
135 | set disp [expr { ($opcode & 0x3fffff) << 2 } ] | |||
|
136 | if { $disp > 0x800000 } { set disp [expr {$disp - 0x1000000}] } | |||
|
137 | # Todo check cond,annul, handle always or never | |||
|
138 | set nnpc2 [ format "0x%08x" [ expr { $pc + $disp } ] ] | |||
|
139 | set cond [ expr { ($opcode >> 25) & 15 } ] | |||
|
140 | set annulbit [ expr { $opcode & 0x20000000 } ] | |||
|
141 | if { $cond == 0 } { # Branch never | |||
|
142 | set nnpc2 $nnpc1 | |||
|
143 | if { $annulbit } { set annul 3 } | |||
|
144 | } elseif { $cond == 8 } { # Branch always | |||
|
145 | set nnpc1 $nnpc2 | |||
|
146 | if { $annulbit } { set annul 3 } | |||
|
147 | } else { # True cond branch | |||
|
148 | if { $annulbit } { set annul 2 } | |||
|
149 | } | |||
|
150 | } elseif { $op2 == 4 } { | |||
|
151 | set opname "sethi" | |||
|
152 | set destreg [ expr { ($opcode >> 25) & 31 } ] | |||
|
153 | set immed [ expr { ($opcode & 0x3fffff) << 10 } ] | |||
|
154 | } | |||
|
155 | } elseif { $op1 == 3 } { | |||
|
156 | # SPARC V8 Table F-4 | |||
|
157 | # set opname "mem" - changed to use ld/st/atomic instead | |||
|
158 | set op3 [ expr { ($opcode >> 19) & 63 } ] | |||
|
159 | set rs1 [ expr { (($opcode >> 14) & 31) } ] | |||
|
160 | set rs2 [ expr { (($opcode ) & 31) } ] | |||
|
161 | set rd [ expr { (($opcode >> 25) & 31) } ] | |||
|
162 | set sreg1 $rs1 | |||
|
163 | if { $opcode & 0x2000 } { | |||
|
164 | set immed [ expr { $opcode & 0x1fff } ] | |||
|
165 | if { $immed > 0xfff } { set immed [ expr { $immed-(0x2000) } ] } | |||
|
166 | } else { | |||
|
167 | set sreg2 $rs2 | |||
|
168 | } | |||
|
169 | if { (($op3 & 13) == 13) || ($op3 == 0x3c) } { | |||
|
170 | # Atomic ldst/swap/casa | |||
|
171 | set opname "atomic" | |||
|
172 | set destreg $rd | |||
|
173 | set streg $rd | |||
|
174 | } else { | |||
|
175 | # Adjust reg no if FP ld/st (op3[5]=1) | |||
|
176 | if { ($op3 & 0x20) != 0 } { set rd [expr {32 + $rd} ] } | |||
|
177 | # Check if read or write op3[2] | |||
|
178 | if { ($op3 & 4) != 0 } { | |||
|
179 | set opname "st" | |||
|
180 | set streg $rd | |||
|
181 | set allow_safe_sta true | |||
|
182 | if { $allow_safe_sta && (($op3 & 0x3c) == 0x14) } { | |||
|
183 | # op3 is 0x14, 0x15, 0x16 or 0x17 (sta, stba, stha or stda) | |||
|
184 | # (if i = 0) | |||
|
185 | set asi [expr { (($opcode >> 5) & 0xff) }] | |||
|
186 | set safematch [lsearch -exact -integer $safeasi $asi] | |||
|
187 | if {0 <= $safematch} { | |||
|
188 | set opname "sta_safe" | |||
|
189 | } | |||
|
190 | } | |||
|
191 | } else { | |||
|
192 | set opname "ld" | |||
|
193 | set destreg $rd | |||
|
194 | } | |||
|
195 | # Check size op3[1:0] | |||
|
196 | if { ($op3 & 3) == 3 } { | |||
|
197 | if { $opname eq "st" } { set dblflag 1 } else { set dblflag 8 } | |||
|
198 | } | |||
|
199 | } | |||
|
200 | } else { | |||
|
201 | set op3 [ expr { ($opcode >> 19) & 63 } ] | |||
|
202 | if { $op3 == 0x34 || $op3 == 0x35 } { | |||
|
203 | set opname "fpop" | |||
|
204 | set opf [ expr { ($opcode >> 5) & 0x1ff } ] | |||
|
205 | set rs1 [ expr { 32 + (($opcode >> 14) & 31) } ] | |||
|
206 | set rs2 [ expr { 32 + (($opcode ) & 31) } ] | |||
|
207 | set rd [ expr { 32 + (($opcode >> 25) & 31) } ] | |||
|
208 | # opf[1:0] corresponds to operand size of rs2 | |||
|
209 | # opf[7:6]=11 is conv op, opf[3:2] gives opsize of rd, rs1 unused | |||
|
210 | # opf[7:6]=00 is single-operand op, rd same size as rs2, rs1 unused | |||
|
211 | # opf[7:4]=0100 regular op, rs1,rd same size as rs2 | |||
|
212 | # opf[7:4]=0101 comp op, rd unused, rs1 same size as rs2 | |||
|
213 | # opf[7:4]=0110 conv+mul, opf[3:2] gives opsize of rd, rs1 same size as rs2 | |||
|
214 | set sreg2 $rs2 | |||
|
215 | if { ($opf & 3) > 1 } { set dblflag 2 } | |||
|
216 | if { ($opf & 0xc0) == 0x40 } { | |||
|
217 | set sreg1 $rs1 | |||
|
218 | if { $dblflag & 2 } { set dblflag [ expr { $dblflag | 4 } ] } | |||
|
219 | } | |||
|
220 | if { ($opf & 0xc0) == 0xc0 || ($opf & 0xf0) == 0x60 } { | |||
|
221 | set destreg $rd | |||
|
222 | if { ($opf & 0xc) > 4 } { set dblflag [ expr { $dblflag | 8 } ] } | |||
|
223 | } elseif { ($opf & 0xf0) != 0x50 } { | |||
|
224 | set destreg $rd | |||
|
225 | if { $dblflag & 2 } { set dblflag [ expr { $dblflag | 8 } ] } | |||
|
226 | } | |||
|
227 | } else { | |||
|
228 | set opname "alu" | |||
|
229 | set destreg [ expr { (($opcode >> 25) & 31) } ] | |||
|
230 | set sreg1 [ expr { (($opcode >> 14) & 31) } ] | |||
|
231 | if { $opcode & 0x2000 } { | |||
|
232 | set immed [ expr { $opcode & 0x1fff } ] | |||
|
233 | if { $immed > 0xfff } { set immed [ expr { $immed-(0x2000) } ] } | |||
|
234 | } else { | |||
|
235 | set sreg2 [ expr { (($opcode ) & 31) } ] | |||
|
236 | } | |||
|
237 | if { $op3 == 0x38 } { | |||
|
238 | set opname "jmpl" | |||
|
239 | set nnpc1 "jmpaddr" | |||
|
240 | set nnpc2 "jmpaddr" | |||
|
241 | set bubbles 2 | |||
|
242 | } elseif { $op3 == 0x3c } { | |||
|
243 | set opname "save" | |||
|
244 | } elseif { $op3 == 0x3d } { | |||
|
245 | set opname "restore" | |||
|
246 | } | |||
|
247 | } | |||
|
248 | } | |||
|
249 | #Return values | |||
|
250 | return [list $opname $destreg $sreg1 $sreg2 $streg $dblflag $immed $nnpc1 $nnpc2 $annul $bubbles] | |||
|
251 | } | |||
|
252 | ||||
|
253 | proc is_store { opcode } { | |||
|
254 | set op1 [ expr { ($opcode >> 30) } ] | |||
|
255 | set op3 [ expr { ($opcode >> 19) & 63 } ] | |||
|
256 | return [expr {($op1 == 3) && (($op3 & 0xc) == 0x4)}] | |||
|
257 | } | |||
|
258 | ||||
|
259 | # ------------------------------------------------------------------------------------- | |||
|
260 | ||||
|
261 | proc unpack { l args } { | |||
|
262 | for { set i 0 } { $i < [llength $args] } { incr i } { | |||
|
263 | uplevel 1 "set [lindex $args $i] [lindex $l $i]" | |||
|
264 | } | |||
|
265 | } | |||
|
266 | ||||
|
267 | # --------- Postprocessing on whole function | |||
|
268 | ||||
|
269 | # Number of instructions printed is starti + 2 | |||
|
270 | proc print_trace { fnpc state fnarr seqstart {starti 4}} { | |||
|
271 | upvar $fnarr fnops | |||
|
272 | ||||
|
273 | puts " # PC Opcode" | |||
|
274 | set cnt [expr {$seqstart-$starti}] | |||
|
275 | for { set x $starti } { $x > -2 } { set x [expr {$x-1}] } { | |||
|
276 | incr cnt | |||
|
277 | if { $cnt > 0 } { set cntv $cnt } else { set cntv " " } | |||
|
278 | if { $x >= 0 } { set pc [lindex $state $x] } else { set pc $fnpc } | |||
|
279 | if { $pc eq "?" || $pc eq "call" || $pc eq "ret" || $pc eq "dslot" } { | |||
|
280 | puts " $cntv (other fn) $pc" | |||
|
281 | } else { | |||
|
282 | if { [string index $pc 0] eq "A" } { | |||
|
283 | set pc [string range $pc 1 end] | |||
|
284 | set annul " (annulled)" | |||
|
285 | } else { | |||
|
286 | set annul "" | |||
|
287 | } | |||
|
288 | if { [info exists fnops($pc)] } { | |||
|
289 | set op $fnops($pc) | |||
|
290 | } else { | |||
|
291 | set op [list "0x???????? (outside func)"] | |||
|
292 | } | |||
|
293 | puts " $cntv $pc [join $op] $annul" | |||
|
294 | } | |||
|
295 | } | |||
|
296 | puts "" | |||
|
297 | } | |||
|
298 | ||||
|
299 | # Routine called by scan_wholefunc_main to check | |||
|
300 | # instruction sequences described in GRLIB-TN-009, Issue 1.0 | |||
|
301 | # | |||
|
302 | # "Sequence A" | |||
|
303 | # 1. store of word size or less (st / stb / sth / stf) | |||
|
304 | # 2. any single instruction that is not a load or store | |||
|
305 | # 3. any store instruction (st / stb / sth / stf / std / stdf) | |||
|
306 | # | |||
|
307 | # "Sequence B" | |||
|
308 | # 1. store of double word size (std / stdf) | |||
|
309 | # 2. any store instruction (st / stb / sth / stf / std / stdf) | |||
|
310 | proc scan_b2bst { fnname fnpc fnop opdec fnarr state } { | |||
|
311 | global b2bst_seqa_scan | |||
|
312 | global b2bst_seqb_scan | |||
|
313 | upvar $fnarr fnops | |||
|
314 | global dslot_mode | |||
|
315 | ||||
|
316 | # Check latest 3 insn if they can be st/std/regular | |||
|
317 | set pca [list $fnpc [lindex $state 0] [lindex $state 1]] | |||
|
318 | set can_be_arr [list] | |||
|
319 | for { set i 0 } { $i < 3 } { incr i } { | |||
|
320 | set can_be [list 0 0 0] ; # st std regular | |||
|
321 | set pcv [lindex $pca $i] | |||
|
322 | if { $pcv eq "?" } { | |||
|
323 | set can_be [list 1 1 1] | |||
|
324 | } elseif { $pcv eq "dslot" } { | |||
|
325 | set can_be [list [expr {1-$dslot_mode}] [expr {1-$dslot_mode}] 1] | |||
|
326 | } elseif { [string index $pcv 0] eq "A" || $pcv eq "call" || $pcv eq "ret" } { | |||
|
327 | set can_be [list 0 0 1] | |||
|
328 | } else { | |||
|
329 | set op $fnops($pcv) | |||
|
330 | set ophex [lindex $op 0] | |||
|
331 | set opdec [decode_inst $ophex] | |||
|
332 | set optype [lindex $opdec 0] | |||
|
333 | set opstorereg [lindex $opdec 4] | |||
|
334 | set opdblflag [lindex $opdec 5] | |||
|
335 | if { $optype eq "st" && ($opdblflag & 1) } { | |||
|
336 | set can_be [list 0 1 0] | |||
|
337 | } elseif { $optype eq "st" } { | |||
|
338 | set can_be [list 1 0 0] | |||
|
339 | } elseif { $optype ne "ld" && $optype ne "atomic" } { | |||
|
340 | # Any single instruction that is not a load or store | |||
|
341 | set can_be [list 0 0 1] | |||
|
342 | } | |||
|
343 | } | |||
|
344 | lappend can_be_arr $can_be | |||
|
345 | } | |||
|
346 | # can_be_arr has at index | |||
|
347 | # - at index 2: previous previous instruction | |||
|
348 | # - at index 1: previous instruction | |||
|
349 | # - at index 0: current instruction | |||
|
350 | set pp_insn [lindex $can_be_arr 2] | |||
|
351 | set p_insn [lindex $can_be_arr 1] | |||
|
352 | set c_insn [lindex $can_be_arr 0] | |||
|
353 | # Sequence A | |||
|
354 | # 1. store of word size or less | |||
|
355 | # 2. any single instruction that is not a load or store | |||
|
356 | # 3. any store instruction | |||
|
357 | if { | |||
|
358 | ( | |||
|
359 | $b2bst_seqa_scan && | |||
|
360 | [lindex $pp_insn 0] && | |||
|
361 | [lindex $p_insn 2] && | |||
|
362 | ([lindex $c_insn 0] || [lindex $c_insn 1]) | |||
|
363 | ) } { | |||
|
364 | puts "WARNING: Possible sequence matching LEON3FT b2bst errata (sequence A) in function $fnname" | |||
|
365 | print_trace $fnpc $state fnops 1 | |||
|
366 | puts "" | |||
|
367 | return 1 | |||
|
368 | } | |||
|
369 | ||||
|
370 | # Sequence B | |||
|
371 | # 1. any store instruction | |||
|
372 | # 2. store of double word size | |||
|
373 | if { | |||
|
374 | ( | |||
|
375 | $b2bst_seqb_scan && | |||
|
376 | [lindex $p_insn 1] && | |||
|
377 | ([lindex $c_insn 0] || [lindex $c_insn 1]) | |||
|
378 | ) } { | |||
|
379 | puts "WARNING: Possible sequence matching LEON3FT b2bst errata (sequence B) in function $fnname" | |||
|
380 | print_trace $fnpc $state fnops 0 | |||
|
381 | puts "" | |||
|
382 | return 1 | |||
|
383 | } | |||
|
384 | return 0 | |||
|
385 | } | |||
|
386 | ||||
|
387 | ||||
|
388 | # Main recursive function doing scan | |||
|
389 | # fnname - funcion name | |||
|
390 | # fnpc, fnnpc, PC/nPC of current insn (8-digit hex, 0x prefix) prefix also with A if annulled, | |||
|
391 | # fnarr - array/hash-table, see descr for scan_wholefunc | |||
|
392 | # dpdist - number of SP FPOPs done minimum since last DP FPOP | |||
|
393 | # state - List of 5 last instruction addresses (hex w 0x prefix), special values "?"=unknown "call"=call from calling proc | |||
|
394 | # smap - Hash table used to track where we have been already | |||
|
395 | proc scan_wholefunc_main { fnname fnpc fnnpc fnarr savelevel dpdist state smap lastoptype } { | |||
|
396 | global dslot_mode | |||
|
397 | upvar $fnarr fnops | |||
|
398 | upvar $smap statemap | |||
|
399 | ||||
|
400 | set r 0 | |||
|
401 | ||||
|
402 | # puts "entering scan_wholefunc_main: PC:$fnpc nPC:$fnnpc dpdist:$dpdist savelevel:$savelevel state:$state" | |||
|
403 | # puts "fnops exists [info exists fnops] [array exists fnops] [array names fnops]" | |||
|
404 | while {1} { | |||
|
405 | # puts "scan_wholefunc_main: PC:$fnpc nPC:$fnnpc dpdist:$dpdist savelevel:$savelevel state:$state" | |||
|
406 | set statedesc [list $fnpc $fnnpc $savelevel $dpdist $state] | |||
|
407 | if { [info exists statemap($statedesc)] } { | |||
|
408 | # Already been here | |||
|
409 | return $r | |||
|
410 | } | |||
|
411 | set statemap($statedesc) 1 | |||
|
412 | ||||
|
413 | set fnpca $fnpc | |||
|
414 | set pcannul 0 | |||
|
415 | if { [string index $fnpc 0] eq "A" } { | |||
|
416 | set pcannul 1 | |||
|
417 | set fnpc [string range $fnpc 1 end] | |||
|
418 | set ophex "0x01000000" | |||
|
419 | } else { | |||
|
420 | if {![info exists fnops($fnpc)]} { | |||
|
421 | puts_note "$fnname: Execution leaves function without return"; | |||
|
422 | return $r | |||
|
423 | } | |||
|
424 | ||||
|
425 | set op $fnops($fnpc) | |||
|
426 | set ophex [lindex $op 0] | |||
|
427 | set opname [lindex $op 1] | |||
|
428 | } | |||
|
429 | ||||
|
430 | set opdec [ decode_inst $ophex $fnpc $fnnpc ] | |||
|
431 | unpack $opdec optype treg sreg1 sreg2 streg dblflag immed nnpc1 nnpc2 annul bubbles | |||
|
432 | ||||
|
433 | set prev_savelevel $savelevel | |||
|
434 | if { $optype eq "fpop" } { | |||
|
435 | # update dpdist | |||
|
436 | if { ($dblflag & 6) == 0 } { | |||
|
437 | if { $dpdist < 2 } { incr dpdist } | |||
|
438 | } else { | |||
|
439 | set dpdist 0 | |||
|
440 | } | |||
|
441 | } elseif { $optype eq "save" } { | |||
|
442 | if { $savelevel > 9 } { | |||
|
443 | puts_note "$fnname: More than 10 deep saves (possibly regfile clear loop)" | |||
|
444 | } else { | |||
|
445 | incr savelevel | |||
|
446 | } | |||
|
447 | # puts "save at $fnpc, new savelevel: $savelevel" | |||
|
448 | } elseif { $optype eq "restore" } { | |||
|
449 | if { $savelevel < -9 } { | |||
|
450 | puts_note "$fnname: More than 10 deep restores (possibly regfile clear loop)" | |||
|
451 | } else { | |||
|
452 | if { $savelevel == 0 } { | |||
|
453 | puts_note "$fnname: More restore than save instructions" | |||
|
454 | } | |||
|
455 | set savelevel [ expr { $savelevel-1} ] | |||
|
456 | } | |||
|
457 | # puts "restore at $fnpc, new savelevel: $savelevel" | |||
|
458 | } | |||
|
459 | if { true && ($optype eq "st") } { | |||
|
460 | if { [scan_b2bst $fnname $fnpc $op $opdec fnops $state] } { incr r } | |||
|
461 | } | |||
|
462 | ||||
|
463 | # Handle jmpl and call | |||
|
464 | # If in delay slot of jmpl: | |||
|
465 | # If ret or retl, stop recursing further | |||
|
466 | # If other jmpl, check savelevel if it will return or not | |||
|
467 | # If in delay slot of call, set dpdist to 0 (called proc may have done DP operation) | |||
|
468 | set is_call 0 | |||
|
469 | if { | |||
|
470 | ( | |||
|
471 | $dslot_mode != 0 && | |||
|
472 | ($lastoptype eq "branch" || $lastoptype eq "jmpl" || $lastoptype eq "call") | |||
|
473 | ) } { | |||
|
474 | if { $optype eq "st" } { | |||
|
475 | puts "WARNING: $fnname: $opname in delay slot of branch/call/ret at $fnpc may cause errata" | |||
|
476 | print_trace $fnpc $state fnops -1 1 | |||
|
477 | puts "" | |||
|
478 | incr r | |||
|
479 | } | |||
|
480 | } | |||
|
481 | if { $lastoptype eq "jmpl" } { | |||
|
482 | set linst [lindex $state 0] | |||
|
483 | set q $fnops($linst) | |||
|
484 | set qh [lindex $q 0] | |||
|
485 | set qdec [ decode_inst $qh $linst $fnpc ] | |||
|
486 | unpack $qdec qdtype qdtreg qdsreg1 qdsreg2 qdstreg qddblflag qdimmed qdnnpc1 qdnnpc2 qdannul | |||
|
487 | if { $qdtreg==15 && $prev_savelevel==1 && $savelevel==1 } { | |||
|
488 | # Function call via pointer | |||
|
489 | incr is_call | |||
|
490 | } elseif { $qdtreg==0 && $savelevel==0 } { | |||
|
491 | # Return or tail recursion | |||
|
492 | return $r | |||
|
493 | } else { | |||
|
494 | # Computed goto or some other non-standard construct | |||
|
495 | puts_info "$fnname: Unable to trace jmpl at $linst - check manually" | |||
|
496 | return $r | |||
|
497 | } | |||
|
498 | } elseif { $lastoptype eq "call" } { | |||
|
499 | if { $savelevel==0 && $prev_savelevel==1 } { | |||
|
500 | # call,restore tail recursion into other fn | |||
|
501 | return $r | |||
|
502 | } elseif { $savelevel==0 && $prev_savelevel==0 && $treg == 15 } { | |||
|
503 | puts_note "$fnname: Leaf tail recursion construct at $fnpc" | |||
|
504 | return $r | |||
|
505 | } else { | |||
|
506 | incr is_call | |||
|
507 | } | |||
|
508 | } | |||
|
509 | # Update history | |||
|
510 | for { set z 0 } { $z <= $bubbles } { incr z } { | |||
|
511 | set state [concat $fnpca [lrange $state 0 4] ] | |||
|
512 | } | |||
|
513 | if { $is_call } { | |||
|
514 | if { $optype eq "branch" || $optype eq "call" || $optype eq "jmpl" } { | |||
|
515 | puts_info "$fnname: jump in delay slot of call - check manually" | |||
|
516 | } | |||
|
517 | # Setup state after call has returned | |||
|
518 | set dpdist 0 | |||
|
519 | set state [list "dslot" "ret" "ret" "ret" "?" ] | |||
|
520 | set optype "?"; # for lastoptype | |||
|
521 | set fnnpc [ format "0x%08x" [expr {$fnpc+4}]] | |||
|
522 | set nnpc1 [ format "0x%08x" [expr {$fnpc+8}]] | |||
|
523 | set nnpc2 $nnpc1 | |||
|
524 | set annul 0 | |||
|
525 | } | |||
|
526 | # Handle annullment | |||
|
527 | if { ($annul & 2) != 0 } { set npc1 "A$fnnpc" } else { set npc1 $fnnpc } | |||
|
528 | if { ($annul & 1) != 0 } { set npc2 "A$fnnpc" } else { set npc2 $fnnpc } | |||
|
529 | # Recurse if multiple nPC:s, tail recurse for last element | |||
|
530 | if { $nnpc1 != $nnpc2 || $npc1 != $npc2 } { | |||
|
531 | # puts "Recursion nnpc:$nnpc2!" | |||
|
532 | set q [scan_wholefunc_main $fnname $npc1 $nnpc2 fnops $savelevel $dpdist $state statemap $optype] | |||
|
533 | set r [expr {$r+$q}] | |||
|
534 | } | |||
|
535 | set fnpc $npc1 | |||
|
536 | set fnnpc $nnpc1 | |||
|
537 | set lastoptype $optype | |||
|
538 | } | |||
|
539 | } | |||
|
540 | ||||
|
541 | # Whole function scan for "LEON3FT Stale Cache After Store with Data Tag Parity Error" errata | |||
|
542 | # fnname - function name, fnaddr - function addres | |||
|
543 | # fnarr - name of array/hash-table containing operations | |||
|
544 | # key to the array is the address as 8-digit hex number prefixed with 0x | |||
|
545 | # value is a list containing 0:opcode, 1:mnemonic, 2:args | |||
|
546 | proc scan_wholefunc { fnname fnaddr fnarr } { | |||
|
547 | global fn_count fninst_count; | |||
|
548 | upvar $fnarr fnops | |||
|
549 | ||||
|
550 | if { $fnname eq ".text" } { | |||
|
551 | puts "WARNING: The disassembled binary appears to be stripped, the script can not scan stripped binaries" | |||
|
552 | } | |||
|
553 | ||||
|
554 | # Does the fn not contain any store at all, then we can skip it | |||
|
555 | set sid [array startsearch fnops] | |||
|
556 | set found_st 0 | |||
|
557 | while { !$found_st } { | |||
|
558 | set op [array nextelement fnops $sid] | |||
|
559 | if { $op eq "" } { array donesearch fnops $sid; break } | |||
|
560 | set ophex [lindex $fnops($op) 0] | |||
|
561 | # puts "$ophex" | |||
|
562 | if { [is_store $ophex] } { incr found_st } | |||
|
563 | } | |||
|
564 | if { !$found_st } { | |||
|
565 | # puts "No store in $fnname!" | |||
|
566 | return 0 | |||
|
567 | } | |||
|
568 | ||||
|
569 | # -- Function contains store, proceed with scanning | |||
|
570 | # puts "Checking $fnname" | |||
|
571 | set pc "0x$fnaddr" | |||
|
572 | # puts "pc: $pc" | |||
|
573 | set npc [format "0x%08x" [expr {$pc+4}]] | |||
|
574 | array unset statemap | |||
|
575 | array set statemap "" | |||
|
576 | set ec [scan_wholefunc_main $fnname $pc $npc fnops 0 0 [list "dslot" "call" "?" "?" "?" "?"] statemap "?"] | |||
|
577 | # Update fn_count/fninst_count | |||
|
578 | incr fn_count | |||
|
579 | array unset itagchk | |||
|
580 | array set itagchk "" | |||
|
581 | set sid [array startsearch statemap] | |||
|
582 | while { [array anymore statemap $sid] } { | |||
|
583 | set x [array nextelement statemap $sid] | |||
|
584 | set iaddr [lindex $x 0] | |||
|
585 | # puts "iaddr: $iaddr" | |||
|
586 | if { [info exists fnops($iaddr)] && ![info exists itagchk($iaddr)]} { | |||
|
587 | incr fninst_count | |||
|
588 | set itagchk($iaddr) 1 | |||
|
589 | } | |||
|
590 | } | |||
|
591 | array donesearch statemap $sid | |||
|
592 | return $ec | |||
|
593 | } | |||
|
594 | ||||
|
595 | ||||
|
596 | # --------- Main routine | |||
|
597 | ||||
|
598 | if { ! [info exists sourcing] } { | |||
|
599 | ||||
|
600 | # Parse command line | |||
|
601 | for {set i 0} {$i < $argc} {incr i} { | |||
|
602 | set arg [lindex $argv $i] | |||
|
603 | puts "arg=$arg" | |||
|
604 | if {"-noinfo" eq $arg} { | |||
|
605 | set msglevel [expr {$msglevel & ~($MSG_INFO)}] | |||
|
606 | } | |||
|
607 | if {"-nonote" eq $arg} { | |||
|
608 | set msglevel [expr {$msglevel & ~($MSG_NOTE)}] | |||
|
609 | } | |||
|
610 | if {"-silent" eq $arg} { | |||
|
611 | set msglevel 0 | |||
|
612 | } | |||
|
613 | } | |||
|
614 | ||||
|
615 | puts "\n$errata_desc errata scanning utility, rev $util_rev ($util_date)" | |||
|
616 | ||||
|
617 | puts "Searching objdump -d output on standard input for:" | |||
|
618 | if {$b2bst_seqa_scan} { | |||
|
619 | puts " - $b2bst_seqa_desc" | |||
|
620 | } | |||
|
621 | if {$b2bst_seqb_scan} { | |||
|
622 | puts " - $b2bst_seqb_desc" | |||
|
623 | } | |||
|
624 | puts "" | |||
|
625 | ||||
|
626 | set fn_valid 0 | |||
|
627 | while {! [eof stdin]} { | |||
|
628 | set l [gets stdin] | |||
|
629 | incr line_count | |||
|
630 | # puts "line $l" | |||
|
631 | # Remove comment after '!' | |||
|
632 | set x [string first "!" "$l"] | |||
|
633 | if { $x >= 0 } then { set l [string range "$l" 0 $x] } | |||
|
634 | # check if entry point / function start | |||
|
635 | set m [regexp {^ *([0-9A-Fa-f]+) <([^ ]+)>:} "$l" t1 addr symname] | |||
|
636 | if { $m > 0 } then { | |||
|
637 | # puts "Function name=$symname addr=$addr" | |||
|
638 | if { $fn_valid } { | |||
|
639 | # puts $curfn_ops(0x40000000) | |||
|
640 | set q [scan_wholefunc $curfn $curfn_addr curfn_ops] | |||
|
641 | # puts "q=$q err_count=$err_count" | |||
|
642 | set err_count [ expr { $err_count + $q } ] | |||
|
643 | } | |||
|
644 | set curfn "$symname" | |||
|
645 | set curfn_addr "$addr" | |||
|
646 | array unset curfn_ops | |||
|
647 | array set curfn_ops "" | |||
|
648 | set fn_valid 0 | |||
|
649 | } else { | |||
|
650 | # Check if opcode | |||
|
651 | set m [regexp {^ *([0-9A-Fa-f]+): *\t(.. .. .. ..) *\t([^ ]+)(.*)$} "$l" t1 addr hexcode opname opargs] | |||
|
652 | if { $m > 0 } then { | |||
|
653 | # puts "Opcode name=$opname args=$opargs addr=$addr" | |||
|
654 | incr op_count | |||
|
655 | set addr [format "%08x" 0x$addr] | |||
|
656 | set hexcode [string map {" " ""} $hexcode] | |||
|
657 | # puts "setting curfn_ops 0x$addr" | |||
|
658 | set curfn_ops(0x$addr) [list "0x$hexcode" $opname $opargs "" ""] | |||
|
659 | incr fn_valid | |||
|
660 | } else { | |||
|
661 | incr lineskip_count | |||
|
662 | } | |||
|
663 | } | |||
|
664 | } | |||
|
665 | if { $fn_valid } { | |||
|
666 | set q [scan_wholefunc $curfn $curfn_addr curfn_ops] | |||
|
667 | set err_count [ expr { $err_count + $q } ] | |||
|
668 | } | |||
|
669 | ||||
|
670 | puts "\nObjdump lines processed: $line_count, lines skipped: $lineskip_count" | |||
|
671 | puts "Functions scanned: ${fn_count}, reachable instruction count: ${fninst_count}" | |||
|
672 | puts "Potential error locations found: $err_count\n" | |||
|
673 | ||||
|
674 | if {$err_count == 0} { | |||
|
675 | exit 0 | |||
|
676 | } else { | |||
|
677 | exit 1 | |||
|
678 | } | |||
|
679 | ||||
|
680 | } | |||
|
681 |
@@ -1,2068 +1,2068 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1 = {0}; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1 = {0}; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; | |
19 | ring_node kcoefficient_node_1 = {0}; |
|
19 | ring_node kcoefficient_node_1 = {0}; | |
20 | ring_node kcoefficient_node_2 = {0}; |
|
20 | ring_node kcoefficient_node_2 = {0}; | |
21 |
|
21 | |||
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
23 | { |
|
23 | { | |
24 | /** This function updates the LFR registers with the incoming common parameters. |
|
24 | /** This function updates the LFR registers with the incoming common parameters. | |
25 | * |
|
25 | * | |
26 | * @param TC points to the TeleCommand packet that is being processed |
|
26 | * @param TC points to the TeleCommand packet that is being processed | |
27 | * |
|
27 | * | |
28 | * |
|
28 | * | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; | |
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; | |
33 | set_wfp_data_shaping( ); |
|
33 | set_wfp_data_shaping( ); | |
34 | return LFR_SUCCESSFUL; |
|
34 | return LFR_SUCCESSFUL; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
38 | { |
|
38 | { | |
39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
39 | /** This function updates the LFR registers with the incoming normal parameters. | |
40 | * |
|
40 | * | |
41 | * @param TC points to the TeleCommand packet that is being processed |
|
41 | * @param TC points to the TeleCommand packet that is being processed | |
42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int result; |
|
46 | int result; | |
47 | int flag; |
|
47 | int flag; | |
48 | rtems_status_code status; |
|
48 | rtems_status_code status; | |
49 |
|
49 | |||
50 | flag = LFR_SUCCESSFUL; |
|
50 | flag = LFR_SUCCESSFUL; | |
51 |
|
51 | |||
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
55 | flag = LFR_DEFAULT; |
|
55 | flag = LFR_DEFAULT; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
58 | // CHECK THE PARAMETERS SET CONSISTENCY | |
59 | if (flag == LFR_SUCCESSFUL) |
|
59 | if (flag == LFR_SUCCESSFUL) | |
60 | { |
|
60 | { | |
61 | flag = check_normal_par_consistency( TC, queue_id ); |
|
61 | flag = check_normal_par_consistency( TC, queue_id ); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT | |
65 | if (flag == LFR_SUCCESSFUL) |
|
65 | if (flag == LFR_SUCCESSFUL) | |
66 | { |
|
66 | { | |
67 | result = set_sy_lfr_n_swf_l( TC ); |
|
67 | result = set_sy_lfr_n_swf_l( TC ); | |
68 | result = set_sy_lfr_n_swf_p( TC ); |
|
68 | result = set_sy_lfr_n_swf_p( TC ); | |
69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
69 | result = set_sy_lfr_n_bp_p0( TC ); | |
70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
70 | result = set_sy_lfr_n_bp_p1( TC ); | |
71 | result = set_sy_lfr_n_asm_p( TC ); |
|
71 | result = set_sy_lfr_n_asm_p( TC ); | |
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | return flag; |
|
75 | return flag; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
79 | { |
|
79 | { | |
80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
80 | /** This function updates the LFR registers with the incoming burst parameters. | |
81 | * |
|
81 | * | |
82 | * @param TC points to the TeleCommand packet that is being processed |
|
82 | * @param TC points to the TeleCommand packet that is being processed | |
83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
87 | int flag; | |
88 | rtems_status_code status; |
|
88 | rtems_status_code status; | |
89 | unsigned char sy_lfr_b_bp_p0; |
|
89 | unsigned char sy_lfr_b_bp_p0; | |
90 | unsigned char sy_lfr_b_bp_p1; |
|
90 | unsigned char sy_lfr_b_bp_p1; | |
91 | float aux; |
|
91 | float aux; | |
92 |
|
92 | |||
93 | flag = LFR_SUCCESSFUL; |
|
93 | flag = LFR_SUCCESSFUL; | |
94 |
|
94 | |||
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
97 | flag = LFR_DEFAULT; |
|
97 | flag = LFR_DEFAULT; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
102 |
|
102 | |||
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value |
|
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value | |
104 | if (flag == LFR_SUCCESSFUL) |
|
104 | if (flag == LFR_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) | |
107 | { |
|
107 | { | |
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); | |
109 | flag = WRONG_APP_DATA; |
|
109 | flag = WRONG_APP_DATA; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value |
|
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value | |
113 | if (flag == LFR_SUCCESSFUL) |
|
113 | if (flag == LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) | |
116 | { |
|
116 | { | |
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1 + DATAFIELD_OFFSET, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1 + DATAFIELD_OFFSET, sy_lfr_b_bp_p1 ); | |
118 | flag = WRONG_APP_DATA; |
|
118 | flag = WRONG_APP_DATA; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | //**************************************************************** |
|
121 | //**************************************************************** | |
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 | |
123 | if (flag == LFR_SUCCESSFUL) |
|
123 | if (flag == LFR_SUCCESSFUL) | |
124 | { |
|
124 | { | |
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
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 | if (aux > FLOAT_EQUAL_ZERO) |
|
128 | if (aux > FLOAT_EQUAL_ZERO) | |
129 | { |
|
129 | { | |
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); | |
131 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET THE PARAMETERS |
|
135 | // SET THE PARAMETERS | |
136 | if (flag == LFR_SUCCESSFUL) |
|
136 | if (flag == LFR_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
138 | flag = set_sy_lfr_b_bp_p0( TC ); | |
139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
139 | flag = set_sy_lfr_b_bp_p1( TC ); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | return flag; |
|
142 | return flag; | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
146 | { |
|
146 | { | |
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
148 | * |
|
148 | * | |
149 | * @param TC points to the TeleCommand packet that is being processed |
|
149 | * @param TC points to the TeleCommand packet that is being processed | |
150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
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 | int flag; |
|
154 | int flag; | |
155 | rtems_status_code status; |
|
155 | rtems_status_code status; | |
156 | unsigned char sy_lfr_s1_bp_p0; |
|
156 | unsigned char sy_lfr_s1_bp_p0; | |
157 | unsigned char sy_lfr_s1_bp_p1; |
|
157 | unsigned char sy_lfr_s1_bp_p1; | |
158 | float aux; |
|
158 | float aux; | |
159 |
|
159 | |||
160 | flag = LFR_SUCCESSFUL; |
|
160 | flag = LFR_SUCCESSFUL; | |
161 |
|
161 | |||
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
164 | flag = LFR_DEFAULT; |
|
164 | flag = LFR_DEFAULT; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
169 |
|
169 | |||
170 | // sy_lfr_s1_bp_p0 |
|
170 | // sy_lfr_s1_bp_p0 | |
171 | if (flag == LFR_SUCCESSFUL) |
|
171 | if (flag == LFR_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) | |
174 | { |
|
174 | { | |
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); | |
176 | flag = WRONG_APP_DATA; |
|
176 | flag = WRONG_APP_DATA; | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | // sy_lfr_s1_bp_p1 |
|
179 | // sy_lfr_s1_bp_p1 | |
180 | if (flag == LFR_SUCCESSFUL) |
|
180 | if (flag == LFR_SUCCESSFUL) | |
181 | { |
|
181 | { | |
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) | |
183 | { |
|
183 | { | |
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p1 ); | |
185 | flag = WRONG_APP_DATA; |
|
185 | flag = WRONG_APP_DATA; | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 | //****************************************************************** |
|
188 | //****************************************************************** | |
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 | |
190 | if (flag == LFR_SUCCESSFUL) |
|
190 | if (flag == LFR_SUCCESSFUL) | |
191 | { |
|
191 | { | |
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE) ) |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE) ) | |
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); |
|
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); | |
194 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | if (aux > FLOAT_EQUAL_ZERO) | |
195 | { |
|
195 | { | |
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); | |
197 | flag = LFR_DEFAULT; |
|
197 | flag = LFR_DEFAULT; | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | // SET THE PARAMETERS |
|
201 | // SET THE PARAMETERS | |
202 | if (flag == LFR_SUCCESSFUL) |
|
202 | if (flag == LFR_SUCCESSFUL) | |
203 | { |
|
203 | { | |
204 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
205 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | return flag; |
|
208 | return flag; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
212 | { |
|
212 | { | |
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
214 | * |
|
214 | * | |
215 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | * @param TC points to the TeleCommand packet that is being processed | |
216 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
216 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
217 | * |
|
217 | * | |
218 | */ |
|
218 | */ | |
219 |
|
219 | |||
220 | int flag; |
|
220 | int flag; | |
221 | rtems_status_code status; |
|
221 | rtems_status_code status; | |
222 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | unsigned char sy_lfr_s2_bp_p0; | |
223 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | unsigned char sy_lfr_s2_bp_p1; | |
224 | float aux; |
|
224 | float aux; | |
225 |
|
225 | |||
226 | flag = LFR_SUCCESSFUL; |
|
226 | flag = LFR_SUCCESSFUL; | |
227 |
|
227 | |||
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
230 | flag = LFR_DEFAULT; |
|
230 | flag = LFR_DEFAULT; | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
235 |
|
235 | |||
236 | // sy_lfr_s2_bp_p0 |
|
236 | // sy_lfr_s2_bp_p0 | |
237 | if (flag == LFR_SUCCESSFUL) |
|
237 | if (flag == LFR_SUCCESSFUL) | |
238 | { |
|
238 | { | |
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
240 | { |
|
240 | { | |
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
242 | flag = WRONG_APP_DATA; |
|
242 | flag = WRONG_APP_DATA; | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 | // sy_lfr_s2_bp_p1 |
|
245 | // sy_lfr_s2_bp_p1 | |
246 | if (flag == LFR_SUCCESSFUL) |
|
246 | if (flag == LFR_SUCCESSFUL) | |
247 | { |
|
247 | { | |
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
249 | { |
|
249 | { | |
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); |
|
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); | |
251 | flag = WRONG_APP_DATA; |
|
251 | flag = WRONG_APP_DATA; | |
252 | } |
|
252 | } | |
253 | } |
|
253 | } | |
254 | //****************************************************************** |
|
254 | //****************************************************************** | |
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
256 | if (flag == LFR_SUCCESSFUL) |
|
256 | if (flag == LFR_SUCCESSFUL) | |
257 | { |
|
257 | { | |
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
261 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | if (aux > FLOAT_EQUAL_ZERO) | |
262 | { |
|
262 | { | |
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
264 | flag = LFR_DEFAULT; |
|
264 | flag = LFR_DEFAULT; | |
265 | } |
|
265 | } | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | // SET THE PARAMETERS |
|
268 | // SET THE PARAMETERS | |
269 | if (flag == LFR_SUCCESSFUL) |
|
269 | if (flag == LFR_SUCCESSFUL) | |
270 | { |
|
270 | { | |
271 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
272 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | return flag; |
|
275 | return flag; | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
279 | { |
|
279 | { | |
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
281 | * |
|
281 | * | |
282 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | * @param TC points to the TeleCommand packet that is being processed | |
283 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
283 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
284 | * |
|
284 | * | |
285 | */ |
|
285 | */ | |
286 |
|
286 | |||
287 | int flag; |
|
287 | int flag; | |
288 |
|
288 | |||
289 | flag = LFR_DEFAULT; |
|
289 | flag = LFR_DEFAULT; | |
290 |
|
290 | |||
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
292 |
|
292 | |||
293 | return flag; |
|
293 | return flag; | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
297 | { |
|
297 | { | |
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
299 | * |
|
299 | * | |
300 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | * @param TC points to the TeleCommand packet that is being processed | |
301 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
301 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
302 | * |
|
302 | * | |
303 | */ |
|
303 | */ | |
304 |
|
304 | |||
305 | int flag; |
|
305 | int flag; | |
306 |
|
306 | |||
307 | flag = LFR_DEFAULT; |
|
307 | flag = LFR_DEFAULT; | |
308 |
|
308 | |||
309 | flag = set_sy_lfr_fbins( TC ); |
|
309 | flag = set_sy_lfr_fbins( TC ); | |
310 |
|
310 | |||
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering |
|
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering | |
312 | merge_fbins_masks(); |
|
312 | merge_fbins_masks(); | |
313 |
|
313 | |||
314 | return flag; |
|
314 | return flag; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
318 | { |
|
318 | { | |
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
320 | * |
|
320 | * | |
321 | * @param TC points to the TeleCommand packet that is being processed |
|
321 | * @param TC points to the TeleCommand packet that is being processed | |
322 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
322 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
323 | * |
|
323 | * | |
324 | */ |
|
324 | */ | |
325 |
|
325 | |||
326 | int flag; |
|
326 | int flag; | |
327 | unsigned char k; |
|
327 | unsigned char k; | |
328 |
|
328 | |||
329 | flag = LFR_DEFAULT; |
|
329 | flag = LFR_DEFAULT; | |
330 | k = INIT_CHAR; |
|
330 | k = INIT_CHAR; | |
331 |
|
331 | |||
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); |
|
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); | |
333 |
|
333 | |||
334 | if (flag == LFR_SUCCESSFUL) |
|
334 | if (flag == LFR_SUCCESSFUL) | |
335 | { |
|
335 | { | |
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; |
|
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; | |
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; |
|
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; | |
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; |
|
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; | |
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; |
|
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; | |
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; |
|
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; | |
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; |
|
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; | |
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; |
|
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; | |
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; |
|
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; | |
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; |
|
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; | |
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; |
|
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; | |
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; |
|
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; | |
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; |
|
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; | |
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; |
|
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; | |
351 |
|
351 | |||
352 | //**************************** |
|
352 | //**************************** | |
353 | // store PAS filter parameters |
|
353 | // store PAS filter parameters | |
354 |
|
354 | |||
355 | // sy_lfr_pas_filter_enabled |
|
355 | // sy_lfr_pas_filter_enabled | |
356 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; |
|
356 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; | |
357 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); |
|
357 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); | |
358 |
|
358 | |||
359 | // sy_lfr_pas_filter_modulus |
|
359 | // sy_lfr_pas_filter_modulus | |
360 | filterPar.modulus_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_modulus) * CONST_65536; |
|
360 | filterPar.modulus_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_modulus) * CONST_65536; | |
361 |
|
361 | |||
362 | // sy_lfr_pas_filter_tbad |
|
362 | // sy_lfr_pas_filter_tbad | |
363 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, |
|
363 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, | |
364 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
364 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
365 | filterPar.tbad_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_tbad * CONST_65536); |
|
365 | filterPar.tbad_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_tbad * CONST_65536); | |
366 |
|
366 | |||
367 | // sy_lfr_pas_filter_offset |
|
367 | // sy_lfr_pas_filter_offset | |
368 | filterPar.offset_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_offset) * CONST_65536; |
|
368 | filterPar.offset_in_finetime = ((uint64_t) parameter_dump_packet.sy_lfr_pas_filter_offset) * CONST_65536; | |
369 |
|
369 | |||
370 | // sy_lfr_pas_filter_shift |
|
370 | // sy_lfr_pas_filter_shift | |
371 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, |
|
371 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, | |
372 | parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
372 | parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
373 | filterPar.shift_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_shift * CONST_65536); |
|
373 | filterPar.shift_in_finetime = (uint64_t) (filterPar.sy_lfr_pas_filter_shift * CONST_65536); | |
374 |
|
374 | |||
375 | //**************************************************** |
|
375 | //**************************************************** | |
376 | // store the parameter sy_lfr_sc_rw_delta_f as a float |
|
376 | // store the parameter sy_lfr_sc_rw_delta_f as a float | |
377 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, |
|
377 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, | |
378 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
378 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
379 |
|
379 | |||
380 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet |
|
380 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet | |
381 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) |
|
381 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) | |
382 | { |
|
382 | { | |
383 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; |
|
383 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | //*********************************************** |
|
386 | //*********************************************** | |
387 | // store the parameter sy_lfr_rw.._k.. as a float |
|
387 | // store the parameter sy_lfr_rw.._k.. as a float | |
388 | // rw1_k |
|
388 | // rw1_k | |
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); |
|
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); | |
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); |
|
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); | |
391 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); |
|
391 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); | |
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); |
|
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); | |
393 | // rw2_k |
|
393 | // rw2_k | |
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); |
|
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); | |
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); |
|
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); | |
396 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); |
|
396 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); | |
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); |
|
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); | |
398 | // rw3_k |
|
398 | // rw3_k | |
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); |
|
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); | |
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); |
|
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); | |
401 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); |
|
401 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); | |
402 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); |
|
402 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); | |
403 | // rw4_k |
|
403 | // rw4_k | |
404 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); |
|
404 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); | |
405 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); |
|
405 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); | |
406 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); |
|
406 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); | |
407 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); |
|
407 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); | |
408 |
|
408 | |||
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | return flag; |
|
411 | return flag; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
414 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
415 | { |
|
415 | { | |
416 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
416 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
417 | * |
|
417 | * | |
418 | * @param TC points to the TeleCommand packet that is being processed |
|
418 | * @param TC points to the TeleCommand packet that is being processed | |
419 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
419 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
420 | * |
|
420 | * | |
421 | */ |
|
421 | */ | |
422 |
|
422 | |||
423 | unsigned int address; |
|
423 | unsigned int address; | |
424 | rtems_status_code status; |
|
424 | rtems_status_code status; | |
425 | unsigned int freq; |
|
425 | unsigned int freq; | |
426 | unsigned int bin; |
|
426 | unsigned int bin; | |
427 | unsigned int coeff; |
|
427 | unsigned int coeff; | |
428 | unsigned char *kCoeffPtr; |
|
428 | unsigned char *kCoeffPtr; | |
429 | unsigned char *kCoeffDumpPtr; |
|
429 | unsigned char *kCoeffDumpPtr; | |
430 |
|
430 | |||
431 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
431 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
432 | // F0 => 11 bins |
|
432 | // F0 => 11 bins | |
433 | // F1 => 13 bins |
|
433 | // F1 => 13 bins | |
434 | // F2 => 12 bins |
|
434 | // F2 => 12 bins | |
435 | // 36 bins to dump in two packets (30 bins max per packet) |
|
435 | // 36 bins to dump in two packets (30 bins max per packet) | |
436 |
|
436 | |||
437 | //********* |
|
437 | //********* | |
438 | // PACKET 1 |
|
438 | // PACKET 1 | |
439 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
439 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
440 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
440 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
441 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
441 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
442 | for( freq = 0; |
|
442 | for( freq = 0; | |
443 | freq < NB_BINS_COMPRESSED_SM_F0; |
|
443 | freq < NB_BINS_COMPRESSED_SM_F0; | |
444 | freq++ ) |
|
444 | freq++ ) | |
445 | { |
|
445 | { | |
446 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; |
|
446 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; | |
447 | bin = freq; |
|
447 | bin = freq; | |
448 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
448 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
449 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
449 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
450 | { |
|
450 | { | |
451 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
451 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
452 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
452 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
453 | ]; // 2 for the kcoeff_frequency |
|
453 | ]; // 2 for the kcoeff_frequency | |
454 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
454 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
455 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
455 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 | for( freq = NB_BINS_COMPRESSED_SM_F0; |
|
458 | for( freq = NB_BINS_COMPRESSED_SM_F0; | |
459 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
459 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
460 | freq++ ) |
|
460 | freq++ ) | |
461 | { |
|
461 | { | |
462 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
462 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; | |
463 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
463 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
464 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
464 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
465 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
465 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
466 | { |
|
466 | { | |
467 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
467 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
468 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
468 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
469 | ]; // 2 for the kcoeff_frequency |
|
469 | ]; // 2 for the kcoeff_frequency | |
470 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
470 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
471 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
471 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
472 | } |
|
472 | } | |
473 | } |
|
473 | } | |
474 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
474 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
475 | freq < KCOEFF_BLK_NR_PKT1 ; |
|
475 | freq < KCOEFF_BLK_NR_PKT1 ; | |
476 | freq++ ) |
|
476 | freq++ ) | |
477 | { |
|
477 | { | |
478 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
478 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; | |
479 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
479 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
480 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
480 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
481 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) |
|
481 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) | |
482 | { |
|
482 | { | |
483 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
483 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
484 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
484 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
485 | ]; // 2 for the kcoeff_frequency |
|
485 | ]; // 2 for the kcoeff_frequency | |
486 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
486 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
487 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
487 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
490 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
491 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
491 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
492 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
492 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
493 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
493 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
494 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
494 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
495 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
495 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
496 | // SEND DATA |
|
496 | // SEND DATA | |
497 | kcoefficient_node_1.status = 1; |
|
497 | kcoefficient_node_1.status = 1; | |
498 | address = (unsigned int) &kcoefficient_node_1; |
|
498 | address = (unsigned int) &kcoefficient_node_1; | |
499 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
499 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
500 | if (status != RTEMS_SUCCESSFUL) { |
|
500 | if (status != RTEMS_SUCCESSFUL) { | |
501 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
501 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
502 | } |
|
502 | } | |
503 |
|
503 | |||
504 | //******** |
|
504 | //******** | |
505 | // PACKET 2 |
|
505 | // PACKET 2 | |
506 | // 6 F2 bins |
|
506 | // 6 F2 bins | |
507 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
507 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
508 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
508 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
509 | for( freq = 0; |
|
509 | for( freq = 0; | |
510 | freq < KCOEFF_BLK_NR_PKT2; |
|
510 | freq < KCOEFF_BLK_NR_PKT2; | |
511 | freq++ ) |
|
511 | freq++ ) | |
512 | { |
|
512 | { | |
513 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; |
|
513 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; | |
514 | bin = freq + KCOEFF_BLK_NR_PKT2; |
|
514 | bin = freq + KCOEFF_BLK_NR_PKT2; | |
515 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
515 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
516 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
516 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
517 | { |
|
517 | { | |
518 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ |
|
518 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ | |
519 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency |
|
519 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency | |
520 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
520 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
521 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
521 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
522 | } |
|
522 | } | |
523 | } |
|
523 | } | |
524 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
524 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
525 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
525 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
526 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
526 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
527 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
527 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
528 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
528 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
529 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
529 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
530 | // SEND DATA |
|
530 | // SEND DATA | |
531 | kcoefficient_node_2.status = 1; |
|
531 | kcoefficient_node_2.status = 1; | |
532 | address = (unsigned int) &kcoefficient_node_2; |
|
532 | address = (unsigned int) &kcoefficient_node_2; | |
533 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
533 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
534 | if (status != RTEMS_SUCCESSFUL) { |
|
534 | if (status != RTEMS_SUCCESSFUL) { | |
535 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
535 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
536 | } |
|
536 | } | |
537 |
|
537 | |||
538 | return status; |
|
538 | return status; | |
539 | } |
|
539 | } | |
540 |
|
540 | |||
541 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
541 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
542 | { |
|
542 | { | |
543 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
543 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
544 | * |
|
544 | * | |
545 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
545 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
546 | * |
|
546 | * | |
547 | * @return RTEMS directive status codes: |
|
547 | * @return RTEMS directive status codes: | |
548 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
548 | * - RTEMS_SUCCESSFUL - message sent successfully | |
549 | * - RTEMS_INVALID_ID - invalid queue id |
|
549 | * - RTEMS_INVALID_ID - invalid queue id | |
550 | * - RTEMS_INVALID_SIZE - invalid message size |
|
550 | * - RTEMS_INVALID_SIZE - invalid message size | |
551 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
551 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
552 | * - RTEMS_UNSATISFIED - out of message buffers |
|
552 | * - RTEMS_UNSATISFIED - out of message buffers | |
553 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
553 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
554 | * |
|
554 | * | |
555 | */ |
|
555 | */ | |
556 |
|
556 | |||
557 | int status; |
|
557 | int status; | |
558 |
|
558 | |||
559 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
559 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
560 | parameter_dump_packet.destinationID = TC->sourceID; |
|
560 | parameter_dump_packet.destinationID = TC->sourceID; | |
561 |
|
561 | |||
562 | // UPDATE TIME |
|
562 | // UPDATE TIME | |
563 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
563 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
564 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
564 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
565 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
565 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
566 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
566 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
567 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
567 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
568 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
568 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
569 | // SEND DATA |
|
569 | // SEND DATA | |
570 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
570 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
571 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
571 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
572 | if (status != RTEMS_SUCCESSFUL) { |
|
572 | if (status != RTEMS_SUCCESSFUL) { | |
573 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
573 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
574 | } |
|
574 | } | |
575 |
|
575 | |||
576 | return status; |
|
576 | return status; | |
577 | } |
|
577 | } | |
578 |
|
578 | |||
579 | //*********************** |
|
579 | //*********************** | |
580 | // NORMAL MODE PARAMETERS |
|
580 | // NORMAL MODE PARAMETERS | |
581 |
|
581 | |||
582 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
582 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
583 | { |
|
583 | { | |
584 | unsigned char msb; |
|
584 | unsigned char msb; | |
585 | unsigned char lsb; |
|
585 | unsigned char lsb; | |
586 | int flag; |
|
586 | int flag; | |
587 | float aux; |
|
587 | float aux; | |
588 | rtems_status_code status; |
|
588 | rtems_status_code status; | |
589 |
|
589 | |||
590 | unsigned int sy_lfr_n_swf_l; |
|
590 | unsigned int sy_lfr_n_swf_l; | |
591 | unsigned int sy_lfr_n_swf_p; |
|
591 | unsigned int sy_lfr_n_swf_p; | |
592 | unsigned int sy_lfr_n_asm_p; |
|
592 | unsigned int sy_lfr_n_asm_p; | |
593 | unsigned char sy_lfr_n_bp_p0; |
|
593 | unsigned char sy_lfr_n_bp_p0; | |
594 | unsigned char sy_lfr_n_bp_p1; |
|
594 | unsigned char sy_lfr_n_bp_p1; | |
595 | unsigned char sy_lfr_n_cwf_long_f3; |
|
595 | unsigned char sy_lfr_n_cwf_long_f3; | |
596 |
|
596 | |||
597 | flag = LFR_SUCCESSFUL; |
|
597 | flag = LFR_SUCCESSFUL; | |
598 |
|
598 | |||
599 | //*************** |
|
599 | //*************** | |
600 | // get parameters |
|
600 | // get parameters | |
601 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
601 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
602 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
602 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
603 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; |
|
603 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; | |
604 |
|
604 | |||
605 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
605 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
606 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
606 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
607 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; |
|
607 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; | |
608 |
|
608 | |||
609 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
609 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
610 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
610 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
611 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; |
|
611 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; | |
612 |
|
612 | |||
613 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
613 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
614 |
|
614 | |||
615 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
615 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
616 |
|
616 | |||
617 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
617 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
618 |
|
618 | |||
619 | //****************** |
|
619 | //****************** | |
620 | // check consistency |
|
620 | // check consistency | |
621 | // sy_lfr_n_swf_l |
|
621 | // sy_lfr_n_swf_l | |
622 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) |
|
622 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) | |
623 | { |
|
623 | { | |
624 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); |
|
624 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); | |
625 | flag = WRONG_APP_DATA; |
|
625 | flag = WRONG_APP_DATA; | |
626 | } |
|
626 | } | |
627 | // sy_lfr_n_swf_p |
|
627 | // sy_lfr_n_swf_p | |
628 | if (flag == LFR_SUCCESSFUL) |
|
628 | if (flag == LFR_SUCCESSFUL) | |
629 | { |
|
629 | { | |
630 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) |
|
630 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) | |
631 | { |
|
631 | { | |
632 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); |
|
632 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); | |
633 | flag = WRONG_APP_DATA; |
|
633 | flag = WRONG_APP_DATA; | |
634 | } |
|
634 | } | |
635 | } |
|
635 | } | |
636 | // sy_lfr_n_bp_p0 |
|
636 | // sy_lfr_n_bp_p0 | |
637 | if (flag == LFR_SUCCESSFUL) |
|
637 | if (flag == LFR_SUCCESSFUL) | |
638 | { |
|
638 | { | |
639 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
639 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
640 | { |
|
640 | { | |
641 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); |
|
641 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); | |
642 | flag = WRONG_APP_DATA; |
|
642 | flag = WRONG_APP_DATA; | |
643 | } |
|
643 | } | |
644 | } |
|
644 | } | |
645 | // sy_lfr_n_asm_p |
|
645 | // sy_lfr_n_asm_p | |
646 | if (flag == LFR_SUCCESSFUL) |
|
646 | if (flag == LFR_SUCCESSFUL) | |
647 | { |
|
647 | { | |
648 | if (sy_lfr_n_asm_p == 0) |
|
648 | if (sy_lfr_n_asm_p == 0) | |
649 | { |
|
649 | { | |
650 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
650 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
651 | flag = WRONG_APP_DATA; |
|
651 | flag = WRONG_APP_DATA; | |
652 | } |
|
652 | } | |
653 | } |
|
653 | } | |
654 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
654 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
655 | if (flag == LFR_SUCCESSFUL) |
|
655 | if (flag == LFR_SUCCESSFUL) | |
656 | { |
|
656 | { | |
657 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
657 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
658 | if (aux > FLOAT_EQUAL_ZERO) |
|
658 | if (aux > FLOAT_EQUAL_ZERO) | |
659 | { |
|
659 | { | |
660 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
660 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
661 | flag = WRONG_APP_DATA; |
|
661 | flag = WRONG_APP_DATA; | |
662 | } |
|
662 | } | |
663 | } |
|
663 | } | |
664 | // sy_lfr_n_bp_p1 |
|
664 | // sy_lfr_n_bp_p1 | |
665 | if (flag == LFR_SUCCESSFUL) |
|
665 | if (flag == LFR_SUCCESSFUL) | |
666 | { |
|
666 | { | |
667 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
667 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
668 | { |
|
668 | { | |
669 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
669 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
670 | flag = WRONG_APP_DATA; |
|
670 | flag = WRONG_APP_DATA; | |
671 | } |
|
671 | } | |
672 | } |
|
672 | } | |
673 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
673 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
674 | if (flag == LFR_SUCCESSFUL) |
|
674 | if (flag == LFR_SUCCESSFUL) | |
675 | { |
|
675 | { | |
676 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
676 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
677 | if (aux > FLOAT_EQUAL_ZERO) |
|
677 | if (aux > FLOAT_EQUAL_ZERO) | |
678 | { |
|
678 | { | |
679 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
679 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
680 | flag = LFR_DEFAULT; |
|
680 | flag = LFR_DEFAULT; | |
681 | } |
|
681 | } | |
682 | } |
|
682 | } | |
683 | // sy_lfr_n_cwf_long_f3 |
|
683 | // sy_lfr_n_cwf_long_f3 | |
684 |
|
684 | |||
685 | return flag; |
|
685 | return flag; | |
686 | } |
|
686 | } | |
687 |
|
687 | |||
688 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
688 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
689 | { |
|
689 | { | |
690 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
690 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
691 | * |
|
691 | * | |
692 | * @param TC points to the TeleCommand packet that is being processed |
|
692 | * @param TC points to the TeleCommand packet that is being processed | |
693 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
693 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
694 | * |
|
694 | * | |
695 | */ |
|
695 | */ | |
696 |
|
696 | |||
697 | int result; |
|
697 | int result; | |
698 |
|
698 | |||
699 | result = LFR_SUCCESSFUL; |
|
699 | result = LFR_SUCCESSFUL; | |
700 |
|
700 | |||
701 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
701 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
702 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
702 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
703 |
|
703 | |||
704 | return result; |
|
704 | return result; | |
705 | } |
|
705 | } | |
706 |
|
706 | |||
707 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
707 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
708 | { |
|
708 | { | |
709 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
709 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
710 | * |
|
710 | * | |
711 | * @param TC points to the TeleCommand packet that is being processed |
|
711 | * @param TC points to the TeleCommand packet that is being processed | |
712 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
712 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
713 | * |
|
713 | * | |
714 | */ |
|
714 | */ | |
715 |
|
715 | |||
716 | int result; |
|
716 | int result; | |
717 |
|
717 | |||
718 | result = LFR_SUCCESSFUL; |
|
718 | result = LFR_SUCCESSFUL; | |
719 |
|
719 | |||
720 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
720 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
721 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
721 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
722 |
|
722 | |||
723 | return result; |
|
723 | return result; | |
724 | } |
|
724 | } | |
725 |
|
725 | |||
726 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
726 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
727 | { |
|
727 | { | |
728 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
728 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
729 | * |
|
729 | * | |
730 | * @param TC points to the TeleCommand packet that is being processed |
|
730 | * @param TC points to the TeleCommand packet that is being processed | |
731 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
731 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
732 | * |
|
732 | * | |
733 | */ |
|
733 | */ | |
734 |
|
734 | |||
735 | int result; |
|
735 | int result; | |
736 |
|
736 | |||
737 | result = LFR_SUCCESSFUL; |
|
737 | result = LFR_SUCCESSFUL; | |
738 |
|
738 | |||
739 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
739 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
740 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
740 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
741 |
|
741 | |||
742 | return result; |
|
742 | return result; | |
743 | } |
|
743 | } | |
744 |
|
744 | |||
745 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
745 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
746 | { |
|
746 | { | |
747 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
747 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
748 | * |
|
748 | * | |
749 | * @param TC points to the TeleCommand packet that is being processed |
|
749 | * @param TC points to the TeleCommand packet that is being processed | |
750 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
750 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
751 | * |
|
751 | * | |
752 | */ |
|
752 | */ | |
753 |
|
753 | |||
754 | int status; |
|
754 | int status; | |
755 |
|
755 | |||
756 | status = LFR_SUCCESSFUL; |
|
756 | status = LFR_SUCCESSFUL; | |
757 |
|
757 | |||
758 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
758 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
759 |
|
759 | |||
760 | return status; |
|
760 | return status; | |
761 | } |
|
761 | } | |
762 |
|
762 | |||
763 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
763 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
764 | { |
|
764 | { | |
765 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
765 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
766 | * |
|
766 | * | |
767 | * @param TC points to the TeleCommand packet that is being processed |
|
767 | * @param TC points to the TeleCommand packet that is being processed | |
768 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
768 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
769 | * |
|
769 | * | |
770 | */ |
|
770 | */ | |
771 |
|
771 | |||
772 | int status; |
|
772 | int status; | |
773 |
|
773 | |||
774 | status = LFR_SUCCESSFUL; |
|
774 | status = LFR_SUCCESSFUL; | |
775 |
|
775 | |||
776 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
776 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
777 |
|
777 | |||
778 | return status; |
|
778 | return status; | |
779 | } |
|
779 | } | |
780 |
|
780 | |||
781 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
781 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
782 | { |
|
782 | { | |
783 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
783 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
784 | * |
|
784 | * | |
785 | * @param TC points to the TeleCommand packet that is being processed |
|
785 | * @param TC points to the TeleCommand packet that is being processed | |
786 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
786 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
787 | * |
|
787 | * | |
788 | */ |
|
788 | */ | |
789 |
|
789 | |||
790 | int status; |
|
790 | int status; | |
791 |
|
791 | |||
792 | status = LFR_SUCCESSFUL; |
|
792 | status = LFR_SUCCESSFUL; | |
793 |
|
793 | |||
794 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
794 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
795 |
|
795 | |||
796 | return status; |
|
796 | return status; | |
797 | } |
|
797 | } | |
798 |
|
798 | |||
799 | //********************** |
|
799 | //********************** | |
800 | // BURST MODE PARAMETERS |
|
800 | // BURST MODE PARAMETERS | |
801 |
|
801 | |||
802 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
802 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
803 | { |
|
803 | { | |
804 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
804 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
805 | * |
|
805 | * | |
806 | * @param TC points to the TeleCommand packet that is being processed |
|
806 | * @param TC points to the TeleCommand packet that is being processed | |
807 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
807 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
808 | * |
|
808 | * | |
809 | */ |
|
809 | */ | |
810 |
|
810 | |||
811 | int status; |
|
811 | int status; | |
812 |
|
812 | |||
813 | status = LFR_SUCCESSFUL; |
|
813 | status = LFR_SUCCESSFUL; | |
814 |
|
814 | |||
815 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
815 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
816 |
|
816 | |||
817 | return status; |
|
817 | return status; | |
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
820 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
821 | { |
|
821 | { | |
822 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
822 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
823 | * |
|
823 | * | |
824 | * @param TC points to the TeleCommand packet that is being processed |
|
824 | * @param TC points to the TeleCommand packet that is being processed | |
825 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
825 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
826 | * |
|
826 | * | |
827 | */ |
|
827 | */ | |
828 |
|
828 | |||
829 | int status; |
|
829 | int status; | |
830 |
|
830 | |||
831 | status = LFR_SUCCESSFUL; |
|
831 | status = LFR_SUCCESSFUL; | |
832 |
|
832 | |||
833 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
833 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
834 |
|
834 | |||
835 | return status; |
|
835 | return status; | |
836 | } |
|
836 | } | |
837 |
|
837 | |||
838 | //********************* |
|
838 | //********************* | |
839 | // SBM1 MODE PARAMETERS |
|
839 | // SBM1 MODE PARAMETERS | |
840 |
|
840 | |||
841 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
841 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
842 | { |
|
842 | { | |
843 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
843 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
844 | * |
|
844 | * | |
845 | * @param TC points to the TeleCommand packet that is being processed |
|
845 | * @param TC points to the TeleCommand packet that is being processed | |
846 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
846 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
847 | * |
|
847 | * | |
848 | */ |
|
848 | */ | |
849 |
|
849 | |||
850 | int status; |
|
850 | int status; | |
851 |
|
851 | |||
852 | status = LFR_SUCCESSFUL; |
|
852 | status = LFR_SUCCESSFUL; | |
853 |
|
853 | |||
854 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
854 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
855 |
|
855 | |||
856 | return status; |
|
856 | return status; | |
857 | } |
|
857 | } | |
858 |
|
858 | |||
859 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
859 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
860 | { |
|
860 | { | |
861 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
861 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
862 | * |
|
862 | * | |
863 | * @param TC points to the TeleCommand packet that is being processed |
|
863 | * @param TC points to the TeleCommand packet that is being processed | |
864 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
864 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
865 | * |
|
865 | * | |
866 | */ |
|
866 | */ | |
867 |
|
867 | |||
868 | int status; |
|
868 | int status; | |
869 |
|
869 | |||
870 | status = LFR_SUCCESSFUL; |
|
870 | status = LFR_SUCCESSFUL; | |
871 |
|
871 | |||
872 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
872 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
873 |
|
873 | |||
874 | return status; |
|
874 | return status; | |
875 | } |
|
875 | } | |
876 |
|
876 | |||
877 | //********************* |
|
877 | //********************* | |
878 | // SBM2 MODE PARAMETERS |
|
878 | // SBM2 MODE PARAMETERS | |
879 |
|
879 | |||
880 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
880 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
881 | { |
|
881 | { | |
882 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
882 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
883 | * |
|
883 | * | |
884 | * @param TC points to the TeleCommand packet that is being processed |
|
884 | * @param TC points to the TeleCommand packet that is being processed | |
885 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
885 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
886 | * |
|
886 | * | |
887 | */ |
|
887 | */ | |
888 |
|
888 | |||
889 | int status; |
|
889 | int status; | |
890 |
|
890 | |||
891 | status = LFR_SUCCESSFUL; |
|
891 | status = LFR_SUCCESSFUL; | |
892 |
|
892 | |||
893 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
893 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
894 |
|
894 | |||
895 | return status; |
|
895 | return status; | |
896 | } |
|
896 | } | |
897 |
|
897 | |||
898 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
898 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
899 | { |
|
899 | { | |
900 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
900 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
901 | * |
|
901 | * | |
902 | * @param TC points to the TeleCommand packet that is being processed |
|
902 | * @param TC points to the TeleCommand packet that is being processed | |
903 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
903 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
904 | * |
|
904 | * | |
905 | */ |
|
905 | */ | |
906 |
|
906 | |||
907 | int status; |
|
907 | int status; | |
908 |
|
908 | |||
909 | status = LFR_SUCCESSFUL; |
|
909 | status = LFR_SUCCESSFUL; | |
910 |
|
910 | |||
911 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
911 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
912 |
|
912 | |||
913 | return status; |
|
913 | return status; | |
914 | } |
|
914 | } | |
915 |
|
915 | |||
916 | //******************* |
|
916 | //******************* | |
917 | // TC_LFR_UPDATE_INFO |
|
917 | // TC_LFR_UPDATE_INFO | |
918 |
|
918 | |||
919 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
919 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
920 | { |
|
920 | { | |
921 | unsigned int status; |
|
921 | unsigned int status; | |
922 |
|
922 | |||
923 | status = LFR_DEFAULT; |
|
923 | status = LFR_DEFAULT; | |
924 |
|
924 | |||
925 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
925 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
926 | || (mode == LFR_MODE_BURST) |
|
926 | || (mode == LFR_MODE_BURST) | |
927 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
927 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
928 | { |
|
928 | { | |
929 | status = LFR_SUCCESSFUL; |
|
929 | status = LFR_SUCCESSFUL; | |
930 | } |
|
930 | } | |
931 | else |
|
931 | else | |
932 | { |
|
932 | { | |
933 | status = LFR_DEFAULT; |
|
933 | status = LFR_DEFAULT; | |
934 | } |
|
934 | } | |
935 |
|
935 | |||
936 | return status; |
|
936 | return status; | |
937 | } |
|
937 | } | |
938 |
|
938 | |||
939 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
939 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
940 | { |
|
940 | { | |
941 | unsigned int status; |
|
941 | unsigned int status; | |
942 |
|
942 | |||
943 | status = LFR_DEFAULT; |
|
943 | status = LFR_DEFAULT; | |
944 |
|
944 | |||
945 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
945 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
946 | || (mode == TDS_MODE_BURST) |
|
946 | || (mode == TDS_MODE_BURST) | |
947 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
947 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
948 | || (mode == TDS_MODE_LFM)) |
|
948 | || (mode == TDS_MODE_LFM)) | |
949 | { |
|
949 | { | |
950 | status = LFR_SUCCESSFUL; |
|
950 | status = LFR_SUCCESSFUL; | |
951 | } |
|
951 | } | |
952 | else |
|
952 | else | |
953 | { |
|
953 | { | |
954 | status = LFR_DEFAULT; |
|
954 | status = LFR_DEFAULT; | |
955 | } |
|
955 | } | |
956 |
|
956 | |||
957 | return status; |
|
957 | return status; | |
958 | } |
|
958 | } | |
959 |
|
959 | |||
960 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
960 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
961 | { |
|
961 | { | |
962 | unsigned int status; |
|
962 | unsigned int status; | |
963 |
|
963 | |||
964 | status = LFR_DEFAULT; |
|
964 | status = LFR_DEFAULT; | |
965 |
|
965 | |||
966 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
966 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
967 | || (mode == THR_MODE_BURST)) |
|
967 | || (mode == THR_MODE_BURST)) | |
968 | { |
|
968 | { | |
969 | status = LFR_SUCCESSFUL; |
|
969 | status = LFR_SUCCESSFUL; | |
970 | } |
|
970 | } | |
971 | else |
|
971 | else | |
972 | { |
|
972 | { | |
973 | status = LFR_DEFAULT; |
|
973 | status = LFR_DEFAULT; | |
974 | } |
|
974 | } | |
975 |
|
975 | |||
976 | return status; |
|
976 | return status; | |
977 | } |
|
977 | } | |
978 |
|
978 | |||
979 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) |
|
979 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) | |
980 | { |
|
980 | { | |
981 | unsigned char flag; |
|
981 | unsigned char flag; | |
982 | unsigned char flagPosInByte; |
|
982 | unsigned char flagPosInByte; | |
983 | unsigned char newFlag; |
|
983 | unsigned char newFlag; | |
984 | unsigned char flagMask; |
|
984 | unsigned char flagMask; | |
985 |
|
985 | |||
986 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered |
|
986 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered | |
987 | if (isnan(value)) |
|
987 | if (isnan(value)) | |
988 | { |
|
988 | { | |
989 | flag = FLAG_NAN; |
|
989 | flag = FLAG_NAN; | |
990 | } |
|
990 | } | |
991 | else |
|
991 | else | |
992 | { |
|
992 | { | |
993 | flag = FLAG_IAN; |
|
993 | flag = FLAG_IAN; | |
994 | } |
|
994 | } | |
995 |
|
995 | |||
996 | switch(wheel) |
|
996 | switch(wheel) | |
997 | { |
|
997 | { | |
998 | case WHEEL_1: |
|
998 | case WHEEL_1: | |
999 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
999 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
1000 | flagMask = ~(1 << flagPosInByte); |
|
1000 | flagMask = ~(1 << flagPosInByte); | |
1001 | newFlag = flag << flagPosInByte; |
|
1001 | newFlag = flag << flagPosInByte; | |
1002 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
1002 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
1003 | break; |
|
1003 | break; | |
1004 | case WHEEL_2: |
|
1004 | case WHEEL_2: | |
1005 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
1005 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
1006 | flagMask = ~(1 << flagPosInByte); |
|
1006 | flagMask = ~(1 << flagPosInByte); | |
1007 | newFlag = flag << flagPosInByte; |
|
1007 | newFlag = flag << flagPosInByte; | |
1008 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
1008 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
1009 | break; |
|
1009 | break; | |
1010 | case WHEEL_3: |
|
1010 | case WHEEL_3: | |
1011 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
1011 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
1012 | flagMask = ~(1 << flagPosInByte); |
|
1012 | flagMask = ~(1 << flagPosInByte); | |
1013 | newFlag = flag << flagPosInByte; |
|
1013 | newFlag = flag << flagPosInByte; | |
1014 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1014 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1015 | break; |
|
1015 | break; | |
1016 | case WHEEL_4: |
|
1016 | case WHEEL_4: | |
1017 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
1017 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
1018 | flagMask = ~(1 << flagPosInByte); |
|
1018 | flagMask = ~(1 << flagPosInByte); | |
1019 | newFlag = flag << flagPosInByte; |
|
1019 | newFlag = flag << flagPosInByte; | |
1020 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1020 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1021 | break; |
|
1021 | break; | |
1022 | default: |
|
1022 | default: | |
1023 | break; |
|
1023 | break; | |
1024 | } |
|
1024 | } | |
1025 | } |
|
1025 | } | |
1026 |
|
1026 | |||
1027 | void set_hk_lfr_sc_rw_f_flags( void ) |
|
1027 | void set_hk_lfr_sc_rw_f_flags( void ) | |
1028 | { |
|
1028 | { | |
1029 | // RW1 |
|
1029 | // RW1 | |
1030 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); |
|
1030 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); | |
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); |
|
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); | |
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); |
|
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); | |
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); |
|
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); | |
1034 |
|
1034 | |||
1035 | // RW2 |
|
1035 | // RW2 | |
1036 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); |
|
1036 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); | |
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); |
|
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); | |
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); |
|
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); | |
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); |
|
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); | |
1040 |
|
1040 | |||
1041 | // RW3 |
|
1041 | // RW3 | |
1042 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); |
|
1042 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); | |
1043 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); |
|
1043 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); | |
1044 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); |
|
1044 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); | |
1045 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); |
|
1045 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); | |
1046 |
|
1046 | |||
1047 | // RW4 |
|
1047 | // RW4 | |
1048 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); |
|
1048 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); | |
1049 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); |
|
1049 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); | |
1050 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); |
|
1050 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); | |
1051 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); |
|
1051 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); | |
1052 | } |
|
1052 | } | |
1053 |
|
1053 | |||
1054 | int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ) |
|
1054 | int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ) | |
1055 | { |
|
1055 | { | |
1056 | float rw_k; |
|
1056 | float rw_k; | |
1057 | int ret; |
|
1057 | int ret; | |
1058 |
|
1058 | |||
1059 | ret = LFR_SUCCESSFUL; |
|
1059 | ret = LFR_SUCCESSFUL; | |
1060 | rw_k = INIT_FLOAT; |
|
1060 | rw_k = INIT_FLOAT; | |
1061 |
|
1061 | |||
1062 | copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->packetID[ offset ] ); |
|
1062 | copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->packetID[ offset ] ); | |
1063 |
|
1063 | |||
1064 | *pos = offset; |
|
1064 | *pos = offset; | |
1065 | *value = rw_k; |
|
1065 | *value = rw_k; | |
1066 |
|
1066 | |||
1067 | if (rw_k < MIN_SY_LFR_RW_F) |
|
1067 | if (rw_k < MIN_SY_LFR_RW_F) | |
1068 | { |
|
1068 | { | |
1069 | ret = WRONG_APP_DATA; |
|
1069 | ret = WRONG_APP_DATA; | |
1070 | } |
|
1070 | } | |
1071 |
|
1071 | |||
1072 | return ret; |
|
1072 | return ret; | |
1073 | } |
|
1073 | } | |
1074 |
|
1074 | |||
1075 | int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value ) |
|
1075 | int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value ) | |
1076 | { |
|
1076 | { | |
1077 | int ret; |
|
1077 | int ret; | |
1078 |
|
1078 | |||
1079 | ret = LFR_SUCCESSFUL; |
|
1079 | ret = LFR_SUCCESSFUL; | |
1080 |
|
1080 | |||
1081 | //**** |
|
1081 | //**** | |
1082 | //**** |
|
1082 | //**** | |
1083 | // RW1 |
|
1083 | // RW1 | |
1084 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1, pos, value ); // F1 |
|
1084 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1, pos, value ); // F1 | |
1085 | if (ret == LFR_SUCCESSFUL) // F2 |
|
1085 | if (ret == LFR_SUCCESSFUL) // F2 | |
1086 | { |
|
1086 | { | |
1087 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2, pos, value ); |
|
1087 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2, pos, value ); | |
1088 | } |
|
1088 | } | |
1089 | if (ret == LFR_SUCCESSFUL) // F3 |
|
1089 | if (ret == LFR_SUCCESSFUL) // F3 | |
1090 | { |
|
1090 | { | |
1091 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3, pos, value ); |
|
1091 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3, pos, value ); | |
1092 | } |
|
1092 | } | |
1093 | if (ret == LFR_SUCCESSFUL) // F4 |
|
1093 | if (ret == LFR_SUCCESSFUL) // F4 | |
1094 | { |
|
1094 | { | |
1095 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4, pos, value ); |
|
1095 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4, pos, value ); | |
1096 | } |
|
1096 | } | |
1097 |
|
1097 | |||
1098 | //**** |
|
1098 | //**** | |
1099 | //**** |
|
1099 | //**** | |
1100 | // RW2 |
|
1100 | // RW2 | |
1101 | if (ret == LFR_SUCCESSFUL) // F1 |
|
1101 | if (ret == LFR_SUCCESSFUL) // F1 | |
1102 | { |
|
1102 | { | |
1103 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1, pos, value ); |
|
1103 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1, pos, value ); | |
1104 | } |
|
1104 | } | |
1105 | if (ret == LFR_SUCCESSFUL) // F2 |
|
1105 | if (ret == LFR_SUCCESSFUL) // F2 | |
1106 | { |
|
1106 | { | |
1107 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2, pos, value ); |
|
1107 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2, pos, value ); | |
1108 | } |
|
1108 | } | |
1109 | if (ret == LFR_SUCCESSFUL) // F3 |
|
1109 | if (ret == LFR_SUCCESSFUL) // F3 | |
1110 | { |
|
1110 | { | |
1111 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3, pos, value ); |
|
1111 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3, pos, value ); | |
1112 | } |
|
1112 | } | |
1113 | if (ret == LFR_SUCCESSFUL) // F4 |
|
1113 | if (ret == LFR_SUCCESSFUL) // F4 | |
1114 | { |
|
1114 | { | |
1115 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4, pos, value ); |
|
1115 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4, pos, value ); | |
1116 | } |
|
1116 | } | |
1117 |
|
1117 | |||
1118 | //**** |
|
1118 | //**** | |
1119 | //**** |
|
1119 | //**** | |
1120 | // RW3 |
|
1120 | // RW3 | |
1121 | if (ret == LFR_SUCCESSFUL) // F1 |
|
1121 | if (ret == LFR_SUCCESSFUL) // F1 | |
1122 | { |
|
1122 | { | |
1123 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1, pos, value ); |
|
1123 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1, pos, value ); | |
1124 | } |
|
1124 | } | |
1125 | if (ret == LFR_SUCCESSFUL) // F2 |
|
1125 | if (ret == LFR_SUCCESSFUL) // F2 | |
1126 | { |
|
1126 | { | |
1127 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2, pos, value ); |
|
1127 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2, pos, value ); | |
1128 | } |
|
1128 | } | |
1129 | if (ret == LFR_SUCCESSFUL) // F3 |
|
1129 | if (ret == LFR_SUCCESSFUL) // F3 | |
1130 | { |
|
1130 | { | |
1131 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3, pos, value ); |
|
1131 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3, pos, value ); | |
1132 | } |
|
1132 | } | |
1133 | if (ret == LFR_SUCCESSFUL) // F4 |
|
1133 | if (ret == LFR_SUCCESSFUL) // F4 | |
1134 | { |
|
1134 | { | |
1135 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4, pos, value ); |
|
1135 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4, pos, value ); | |
1136 | } |
|
1136 | } | |
1137 |
|
1137 | |||
1138 | //**** |
|
1138 | //**** | |
1139 | //**** |
|
1139 | //**** | |
1140 | // RW4 |
|
1140 | // RW4 | |
1141 | if (ret == LFR_SUCCESSFUL) // F1 |
|
1141 | if (ret == LFR_SUCCESSFUL) // F1 | |
1142 | { |
|
1142 | { | |
1143 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1, pos, value ); |
|
1143 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1, pos, value ); | |
1144 | } |
|
1144 | } | |
1145 | if (ret == LFR_SUCCESSFUL) // F2 |
|
1145 | if (ret == LFR_SUCCESSFUL) // F2 | |
1146 | { |
|
1146 | { | |
1147 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2, pos, value ); |
|
1147 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2, pos, value ); | |
1148 | } |
|
1148 | } | |
1149 | if (ret == LFR_SUCCESSFUL) // F3 |
|
1149 | if (ret == LFR_SUCCESSFUL) // F3 | |
1150 | { |
|
1150 | { | |
1151 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3, pos, value ); |
|
1151 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3, pos, value ); | |
1152 | } |
|
1152 | } | |
1153 | if (ret == LFR_SUCCESSFUL) // F4 |
|
1153 | if (ret == LFR_SUCCESSFUL) // F4 | |
1154 | { |
|
1154 | { | |
1155 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4, pos, value ); |
|
1155 | ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4, pos, value ); | |
1156 | } |
|
1156 | } | |
1157 |
|
1157 | |||
1158 | return ret; |
|
1158 | return ret; | |
1159 | } |
|
1159 | } | |
1160 |
|
1160 | |||
1161 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) |
|
1161 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) | |
1162 | { |
|
1162 | { | |
1163 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. |
|
1163 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. | |
1164 | * |
|
1164 | * | |
1165 | * @param TC points to the TeleCommand packet that is being processed |
|
1165 | * @param TC points to the TeleCommand packet that is being processed | |
1166 | * |
|
1166 | * | |
1167 | */ |
|
1167 | */ | |
1168 |
|
1168 | |||
1169 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet |
|
1169 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet | |
1170 |
|
1170 | |||
1171 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
1171 | bytePosPtr = (unsigned char *) &TC->packetID; | |
1172 |
|
1172 | |||
1173 | // rw1_f |
|
1173 | // rw1_f | |
1174 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); |
|
1174 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); | |
1175 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); |
|
1175 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); | |
1176 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); |
|
1176 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); | |
1177 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); |
|
1177 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); | |
1178 |
|
1178 | |||
1179 | // rw2_f |
|
1179 | // rw2_f | |
1180 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); |
|
1180 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); | |
1181 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); |
|
1181 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); | |
1182 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); |
|
1182 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); | |
1183 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); |
|
1183 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); | |
1184 |
|
1184 | |||
1185 | // rw3_f |
|
1185 | // rw3_f | |
1186 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); |
|
1186 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); | |
1187 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); |
|
1187 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); | |
1188 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); |
|
1188 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); | |
1189 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); |
|
1189 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); | |
1190 |
|
1190 | |||
1191 | // rw4_f |
|
1191 | // rw4_f | |
1192 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); |
|
1192 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); | |
1193 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); |
|
1193 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); | |
1194 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); |
|
1194 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); | |
1195 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); |
|
1195 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); | |
1196 |
|
1196 | |||
1197 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered |
|
1197 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered | |
1198 |
|
1198 | |||
1199 | } |
|
1199 | } | |
1200 |
|
1200 | |||
1201 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ) |
|
1201 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ) | |
1202 | { |
|
1202 | { | |
1203 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
1203 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
1204 | * |
|
1204 | * | |
1205 | * @param fbins_mask |
|
1205 | * @param fbins_mask | |
1206 | * @param rw_f is the reaction wheel frequency to filter |
|
1206 | * @param rw_f is the reaction wheel frequency to filter | |
1207 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel |
|
1207 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel | |
1208 | * @param flag [true] filtering enabled [false] filtering disabled |
|
1208 | * @param flag [true] filtering enabled [false] filtering disabled | |
1209 | * |
|
1209 | * | |
1210 | * @return void |
|
1210 | * @return void | |
1211 | * |
|
1211 | * | |
1212 | */ |
|
1212 | */ | |
1213 |
|
1213 | |||
1214 | float f_RW_min; |
|
1214 | float f_RW_min; | |
1215 | float f_RW_MAX; |
|
1215 | float f_RW_MAX; | |
1216 | float fi_min; |
|
1216 | float fi_min; | |
1217 | float fi_MAX; |
|
1217 | float fi_MAX; | |
1218 | float fi; |
|
1218 | float fi; | |
1219 | float deltaBelow; |
|
1219 | float deltaBelow; | |
1220 | float deltaAbove; |
|
1220 | float deltaAbove; | |
1221 | float freqToFilterOut; |
|
1221 | float freqToFilterOut; | |
1222 | int binBelow; |
|
1222 | int binBelow; | |
1223 | int binAbove; |
|
1223 | int binAbove; | |
1224 | int closestBin; |
|
1224 | int closestBin; | |
1225 | unsigned int whichByte; |
|
1225 | unsigned int whichByte; | |
1226 | int selectedByte; |
|
1226 | int selectedByte; | |
1227 | int bin; |
|
1227 | int bin; | |
1228 | int binToRemove[NB_BINS_TO_REMOVE]; |
|
1228 | int binToRemove[NB_BINS_TO_REMOVE]; | |
1229 | int k; |
|
1229 | int k; | |
1230 | bool filteringSet; |
|
1230 | bool filteringSet; | |
1231 |
|
1231 | |||
1232 | closestBin = 0; |
|
1232 | closestBin = 0; | |
1233 | whichByte = 0; |
|
1233 | whichByte = 0; | |
1234 | bin = 0; |
|
1234 | bin = 0; | |
1235 | filteringSet = false; |
|
1235 | filteringSet = false; | |
1236 |
|
1236 | |||
1237 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) |
|
1237 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) | |
1238 | { |
|
1238 | { | |
1239 | binToRemove[k] = -1; |
|
1239 | binToRemove[k] = -1; | |
1240 | } |
|
1240 | } | |
1241 |
|
1241 | |||
1242 | if (!isnan(rw_f)) |
|
1242 | if (!isnan(rw_f)) | |
1243 | { |
|
1243 | { | |
1244 | // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ] |
|
1244 | // compute the frequency range to filter [ rw_f - delta_f; rw_f + delta_f ] | |
1245 | f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); |
|
1245 | f_RW_min = rw_f - ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); | |
1246 | f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); |
|
1246 | f_RW_MAX = rw_f + ((filterPar.sy_lfr_sc_rw_delta_f) * sy_lfr_rw_k); | |
1247 |
|
1247 | |||
1248 | freqToFilterOut = f_RW_min; |
|
1248 | freqToFilterOut = f_RW_min; | |
1249 | while ( filteringSet == false ) |
|
1249 | while ( filteringSet == false ) | |
1250 | { |
|
1250 | { | |
1251 | // compute the index of the frequency bin immediately below rw_f |
|
1251 | // compute the index of the frequency bin immediately below rw_f | |
1252 | binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) ); |
|
1252 | binBelow = (int) ( floor( ((double) freqToFilterOut) / ((double) deltaFreq)) ); | |
1253 | deltaBelow = freqToFilterOut - binBelow * deltaFreq; |
|
1253 | deltaBelow = freqToFilterOut - binBelow * deltaFreq; | |
1254 |
|
1254 | |||
1255 | // compute the index of the frequency bin immediately above rw_f |
|
1255 | // compute the index of the frequency bin immediately above rw_f | |
1256 | binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) ); |
|
1256 | binAbove = (int) ( ceil( ((double) freqToFilterOut) / ((double) deltaFreq)) ); | |
1257 | deltaAbove = binAbove * deltaFreq - freqToFilterOut; |
|
1257 | deltaAbove = binAbove * deltaFreq - freqToFilterOut; | |
1258 |
|
1258 | |||
1259 | // search the closest bin |
|
1259 | // search the closest bin | |
1260 | if (deltaAbove > deltaBelow) |
|
1260 | if (deltaAbove > deltaBelow) | |
1261 | { |
|
1261 | { | |
1262 | closestBin = binBelow; |
|
1262 | closestBin = binBelow; | |
1263 | } |
|
1263 | } | |
1264 | else |
|
1264 | else | |
1265 | { |
|
1265 | { | |
1266 | closestBin = binAbove; |
|
1266 | closestBin = binAbove; | |
1267 | } |
|
1267 | } | |
1268 |
|
1268 | |||
1269 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] |
|
1269 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] | |
1270 | fi = closestBin * deltaFreq; |
|
1270 | fi = closestBin * deltaFreq; | |
1271 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); |
|
1271 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); | |
1272 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); |
|
1272 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); | |
1273 |
|
1273 | |||
1274 | //************************************************************************************** |
|
1274 | //************************************************************************************** | |
1275 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra |
|
1275 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra | |
1276 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum |
|
1276 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum | |
1277 | //************************************************************************************** |
|
1277 | //************************************************************************************** | |
1278 |
|
1278 | |||
1279 | // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ] |
|
1279 | // 1. IF freqToFilterOut is included in [ fi_min; fi_MAX ] | |
1280 | // => remove f_(i), f_(i-1) and f_(i+1) |
|
1280 | // => remove f_(i), f_(i-1) and f_(i+1) | |
1281 | if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) ) |
|
1281 | if ( ( freqToFilterOut > fi_min ) && ( freqToFilterOut < fi_MAX ) ) | |
1282 | { |
|
1282 | { | |
1283 | binToRemove[0] = (closestBin - 1) - 1; |
|
1283 | binToRemove[0] = (closestBin - 1) - 1; | |
1284 | binToRemove[1] = (closestBin) - 1; |
|
1284 | binToRemove[1] = (closestBin) - 1; | |
1285 | binToRemove[2] = (closestBin + 1) - 1; |
|
1285 | binToRemove[2] = (closestBin + 1) - 1; | |
1286 | } |
|
1286 | } | |
1287 | // 2. ELSE |
|
1287 | // 2. ELSE | |
1288 | // => remove the two f_(i) which are around f_RW |
|
1288 | // => remove the two f_(i) which are around f_RW | |
1289 | else |
|
1289 | else | |
1290 | { |
|
1290 | { | |
1291 | binToRemove[0] = (binBelow) - 1; |
|
1291 | binToRemove[0] = (binBelow) - 1; | |
1292 | binToRemove[1] = (binAbove) - 1; |
|
1292 | binToRemove[1] = (binAbove) - 1; | |
1293 | binToRemove[2] = (-1); |
|
1293 | binToRemove[2] = (-1); | |
1294 | } |
|
1294 | } | |
1295 |
|
1295 | |||
1296 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) |
|
1296 | for (k = 0; k < NB_BINS_TO_REMOVE; k++) | |
1297 | { |
|
1297 | { | |
1298 | bin = binToRemove[k]; |
|
1298 | bin = binToRemove[k]; | |
1299 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) |
|
1299 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) | |
1300 | { |
|
1300 | { | |
1301 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 |
|
1301 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 | |
1302 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); |
|
1302 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); | |
1303 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = |
|
1303 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = | |
1304 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets |
|
1304 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets | |
1305 |
|
1305 | |||
1306 | } |
|
1306 | } | |
1307 | } |
|
1307 | } | |
1308 |
|
1308 | |||
1309 | // update freqToFilterOut |
|
1309 | // update freqToFilterOut | |
1310 | if ( freqToFilterOut == f_RW_MAX ) |
|
1310 | if ( freqToFilterOut == f_RW_MAX ) | |
1311 | { |
|
1311 | { | |
1312 | filteringSet = true; // end of the loop |
|
1312 | filteringSet = true; // end of the loop | |
1313 | } |
|
1313 | } | |
1314 | else |
|
1314 | else | |
1315 | { |
|
1315 | { | |
1316 | freqToFilterOut = freqToFilterOut + deltaFreq; |
|
1316 | freqToFilterOut = freqToFilterOut + deltaFreq; | |
1317 | } |
|
1317 | } | |
1318 |
|
1318 | |||
1319 | if ( freqToFilterOut > f_RW_MAX) |
|
1319 | if ( freqToFilterOut > f_RW_MAX) | |
1320 | { |
|
1320 | { | |
1321 | freqToFilterOut = f_RW_MAX; |
|
1321 | freqToFilterOut = f_RW_MAX; | |
1322 | } |
|
1322 | } | |
1323 | } |
|
1323 | } | |
1324 | } |
|
1324 | } | |
1325 | } |
|
1325 | } | |
1326 |
|
1326 | |||
1327 | void build_sy_lfr_rw_mask( unsigned int channel ) |
|
1327 | void build_sy_lfr_rw_mask( unsigned int channel ) | |
1328 | { |
|
1328 | { | |
1329 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; |
|
1329 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; | |
1330 | unsigned char *maskPtr; |
|
1330 | unsigned char *maskPtr; | |
1331 | double deltaF; |
|
1331 | double deltaF; | |
1332 | unsigned k; |
|
1332 | unsigned k; | |
1333 |
|
1333 | |||
1334 | maskPtr = NULL; |
|
1334 | maskPtr = NULL; | |
1335 | deltaF = DELTAF_F2; |
|
1335 | deltaF = DELTAF_F2; | |
1336 |
|
1336 | |||
1337 | switch (channel) |
|
1337 | switch (channel) | |
1338 | { |
|
1338 | { | |
1339 | case CHANNELF0: |
|
1339 | case CHANNELF0: | |
1340 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1340 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1341 | deltaF = DELTAF_F0; |
|
1341 | deltaF = DELTAF_F0; | |
1342 | break; |
|
1342 | break; | |
1343 | case CHANNELF1: |
|
1343 | case CHANNELF1: | |
1344 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1344 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1345 | deltaF = DELTAF_F1; |
|
1345 | deltaF = DELTAF_F1; | |
1346 | break; |
|
1346 | break; | |
1347 | case CHANNELF2: |
|
1347 | case CHANNELF2: | |
1348 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1348 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1349 | deltaF = DELTAF_F2; |
|
1349 | deltaF = DELTAF_F2; | |
1350 | break; |
|
1350 | break; | |
1351 | default: |
|
1351 | default: | |
1352 | break; |
|
1352 | break; | |
1353 | } |
|
1353 | } | |
1354 |
|
1354 | |||
1355 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1355 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1356 | { |
|
1356 | { | |
1357 | local_rw_fbins_mask[k] = INT8_ALL_F; |
|
1357 | local_rw_fbins_mask[k] = INT8_ALL_F; | |
1358 | } |
|
1358 | } | |
1359 |
|
1359 | |||
1360 | // RW1 |
|
1360 | // RW1 | |
1361 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); |
|
1361 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); | |
1362 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); |
|
1362 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); | |
1363 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); |
|
1363 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); | |
1364 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); |
|
1364 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); | |
1365 |
|
1365 | |||
1366 | // RW2 |
|
1366 | // RW2 | |
1367 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); |
|
1367 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); | |
1368 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); |
|
1368 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); | |
1369 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); |
|
1369 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); | |
1370 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); |
|
1370 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); | |
1371 |
|
1371 | |||
1372 | // RW3 |
|
1372 | // RW3 | |
1373 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); |
|
1373 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); | |
1374 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); |
|
1374 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); | |
1375 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); |
|
1375 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); | |
1376 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); |
|
1376 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); | |
1377 |
|
1377 | |||
1378 | // RW4 |
|
1378 | // RW4 | |
1379 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); |
|
1379 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); | |
1380 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); |
|
1380 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); | |
1381 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); |
|
1381 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); | |
1382 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); |
|
1382 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); | |
1383 |
|
1383 | |||
1384 | // update the value of the fbins related to reaction wheels frequency filtering |
|
1384 | // update the value of the fbins related to reaction wheels frequency filtering | |
1385 | if (maskPtr != NULL) |
|
1385 | if (maskPtr != NULL) | |
1386 | { |
|
1386 | { | |
1387 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1387 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1388 | { |
|
1388 | { | |
1389 | maskPtr[k] = local_rw_fbins_mask[k]; |
|
1389 | maskPtr[k] = local_rw_fbins_mask[k]; | |
1390 | } |
|
1390 | } | |
1391 | } |
|
1391 | } | |
1392 | } |
|
1392 | } | |
1393 |
|
1393 | |||
1394 | void build_sy_lfr_rw_masks( void ) |
|
1394 | void build_sy_lfr_rw_masks( void ) | |
1395 | { |
|
1395 | { | |
1396 | build_sy_lfr_rw_mask( CHANNELF0 ); |
|
1396 | build_sy_lfr_rw_mask( CHANNELF0 ); | |
1397 | build_sy_lfr_rw_mask( CHANNELF1 ); |
|
1397 | build_sy_lfr_rw_mask( CHANNELF1 ); | |
1398 | build_sy_lfr_rw_mask( CHANNELF2 ); |
|
1398 | build_sy_lfr_rw_mask( CHANNELF2 ); | |
1399 | } |
|
1399 | } | |
1400 |
|
1400 | |||
1401 | void merge_fbins_masks( void ) |
|
1401 | void merge_fbins_masks( void ) | |
1402 | { |
|
1402 | { | |
1403 | unsigned char k; |
|
1403 | unsigned char k; | |
1404 |
|
1404 | |||
1405 | unsigned char *fbins_f0; |
|
1405 | unsigned char *fbins_f0; | |
1406 | unsigned char *fbins_f1; |
|
1406 | unsigned char *fbins_f1; | |
1407 | unsigned char *fbins_f2; |
|
1407 | unsigned char *fbins_f2; | |
1408 | unsigned char *rw_mask_f0; |
|
1408 | unsigned char *rw_mask_f0; | |
1409 | unsigned char *rw_mask_f1; |
|
1409 | unsigned char *rw_mask_f1; | |
1410 | unsigned char *rw_mask_f2; |
|
1410 | unsigned char *rw_mask_f2; | |
1411 |
|
1411 | |||
1412 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1412 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1413 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
1413 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; | |
1414 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
1414 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; | |
1415 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1415 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1416 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1416 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1417 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1417 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1418 |
|
1418 | |||
1419 | for( k=0; k < BYTES_PER_MASK; k++ ) |
|
1419 | for( k=0; k < BYTES_PER_MASK; k++ ) | |
1420 | { |
|
1420 | { | |
1421 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; |
|
1421 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; | |
1422 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; |
|
1422 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; | |
1423 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; |
|
1423 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; | |
1424 | } |
|
1424 | } | |
1425 | } |
|
1425 | } | |
1426 |
|
1426 | |||
1427 | //*********** |
|
1427 | //*********** | |
1428 | // FBINS MASK |
|
1428 | // FBINS MASK | |
1429 |
|
1429 | |||
1430 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
1430 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
1431 | { |
|
1431 | { | |
1432 | int status; |
|
1432 | int status; | |
1433 | unsigned int k; |
|
1433 | unsigned int k; | |
1434 | unsigned char *fbins_mask_dump; |
|
1434 | unsigned char *fbins_mask_dump; | |
1435 | unsigned char *fbins_mask_TC; |
|
1435 | unsigned char *fbins_mask_TC; | |
1436 |
|
1436 | |||
1437 | status = LFR_SUCCESSFUL; |
|
1437 | status = LFR_SUCCESSFUL; | |
1438 |
|
1438 | |||
1439 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1439 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1440 | fbins_mask_TC = TC->dataAndCRC; |
|
1440 | fbins_mask_TC = TC->dataAndCRC; | |
1441 |
|
1441 | |||
1442 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1442 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1443 | { |
|
1443 | { | |
1444 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
1444 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
1445 | } |
|
1445 | } | |
1446 |
|
1446 | |||
1447 | return status; |
|
1447 | return status; | |
1448 | } |
|
1448 | } | |
1449 |
|
1449 | |||
1450 | //*************************** |
|
1450 | //*************************** | |
1451 | // TC_LFR_LOAD_PAS_FILTER_PAR |
|
1451 | // TC_LFR_LOAD_PAS_FILTER_PAR | |
1452 |
|
1452 | |||
1453 | int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ) |
|
1453 | int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ) | |
1454 | { |
|
1454 | { | |
1455 | float rw_k; |
|
1455 | float rw_k; | |
1456 | int ret; |
|
1456 | int ret; | |
1457 |
|
1457 | |||
1458 | ret = LFR_SUCCESSFUL; |
|
1458 | ret = LFR_SUCCESSFUL; | |
1459 | rw_k = INIT_FLOAT; |
|
1459 | rw_k = INIT_FLOAT; | |
1460 |
|
1460 | |||
1461 | copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->dataAndCRC[ offset ] ); |
|
1461 | copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->dataAndCRC[ offset ] ); | |
1462 |
|
1462 | |||
1463 | *pos = offset; |
|
1463 | *pos = offset; | |
1464 | *value = rw_k; |
|
1464 | *value = rw_k; | |
1465 |
|
1465 | |||
1466 | if (rw_k < MIN_SY_LFR_RW_F) |
|
1466 | if (rw_k < MIN_SY_LFR_RW_F) | |
1467 | { |
|
1467 | { | |
1468 | ret = WRONG_APP_DATA; |
|
1468 | ret = WRONG_APP_DATA; | |
1469 | } |
|
1469 | } | |
1470 |
|
1470 | |||
1471 | return ret; |
|
1471 | return ret; | |
1472 | } |
|
1472 | } | |
1473 |
|
1473 | |||
1474 | int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float *value ) |
|
1474 | int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float *value ) | |
1475 | { |
|
1475 | { | |
1476 | int ret; |
|
1476 | int ret; | |
1477 |
|
1477 | |||
1478 | ret = LFR_SUCCESSFUL; |
|
1478 | ret = LFR_SUCCESSFUL; | |
1479 |
|
1479 | |||
1480 | //**** |
|
1480 | //**** | |
1481 | //**** |
|
1481 | //**** | |
1482 | // RW1 |
|
1482 | // RW1 | |
1483 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K1, pos, value ); // K1 |
|
1483 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K1, pos, value ); // K1 | |
1484 | if (ret == LFR_SUCCESSFUL) // K2 |
|
1484 | if (ret == LFR_SUCCESSFUL) // K2 | |
1485 | { |
|
1485 | { | |
1486 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K2, pos, value ); |
|
1486 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K2, pos, value ); | |
1487 | } |
|
1487 | } | |
1488 | if (ret == LFR_SUCCESSFUL) // K3 |
|
1488 | if (ret == LFR_SUCCESSFUL) // K3 | |
1489 | { |
|
1489 | { | |
1490 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K3, pos, value ); |
|
1490 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K3, pos, value ); | |
1491 | } |
|
1491 | } | |
1492 | if (ret == LFR_SUCCESSFUL) // K4 |
|
1492 | if (ret == LFR_SUCCESSFUL) // K4 | |
1493 | { |
|
1493 | { | |
1494 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K4, pos, value ); |
|
1494 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW1_K4, pos, value ); | |
1495 | } |
|
1495 | } | |
1496 |
|
1496 | |||
1497 | //**** |
|
1497 | //**** | |
1498 | //**** |
|
1498 | //**** | |
1499 | // RW2 |
|
1499 | // RW2 | |
1500 | if (ret == LFR_SUCCESSFUL) // K1 |
|
1500 | if (ret == LFR_SUCCESSFUL) // K1 | |
1501 | { |
|
1501 | { | |
1502 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K1, pos, value ); |
|
1502 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K1, pos, value ); | |
1503 | } |
|
1503 | } | |
1504 | if (ret == LFR_SUCCESSFUL) // K2 |
|
1504 | if (ret == LFR_SUCCESSFUL) // K2 | |
1505 | { |
|
1505 | { | |
1506 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K2, pos, value ); |
|
1506 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K2, pos, value ); | |
1507 | } |
|
1507 | } | |
1508 | if (ret == LFR_SUCCESSFUL) // K3 |
|
1508 | if (ret == LFR_SUCCESSFUL) // K3 | |
1509 | { |
|
1509 | { | |
1510 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K3, pos, value ); |
|
1510 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K3, pos, value ); | |
1511 | } |
|
1511 | } | |
1512 | if (ret == LFR_SUCCESSFUL) // K4 |
|
1512 | if (ret == LFR_SUCCESSFUL) // K4 | |
1513 | { |
|
1513 | { | |
1514 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K4, pos, value ); |
|
1514 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW2_K4, pos, value ); | |
1515 | } |
|
1515 | } | |
1516 |
|
1516 | |||
1517 | //**** |
|
1517 | //**** | |
1518 | //**** |
|
1518 | //**** | |
1519 | // RW3 |
|
1519 | // RW3 | |
1520 | if (ret == LFR_SUCCESSFUL) // K1 |
|
1520 | if (ret == LFR_SUCCESSFUL) // K1 | |
1521 | { |
|
1521 | { | |
1522 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K1, pos, value ); |
|
1522 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K1, pos, value ); | |
1523 | } |
|
1523 | } | |
1524 | if (ret == LFR_SUCCESSFUL) // K2 |
|
1524 | if (ret == LFR_SUCCESSFUL) // K2 | |
1525 | { |
|
1525 | { | |
1526 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K2, pos, value ); |
|
1526 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K2, pos, value ); | |
1527 | } |
|
1527 | } | |
1528 | if (ret == LFR_SUCCESSFUL) // K3 |
|
1528 | if (ret == LFR_SUCCESSFUL) // K3 | |
1529 | { |
|
1529 | { | |
1530 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K3, pos, value ); |
|
1530 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K3, pos, value ); | |
1531 | } |
|
1531 | } | |
1532 | if (ret == LFR_SUCCESSFUL) // K4 |
|
1532 | if (ret == LFR_SUCCESSFUL) // K4 | |
1533 | { |
|
1533 | { | |
1534 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K4, pos, value ); |
|
1534 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW3_K4, pos, value ); | |
1535 | } |
|
1535 | } | |
1536 |
|
1536 | |||
1537 | //**** |
|
1537 | //**** | |
1538 | //**** |
|
1538 | //**** | |
1539 | // RW4 |
|
1539 | // RW4 | |
1540 | if (ret == LFR_SUCCESSFUL) // K1 |
|
1540 | if (ret == LFR_SUCCESSFUL) // K1 | |
1541 | { |
|
1541 | { | |
1542 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K1, pos, value ); |
|
1542 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K1, pos, value ); | |
1543 | } |
|
1543 | } | |
1544 | if (ret == LFR_SUCCESSFUL) // K2 |
|
1544 | if (ret == LFR_SUCCESSFUL) // K2 | |
1545 | { |
|
1545 | { | |
1546 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K2, pos, value ); |
|
1546 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K2, pos, value ); | |
1547 | } |
|
1547 | } | |
1548 | if (ret == LFR_SUCCESSFUL) // K3 |
|
1548 | if (ret == LFR_SUCCESSFUL) // K3 | |
1549 | { |
|
1549 | { | |
1550 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K3, pos, value ); |
|
1550 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K3, pos, value ); | |
1551 | } |
|
1551 | } | |
1552 | if (ret == LFR_SUCCESSFUL) // K4 |
|
1552 | if (ret == LFR_SUCCESSFUL) // K4 | |
1553 | { |
|
1553 | { | |
1554 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value ); |
|
1554 | ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value ); | |
1555 | } |
|
1555 | } | |
1556 |
|
1556 | |||
1557 | return ret; |
|
1557 | return ret; | |
1558 | } |
|
1558 | } | |
1559 |
|
1559 | |||
1560 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
1560 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
1561 | { |
|
1561 | { | |
1562 | int flag; |
|
1562 | int flag; | |
1563 | rtems_status_code status; |
|
1563 | rtems_status_code status; | |
1564 |
|
1564 | |||
1565 | unsigned char sy_lfr_pas_filter_enabled; |
|
1565 | unsigned char sy_lfr_pas_filter_enabled; | |
1566 | unsigned char sy_lfr_pas_filter_modulus; |
|
1566 | unsigned char sy_lfr_pas_filter_modulus; | |
1567 | float sy_lfr_pas_filter_tbad; |
|
1567 | float sy_lfr_pas_filter_tbad; | |
1568 | unsigned char sy_lfr_pas_filter_offset; |
|
1568 | unsigned char sy_lfr_pas_filter_offset; | |
1569 | float sy_lfr_pas_filter_shift; |
|
1569 | float sy_lfr_pas_filter_shift; | |
1570 | float sy_lfr_sc_rw_delta_f; |
|
1570 | float sy_lfr_sc_rw_delta_f; | |
1571 | char *parPtr; |
|
1571 | char *parPtr; | |
1572 | int datafield_pos; |
|
1572 | int datafield_pos; | |
1573 | float rw_k; |
|
1573 | float rw_k; | |
1574 |
|
1574 | |||
1575 | flag = LFR_SUCCESSFUL; |
|
1575 | flag = LFR_SUCCESSFUL; | |
1576 | sy_lfr_pas_filter_tbad = INIT_FLOAT; |
|
1576 | sy_lfr_pas_filter_tbad = INIT_FLOAT; | |
1577 | sy_lfr_pas_filter_shift = INIT_FLOAT; |
|
1577 | sy_lfr_pas_filter_shift = INIT_FLOAT; | |
1578 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; |
|
1578 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; | |
1579 | parPtr = NULL; |
|
1579 | parPtr = NULL; | |
1580 | datafield_pos = INIT_INT; |
|
1580 | datafield_pos = INIT_INT; | |
1581 | rw_k = INIT_FLOAT; |
|
1581 | rw_k = INIT_FLOAT; | |
1582 |
|
1582 | |||
1583 | //*************** |
|
1583 | //*************** | |
1584 | // get parameters |
|
1584 | // get parameters | |
1585 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] |
|
1585 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] | |
1586 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
1586 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
1587 | copyFloatByChar( |
|
1587 | copyFloatByChar( | |
1588 | (unsigned char*) &sy_lfr_pas_filter_tbad, |
|
1588 | (unsigned char*) &sy_lfr_pas_filter_tbad, | |
1589 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] |
|
1589 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] | |
1590 | ); |
|
1590 | ); | |
1591 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
1591 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
1592 | copyFloatByChar( |
|
1592 | copyFloatByChar( | |
1593 | (unsigned char*) &sy_lfr_pas_filter_shift, |
|
1593 | (unsigned char*) &sy_lfr_pas_filter_shift, | |
1594 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] |
|
1594 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] | |
1595 | ); |
|
1595 | ); | |
1596 | copyFloatByChar( |
|
1596 | copyFloatByChar( | |
1597 | (unsigned char*) &sy_lfr_sc_rw_delta_f, |
|
1597 | (unsigned char*) &sy_lfr_sc_rw_delta_f, | |
1598 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] |
|
1598 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] | |
1599 | ); |
|
1599 | ); | |
1600 |
|
1600 | |||
1601 | //****************** |
|
1601 | //****************** | |
1602 | // CHECK CONSISTENCY |
|
1602 | // CHECK CONSISTENCY | |
1603 |
|
1603 | |||
1604 | //************************** |
|
1604 | //************************** | |
1605 | // sy_lfr_pas_filter_enabled |
|
1605 | // sy_lfr_pas_filter_enabled | |
1606 | // nothing to check, value is 0 or 1 |
|
1606 | // nothing to check, value is 0 or 1 | |
1607 |
|
1607 | |||
1608 | //************************** |
|
1608 | //************************** | |
1609 | // sy_lfr_pas_filter_modulus |
|
1609 | // sy_lfr_pas_filter_modulus | |
1610 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) |
|
1610 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) | |
1611 | { |
|
1611 | { | |
1612 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1612 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1613 | flag = WRONG_APP_DATA; |
|
1613 | flag = WRONG_APP_DATA; | |
1614 | } |
|
1614 | } | |
1615 |
|
1615 | |||
1616 | //*********************** |
|
1616 | //*********************** | |
1617 | // sy_lfr_pas_filter_tbad |
|
1617 | // sy_lfr_pas_filter_tbad | |
1618 | if (flag == LFR_SUCCESSFUL) |
|
1618 | if (flag == LFR_SUCCESSFUL) | |
1619 | { |
|
1619 | { | |
1620 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) |
|
1620 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) | |
1621 | { |
|
1621 | { | |
1622 | parPtr = (char*) &sy_lfr_pas_filter_tbad; |
|
1622 | parPtr = (char*) &sy_lfr_pas_filter_tbad; | |
1623 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1623 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1624 | flag = WRONG_APP_DATA; |
|
1624 | flag = WRONG_APP_DATA; | |
1625 | } |
|
1625 | } | |
1626 | } |
|
1626 | } | |
1627 |
|
1627 | |||
1628 | //************************* |
|
1628 | //************************* | |
1629 | // sy_lfr_pas_filter_offset |
|
1629 | // sy_lfr_pas_filter_offset | |
1630 | if (flag == LFR_SUCCESSFUL) |
|
1630 | if (flag == LFR_SUCCESSFUL) | |
1631 | { |
|
1631 | { | |
1632 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) |
|
1632 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) | |
1633 | { |
|
1633 | { | |
1634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); |
|
1634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); | |
1635 | flag = WRONG_APP_DATA; |
|
1635 | flag = WRONG_APP_DATA; | |
1636 | } |
|
1636 | } | |
1637 | } |
|
1637 | } | |
1638 |
|
1638 | |||
1639 | //************************ |
|
1639 | //************************ | |
1640 | // sy_lfr_pas_filter_shift |
|
1640 | // sy_lfr_pas_filter_shift | |
1641 | if (flag == LFR_SUCCESSFUL) |
|
1641 | if (flag == LFR_SUCCESSFUL) | |
1642 | { |
|
1642 | { | |
1643 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) |
|
1643 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) | |
1644 | { |
|
1644 | { | |
1645 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1645 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1646 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1646 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1647 | flag = WRONG_APP_DATA; |
|
1647 | flag = WRONG_APP_DATA; | |
1648 | } |
|
1648 | } | |
1649 | } |
|
1649 | } | |
1650 |
|
1650 | |||
1651 | //************************************* |
|
1651 | //************************************* | |
1652 | // check global coherency of the values |
|
1652 | // check global coherency of the values | |
1653 | if (flag == LFR_SUCCESSFUL) |
|
1653 | if (flag == LFR_SUCCESSFUL) | |
1654 | { |
|
1654 | { | |
1655 | if ( (sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) >= sy_lfr_pas_filter_modulus ) |
|
1655 | if ( (sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) >= sy_lfr_pas_filter_modulus ) | |
1656 | { |
|
1656 | { | |
1657 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1657 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1658 | flag = WRONG_APP_DATA; |
|
1658 | flag = WRONG_APP_DATA; | |
1659 | } |
|
1659 | } | |
1660 | } |
|
1660 | } | |
1661 |
|
1661 | |||
1662 | //********************* |
|
1662 | //********************* | |
1663 | // sy_lfr_sc_rw_delta_f |
|
1663 | // sy_lfr_sc_rw_delta_f | |
1664 | if (flag == LFR_SUCCESSFUL) |
|
1664 | if (flag == LFR_SUCCESSFUL) | |
1665 | { |
|
1665 | { | |
1666 | if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F ) |
|
1666 | if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F ) | |
1667 | { |
|
1667 | { | |
1668 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1668 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1669 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, sy_lfr_sc_rw_delta_f ); |
|
1669 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, sy_lfr_sc_rw_delta_f ); | |
1670 | flag = WRONG_APP_DATA; |
|
1670 | flag = WRONG_APP_DATA; | |
1671 | } |
|
1671 | } | |
1672 | } |
|
1672 | } | |
1673 |
|
1673 | |||
1674 | //************ |
|
1674 | //************ | |
1675 | // sy_lfr_rw_k |
|
1675 | // sy_lfr_rw_k | |
1676 | if (flag == LFR_SUCCESSFUL) |
|
1676 | if (flag == LFR_SUCCESSFUL) | |
1677 | { |
|
1677 | { | |
1678 | flag = check_all_sy_lfr_rw_k( TC, &datafield_pos, &rw_k ); |
|
1678 | flag = check_all_sy_lfr_rw_k( TC, &datafield_pos, &rw_k ); | |
1679 | if (flag != LFR_SUCCESSFUL) |
|
1679 | if (flag != LFR_SUCCESSFUL) | |
1680 | { |
|
1680 | { | |
1681 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1681 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1682 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, datafield_pos + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1682 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, datafield_pos + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1683 | } |
|
1683 | } | |
1684 | } |
|
1684 | } | |
1685 |
|
1685 | |||
1686 | return flag; |
|
1686 | return flag; | |
1687 | } |
|
1687 | } | |
1688 |
|
1688 | |||
1689 | //************** |
|
1689 | //************** | |
1690 | // KCOEFFICIENTS |
|
1690 | // KCOEFFICIENTS | |
1691 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
1691 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
1692 | { |
|
1692 | { | |
1693 | unsigned int kcoeff; |
|
1693 | unsigned int kcoeff; | |
1694 | unsigned short sy_lfr_kcoeff_frequency; |
|
1694 | unsigned short sy_lfr_kcoeff_frequency; | |
1695 | unsigned short bin; |
|
1695 | unsigned short bin; | |
1696 | float *kcoeffPtr_norm; |
|
1696 | float *kcoeffPtr_norm; | |
1697 | float *kcoeffPtr_sbm; |
|
1697 | float *kcoeffPtr_sbm; | |
1698 | int status; |
|
1698 | int status; | |
1699 | unsigned char *kcoeffLoadPtr; |
|
1699 | unsigned char *kcoeffLoadPtr; | |
1700 | unsigned char *kcoeffNormPtr; |
|
1700 | unsigned char *kcoeffNormPtr; | |
1701 | unsigned char *kcoeffSbmPtr_a; |
|
1701 | unsigned char *kcoeffSbmPtr_a; | |
1702 | unsigned char *kcoeffSbmPtr_b; |
|
1702 | unsigned char *kcoeffSbmPtr_b; | |
1703 |
|
1703 | |||
1704 | sy_lfr_kcoeff_frequency = 0; |
|
1704 | sy_lfr_kcoeff_frequency = 0; | |
1705 | bin = 0; |
|
1705 | bin = 0; | |
1706 | kcoeffPtr_norm = NULL; |
|
1706 | kcoeffPtr_norm = NULL; | |
1707 | kcoeffPtr_sbm = NULL; |
|
1707 | kcoeffPtr_sbm = NULL; | |
1708 | status = LFR_SUCCESSFUL; |
|
1708 | status = LFR_SUCCESSFUL; | |
1709 |
|
1709 | |||
1710 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER |
|
1710 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER | |
1711 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); |
|
1711 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); | |
1712 |
|
1712 | |||
1713 |
|
1713 | |||
1714 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
1714 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
1715 | { |
|
1715 | { | |
1716 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
1716 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
1717 |
status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET |
|
1717 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET, | |
1718 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
1718 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
1719 | status = LFR_DEFAULT; |
|
1719 | status = LFR_DEFAULT; | |
1720 | } |
|
1720 | } | |
1721 | else |
|
1721 | else | |
1722 | { |
|
1722 | { | |
1723 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1723 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
1724 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1724 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
1725 | { |
|
1725 | { | |
1726 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1726 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
1727 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1727 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
1728 | bin = sy_lfr_kcoeff_frequency; |
|
1728 | bin = sy_lfr_kcoeff_frequency; | |
1729 | } |
|
1729 | } | |
1730 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1730 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
1731 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1731 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
1732 | { |
|
1732 | { | |
1733 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1733 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
1734 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1734 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
1735 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1735 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
1736 | } |
|
1736 | } | |
1737 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1737 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
1738 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1738 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
1739 | { |
|
1739 | { | |
1740 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1740 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
1741 | kcoeffPtr_sbm = NULL; |
|
1741 | kcoeffPtr_sbm = NULL; | |
1742 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1742 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
1743 | } |
|
1743 | } | |
1744 | } |
|
1744 | } | |
1745 |
|
1745 | |||
1746 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1746 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
1747 | { |
|
1747 | { | |
1748 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1748 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1749 | { |
|
1749 | { | |
1750 | // destination |
|
1750 | // destination | |
1751 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1751 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
1752 | // source |
|
1752 | // source | |
1753 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1753 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1754 | // copy source to destination |
|
1754 | // copy source to destination | |
1755 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1755 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
1756 | } |
|
1756 | } | |
1757 | } |
|
1757 | } | |
1758 |
|
1758 | |||
1759 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1759 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
1760 | { |
|
1760 | { | |
1761 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1761 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1762 | { |
|
1762 | { | |
1763 | // destination |
|
1763 | // destination | |
1764 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; |
|
1764 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; | |
1765 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; |
|
1765 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; | |
1766 | // source |
|
1766 | // source | |
1767 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1767 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1768 | // copy source to destination |
|
1768 | // copy source to destination | |
1769 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1769 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
1770 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1770 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
1771 | } |
|
1771 | } | |
1772 | } |
|
1772 | } | |
1773 |
|
1773 | |||
1774 | // print_k_coeff(); |
|
1774 | // print_k_coeff(); | |
1775 |
|
1775 | |||
1776 | return status; |
|
1776 | return status; | |
1777 | } |
|
1777 | } | |
1778 |
|
1778 | |||
1779 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1779 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
1780 | { |
|
1780 | { | |
1781 | destination[BYTE_0] = source[BYTE_0]; |
|
1781 | destination[BYTE_0] = source[BYTE_0]; | |
1782 | destination[BYTE_1] = source[BYTE_1]; |
|
1782 | destination[BYTE_1] = source[BYTE_1]; | |
1783 | destination[BYTE_2] = source[BYTE_2]; |
|
1783 | destination[BYTE_2] = source[BYTE_2]; | |
1784 | destination[BYTE_3] = source[BYTE_3]; |
|
1784 | destination[BYTE_3] = source[BYTE_3]; | |
1785 | } |
|
1785 | } | |
1786 |
|
1786 | |||
1787 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) |
|
1787 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) | |
1788 | { |
|
1788 | { | |
1789 | destination[BYTE_0] = source[BYTE_0]; |
|
1789 | destination[BYTE_0] = source[BYTE_0]; | |
1790 | destination[BYTE_1] = source[BYTE_1]; |
|
1790 | destination[BYTE_1] = source[BYTE_1]; | |
1791 | destination[BYTE_2] = source[BYTE_2]; |
|
1791 | destination[BYTE_2] = source[BYTE_2]; | |
1792 | destination[BYTE_3] = source[BYTE_3]; |
|
1792 | destination[BYTE_3] = source[BYTE_3]; | |
1793 | } |
|
1793 | } | |
1794 |
|
1794 | |||
1795 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) |
|
1795 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) | |
1796 | { |
|
1796 | { | |
1797 | destination[BYTE_0] = source[BYTE_0]; |
|
1797 | destination[BYTE_0] = source[BYTE_0]; | |
1798 | destination[BYTE_1] = source[BYTE_1]; |
|
1798 | destination[BYTE_1] = source[BYTE_1]; | |
1799 | } |
|
1799 | } | |
1800 |
|
1800 | |||
1801 | void floatToChar( float value, unsigned char* ptr) |
|
1801 | void floatToChar( float value, unsigned char* ptr) | |
1802 | { |
|
1802 | { | |
1803 | unsigned char* valuePtr; |
|
1803 | unsigned char* valuePtr; | |
1804 |
|
1804 | |||
1805 | valuePtr = (unsigned char*) &value; |
|
1805 | valuePtr = (unsigned char*) &value; | |
1806 |
|
1806 | |||
1807 | ptr[BYTE_0] = valuePtr[BYTE_0]; |
|
1807 | ptr[BYTE_0] = valuePtr[BYTE_0]; | |
1808 | ptr[BYTE_1] = valuePtr[BYTE_1]; |
|
1808 | ptr[BYTE_1] = valuePtr[BYTE_1]; | |
1809 | ptr[BYTE_2] = valuePtr[BYTE_2]; |
|
1809 | ptr[BYTE_2] = valuePtr[BYTE_2]; | |
1810 | ptr[BYTE_3] = valuePtr[BYTE_3]; |
|
1810 | ptr[BYTE_3] = valuePtr[BYTE_3]; | |
1811 | } |
|
1811 | } | |
1812 |
|
1812 | |||
1813 | //********** |
|
1813 | //********** | |
1814 | // init dump |
|
1814 | // init dump | |
1815 |
|
1815 | |||
1816 | void init_parameter_dump( void ) |
|
1816 | void init_parameter_dump( void ) | |
1817 | { |
|
1817 | { | |
1818 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1818 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1819 | * |
|
1819 | * | |
1820 | */ |
|
1820 | */ | |
1821 |
|
1821 | |||
1822 | unsigned int k; |
|
1822 | unsigned int k; | |
1823 |
|
1823 | |||
1824 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1824 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1825 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1825 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1826 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1826 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1827 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1827 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1828 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1828 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1829 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1829 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1830 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1830 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1831 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1831 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1832 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1832 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1833 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1833 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1834 | // DATA FIELD HEADER |
|
1834 | // DATA FIELD HEADER | |
1835 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1835 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1836 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1836 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1837 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1837 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1838 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1838 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1839 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
1839 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
1840 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
1840 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
1841 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
1841 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
1842 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
1842 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
1843 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
1843 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
1844 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
1844 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
1845 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1845 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1846 |
|
1846 | |||
1847 | //****************** |
|
1847 | //****************** | |
1848 | // COMMON PARAMETERS |
|
1848 | // COMMON PARAMETERS | |
1849 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1849 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1850 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1850 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1851 |
|
1851 | |||
1852 | //****************** |
|
1852 | //****************** | |
1853 | // NORMAL PARAMETERS |
|
1853 | // NORMAL PARAMETERS | |
1854 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); |
|
1854 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); | |
1855 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1855 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1856 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); |
|
1856 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); | |
1857 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1857 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1858 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); |
|
1858 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); | |
1859 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1859 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1860 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1860 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1861 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1861 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1862 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1862 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1863 |
|
1863 | |||
1864 | //***************** |
|
1864 | //***************** | |
1865 | // BURST PARAMETERS |
|
1865 | // BURST PARAMETERS | |
1866 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1866 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1867 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1867 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1868 |
|
1868 | |||
1869 | //**************** |
|
1869 | //**************** | |
1870 | // SBM1 PARAMETERS |
|
1870 | // SBM1 PARAMETERS | |
1871 | 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 |
|
1871 | 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 | |
1872 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1872 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1873 |
|
1873 | |||
1874 | //**************** |
|
1874 | //**************** | |
1875 | // SBM2 PARAMETERS |
|
1875 | // SBM2 PARAMETERS | |
1876 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1876 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1877 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1877 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1878 |
|
1878 | |||
1879 | //************ |
|
1879 | //************ | |
1880 | // FBINS MASKS |
|
1880 | // FBINS MASKS | |
1881 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1881 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1882 | { |
|
1882 | { | |
1883 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; |
|
1883 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; | |
1884 | } |
|
1884 | } | |
1885 |
|
1885 | |||
1886 | // PAS FILTER PARAMETERS |
|
1886 | // PAS FILTER PARAMETERS | |
1887 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; |
|
1887 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; | |
1888 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; |
|
1888 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; | |
1889 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
1889 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; | |
1890 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
1890 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
1891 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
1891 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; | |
1892 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
1892 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
1893 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
1893 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
1894 |
|
1894 | |||
1895 | // RW1_K |
|
1895 | // RW1_K | |
1896 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); |
|
1896 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); | |
1897 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); |
|
1897 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); | |
1898 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); |
|
1898 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); | |
1899 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); |
|
1899 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); | |
1900 | // RW2_K |
|
1900 | // RW2_K | |
1901 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); |
|
1901 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); | |
1902 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); |
|
1902 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); | |
1903 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); |
|
1903 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); | |
1904 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); |
|
1904 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); | |
1905 | // RW3_K |
|
1905 | // RW3_K | |
1906 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); |
|
1906 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); | |
1907 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); |
|
1907 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); | |
1908 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); |
|
1908 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); | |
1909 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); |
|
1909 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); | |
1910 | // RW4_K |
|
1910 | // RW4_K | |
1911 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); |
|
1911 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); | |
1912 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); |
|
1912 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); | |
1913 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); |
|
1913 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); | |
1914 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); |
|
1914 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); | |
1915 |
|
1915 | |||
1916 | // LFR_RW_MASK |
|
1916 | // LFR_RW_MASK | |
1917 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1917 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1918 | { |
|
1918 | { | |
1919 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; |
|
1919 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; | |
1920 | } |
|
1920 | } | |
1921 |
|
1921 | |||
1922 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks |
|
1922 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks | |
1923 | merge_fbins_masks(); |
|
1923 | merge_fbins_masks(); | |
1924 | } |
|
1924 | } | |
1925 |
|
1925 | |||
1926 | void init_kcoefficients_dump( void ) |
|
1926 | void init_kcoefficients_dump( void ) | |
1927 | { |
|
1927 | { | |
1928 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); |
|
1928 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); | |
1929 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); |
|
1929 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); | |
1930 |
|
1930 | |||
1931 | kcoefficient_node_1.previous = NULL; |
|
1931 | kcoefficient_node_1.previous = NULL; | |
1932 | kcoefficient_node_1.next = NULL; |
|
1932 | kcoefficient_node_1.next = NULL; | |
1933 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1933 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1934 | kcoefficient_node_1.coarseTime = INIT_CHAR; |
|
1934 | kcoefficient_node_1.coarseTime = INIT_CHAR; | |
1935 | kcoefficient_node_1.fineTime = INIT_CHAR; |
|
1935 | kcoefficient_node_1.fineTime = INIT_CHAR; | |
1936 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1936 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1937 | kcoefficient_node_1.status = INIT_CHAR; |
|
1937 | kcoefficient_node_1.status = INIT_CHAR; | |
1938 |
|
1938 | |||
1939 | kcoefficient_node_2.previous = NULL; |
|
1939 | kcoefficient_node_2.previous = NULL; | |
1940 | kcoefficient_node_2.next = NULL; |
|
1940 | kcoefficient_node_2.next = NULL; | |
1941 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1941 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1942 | kcoefficient_node_2.coarseTime = INIT_CHAR; |
|
1942 | kcoefficient_node_2.coarseTime = INIT_CHAR; | |
1943 | kcoefficient_node_2.fineTime = INIT_CHAR; |
|
1943 | kcoefficient_node_2.fineTime = INIT_CHAR; | |
1944 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1944 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1945 | kcoefficient_node_2.status = INIT_CHAR; |
|
1945 | kcoefficient_node_2.status = INIT_CHAR; | |
1946 | } |
|
1946 | } | |
1947 |
|
1947 | |||
1948 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1948 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1949 | { |
|
1949 | { | |
1950 | unsigned int k; |
|
1950 | unsigned int k; | |
1951 | unsigned int packetLength; |
|
1951 | unsigned int packetLength; | |
1952 |
|
1952 | |||
1953 | packetLength = |
|
1953 | packetLength = | |
1954 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1954 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1955 |
|
1955 | |||
1956 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1956 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1957 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1957 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1958 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1958 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1959 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1959 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1960 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1960 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1961 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1961 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1962 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1962 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1963 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1963 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1964 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); |
|
1964 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); | |
1965 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1965 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1966 | // DATA FIELD HEADER |
|
1966 | // DATA FIELD HEADER | |
1967 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1967 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1968 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1968 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1969 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1969 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1970 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1970 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1971 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; |
|
1971 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; | |
1972 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; |
|
1972 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; | |
1973 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; |
|
1973 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; | |
1974 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; |
|
1974 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; | |
1975 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; |
|
1975 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; | |
1976 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; |
|
1976 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; | |
1977 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1977 | kcoefficients_dump->sid = SID_K_DUMP; | |
1978 |
|
1978 | |||
1979 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; |
|
1979 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; | |
1980 | kcoefficients_dump->pkt_nr = PKTNR_1; |
|
1980 | kcoefficients_dump->pkt_nr = PKTNR_1; | |
1981 | kcoefficients_dump->blk_nr = blk_nr; |
|
1981 | kcoefficients_dump->blk_nr = blk_nr; | |
1982 |
|
1982 | |||
1983 | //****************** |
|
1983 | //****************** | |
1984 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1984 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1985 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1985 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1986 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) |
|
1986 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) | |
1987 | { |
|
1987 | { | |
1988 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; |
|
1988 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; | |
1989 | } |
|
1989 | } | |
1990 | } |
|
1990 | } | |
1991 |
|
1991 | |||
1992 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1992 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1993 | { |
|
1993 | { | |
1994 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1994 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1995 | * |
|
1995 | * | |
1996 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1996 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1997 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1997 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1998 | * |
|
1998 | * | |
1999 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1999 | * If the destination ID is not known, a dedicated counter is incremented. | |
2000 | * |
|
2000 | * | |
2001 | */ |
|
2001 | */ | |
2002 |
|
2002 | |||
2003 | unsigned short sequence_cnt; |
|
2003 | unsigned short sequence_cnt; | |
2004 | unsigned short segmentation_grouping_flag; |
|
2004 | unsigned short segmentation_grouping_flag; | |
2005 | unsigned short new_packet_sequence_control; |
|
2005 | unsigned short new_packet_sequence_control; | |
2006 | unsigned char i; |
|
2006 | unsigned char i; | |
2007 |
|
2007 | |||
2008 | switch (destination_id) |
|
2008 | switch (destination_id) | |
2009 | { |
|
2009 | { | |
2010 | case SID_TC_GROUND: |
|
2010 | case SID_TC_GROUND: | |
2011 | i = GROUND; |
|
2011 | i = GROUND; | |
2012 | break; |
|
2012 | break; | |
2013 | case SID_TC_MISSION_TIMELINE: |
|
2013 | case SID_TC_MISSION_TIMELINE: | |
2014 | i = MISSION_TIMELINE; |
|
2014 | i = MISSION_TIMELINE; | |
2015 | break; |
|
2015 | break; | |
2016 | case SID_TC_TC_SEQUENCES: |
|
2016 | case SID_TC_TC_SEQUENCES: | |
2017 | i = TC_SEQUENCES; |
|
2017 | i = TC_SEQUENCES; | |
2018 | break; |
|
2018 | break; | |
2019 | case SID_TC_RECOVERY_ACTION_CMD: |
|
2019 | case SID_TC_RECOVERY_ACTION_CMD: | |
2020 | i = RECOVERY_ACTION_CMD; |
|
2020 | i = RECOVERY_ACTION_CMD; | |
2021 | break; |
|
2021 | break; | |
2022 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
2022 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
2023 | i = BACKUP_MISSION_TIMELINE; |
|
2023 | i = BACKUP_MISSION_TIMELINE; | |
2024 | break; |
|
2024 | break; | |
2025 | case SID_TC_DIRECT_CMD: |
|
2025 | case SID_TC_DIRECT_CMD: | |
2026 | i = DIRECT_CMD; |
|
2026 | i = DIRECT_CMD; | |
2027 | break; |
|
2027 | break; | |
2028 | case SID_TC_SPARE_GRD_SRC1: |
|
2028 | case SID_TC_SPARE_GRD_SRC1: | |
2029 | i = SPARE_GRD_SRC1; |
|
2029 | i = SPARE_GRD_SRC1; | |
2030 | break; |
|
2030 | break; | |
2031 | case SID_TC_SPARE_GRD_SRC2: |
|
2031 | case SID_TC_SPARE_GRD_SRC2: | |
2032 | i = SPARE_GRD_SRC2; |
|
2032 | i = SPARE_GRD_SRC2; | |
2033 | break; |
|
2033 | break; | |
2034 | case SID_TC_OBCP: |
|
2034 | case SID_TC_OBCP: | |
2035 | i = OBCP; |
|
2035 | i = OBCP; | |
2036 | break; |
|
2036 | break; | |
2037 | case SID_TC_SYSTEM_CONTROL: |
|
2037 | case SID_TC_SYSTEM_CONTROL: | |
2038 | i = SYSTEM_CONTROL; |
|
2038 | i = SYSTEM_CONTROL; | |
2039 | break; |
|
2039 | break; | |
2040 | case SID_TC_AOCS: |
|
2040 | case SID_TC_AOCS: | |
2041 | i = AOCS; |
|
2041 | i = AOCS; | |
2042 | break; |
|
2042 | break; | |
2043 | case SID_TC_RPW_INTERNAL: |
|
2043 | case SID_TC_RPW_INTERNAL: | |
2044 | i = RPW_INTERNAL; |
|
2044 | i = RPW_INTERNAL; | |
2045 | break; |
|
2045 | break; | |
2046 | default: |
|
2046 | default: | |
2047 | i = GROUND; |
|
2047 | i = GROUND; | |
2048 | break; |
|
2048 | break; | |
2049 | } |
|
2049 | } | |
2050 |
|
2050 | |||
2051 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
2051 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
2052 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; |
|
2052 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; | |
2053 |
|
2053 | |||
2054 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
2054 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
2055 |
|
2055 | |||
2056 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
2056 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
2057 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
2057 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
2058 |
|
2058 | |||
2059 | // increment the sequence counter |
|
2059 | // increment the sequence counter | |
2060 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
2060 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
2061 | { |
|
2061 | { | |
2062 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
2062 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
2063 | } |
|
2063 | } | |
2064 | else |
|
2064 | else | |
2065 | { |
|
2065 | { | |
2066 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
2066 | sequenceCounters_TM_DUMP[ i ] = 0; | |
2067 | } |
|
2067 | } | |
2068 | } |
|
2068 | } |
General Comments 0
You need to be logged in to leave comments.
Login now