##// END OF EJS Templates
Message queue implemented for valid TC processing...
paul@pc-solar1.lab-lpp.local -
r9:515486994c1d default
parent child
Show More
@@ -1,69 +1,69
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_project_file>
2 <CodeBlocks_project_file>
3 <FileVersion major="1" minor="6" />
3 <FileVersion major="1" minor="6" />
4 <Project>
4 <Project>
5 <Option title="FSW-rtems" />
5 <Option title="FSW-rtems" />
6 <Option pch_mode="2" />
6 <Option pch_mode="2" />
7 <Option compiler="sparcrtemsgcc446" />
7 <Option compiler="sparcrtemsgcc446" />
8 <Build>
8 <Build>
9 <Target title="Debug">
9 <Target title="Debug">
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
11 <Option object_output="obj/Debug/" />
11 <Option object_output="obj/Debug/" />
12 <Option type="1" />
12 <Option type="1" />
13 <Option compiler="sparcrtems446" />
13 <Option compiler="sparcrtemsgcc446" />
14 <Compiler>
14 <Compiler>
15 <Add option="-fexpensive-optimizations" />
15 <Add option="-fexpensive-optimizations" />
16 <Add option="-O3" />
16 <Add option="-O3" />
17 <Add option="-g" />
17 <Add option="-g" />
18 <Add directory="../header" />
18 <Add directory="../header" />
19 <Add directory="../src" />
19 <Add directory="../src" />
20 </Compiler>
20 </Compiler>
21 </Target>
21 </Target>
22 <Target title="Release">
22 <Target title="Release">
23 <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" />
23 <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" />
24 <Option object_output="obj/Release/" />
24 <Option object_output="obj/Release/" />
25 <Option type="1" />
25 <Option type="1" />
26 <Option compiler="sparcrtemsgcc446" />
26 <Option compiler="sparcrtemsgcc446" />
27 <Compiler>
27 <Compiler>
28 <Add option="-O2" />
28 <Add option="-O2" />
29 </Compiler>
29 </Compiler>
30 <Linker>
30 <Linker>
31 <Add option="-s" />
31 <Add option="-s" />
32 </Linker>
32 </Linker>
33 </Target>
33 </Target>
34 </Build>
34 </Build>
35 <Compiler>
35 <Compiler>
36 <Add option="-Wall" />
36 <Add option="-Wall" />
37 </Compiler>
37 </Compiler>
38 <Unit filename="../header/ccsds_types.h" />
38 <Unit filename="../header/ccsds_types.h" />
39 <Unit filename="../header/fsw_init.h" />
39 <Unit filename="../header/fsw_init.h" />
40 <Unit filename="../header/fsw_misc.h" />
40 <Unit filename="../header/fsw_misc.h" />
41 <Unit filename="../header/fsw_params.h" />
41 <Unit filename="../header/fsw_params.h" />
42 <Unit filename="../header/fsw_processing.h" />
42 <Unit filename="../header/fsw_processing.h" />
43 <Unit filename="../header/grlib_regs.h" />
43 <Unit filename="../header/grlib_regs.h" />
44 <Unit filename="../header/tc_handler.h" />
44 <Unit filename="../header/tc_handler.h" />
45 <Unit filename="../header/wf_handler.h" />
45 <Unit filename="../header/wf_handler.h" />
46 <Unit filename="../src/fsw_globals.c">
46 <Unit filename="../src/fsw_globals.c">
47 <Option compilerVar="CC" />
47 <Option compilerVar="CC" />
48 </Unit>
48 </Unit>
49 <Unit filename="../src/fsw_init.c">
49 <Unit filename="../src/fsw_init.c">
50 <Option compilerVar="CC" />
50 <Option compilerVar="CC" />
51 </Unit>
51 </Unit>
52 <Unit filename="../src/fsw_misc.c">
52 <Unit filename="../src/fsw_misc.c">
53 <Option compilerVar="CC" />
53 <Option compilerVar="CC" />
54 </Unit>
54 </Unit>
55 <Unit filename="../src/fsw_processing.c">
55 <Unit filename="../src/fsw_processing.c">
56 <Option compilerVar="CC" />
56 <Option compilerVar="CC" />
57 </Unit>
57 </Unit>
58 <Unit filename="../src/tc_handler.c">
58 <Unit filename="../src/tc_handler.c">
59 <Option compilerVar="CC" />
59 <Option compilerVar="CC" />
60 </Unit>
60 </Unit>
61 <Unit filename="../src/wf_handler.c">
61 <Unit filename="../src/wf_handler.c">
62 <Option compilerVar="CC" />
62 <Option compilerVar="CC" />
63 </Unit>
63 </Unit>
64 <Extensions>
64 <Extensions>
65 <code_completion />
65 <code_completion />
66 <debugger />
66 <debugger />
67 </Extensions>
67 </Extensions>
68 </Project>
68 </Project>
69 </CodeBlocks_project_file>
69 </CodeBlocks_project_file>
@@ -1,192 +1,226
1 # depslib dependency file v1.0
1 # depslib dependency file v1.0
2 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c
2 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c
3 <rtems.h>
3 <rtems.h>
4 <bsp.h>
4 <bsp.h>
5 <rtems/confdefs.h>
5 <rtems/confdefs.h>
6 <drvmgr/drvmgr_confdefs.h>
6 <drvmgr/drvmgr_confdefs.h>
7 <rtems.h>
7 <rtems.h>
8 <errno.h>
8 <errno.h>
9 <fcntl.h>
9 <fcntl.h>
10 <stdio.h>
10 <stdio.h>
11 <stdlib.h>
11 <stdlib.h>
12 <FSW-config.c>
12 <FSW-config.c>
13 <grspw.h>
13 <grspw.h>
14 <apbuart.h>
14 <apbuart.h>
15 <FSW-rtems-processing.h>
15 <FSW-rtems-processing.h>
16
16
17 1355231335 -processing.h>
17 1355231335 -processing.h>
18
18
19 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c
19 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c
20 <..\header\grspw.h>
20 <..\header\grspw.h>
21 <stdio.h>
21 <stdio.h>
22
22
23 1354190601
23 1354190601
24
24
25 1350983928 e:\missions\solo\dev_ple\header\grspw.h
25 1350983928 e:\missions\solo\dev_ple\header\grspw.h
26
26
27 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c
27 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c
28 <drvmgr/ambapp_bus.h>
28 <drvmgr/ambapp_bus.h>
29
29
30 1354190602 bapp_bus.h>
30 1354190602 bapp_bus.h>
31
31
32 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c
32 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c
33 <drvmgr/ambapp_bus.h>
33 <drvmgr/ambapp_bus.h>
34
34
35 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c
35 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c
36 <FSW-rtems-processing.h>
36 <FSW-rtems-processing.h>
37 <math.h>
37 <math.h>
38 <stdio.h>
38 <stdio.h>
39 <leon.h>
39 <leon.h>
40
40
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
42 <rtems.h>
42 <rtems.h>
43
43
44 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
44 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
45 <FSW-rtems-processing.h>
45 <FSW-rtems-processing.h>
46 <math.h>
46 <math.h>
47 <stdio.h>
47 <stdio.h>
48 <leon.h>
48 <leon.h>
49
49
50 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h
50 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h
51 <rtems.h>
51 <rtems.h>
52 <grlibregs.h>
52 <grlibregs.h>
53 <FSW-params.h>
53 <FSW-params.h>
54
54
55 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c
55 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c
56 <rtems.h>
56 <rtems.h>
57 <bsp.h>
57 <bsp.h>
58 <rtems/confdefs.h>
58 <rtems/confdefs.h>
59 <drvmgr/drvmgr_confdefs.h>
59 <drvmgr/drvmgr_confdefs.h>
60 <FSW-rtems.h>
60 <FSW-rtems.h>
61 <FSW-config.c>
61 <FSW-config.c>
62
62
63 1359365823 /opt/DEV_PLE/src/FSW-config.c
63 1359365823 /opt/DEV_PLE/src/FSW-config.c
64 <drvmgr/ambapp_bus.h>
64 <drvmgr/ambapp_bus.h>
65
65
66 1359458568 source:/opt/DEV_PLE/src/TC_handler.c
66 1359458568 source:/opt/DEV_PLE/src/TC_handler.c
67 <TC_handler.h>
67 <TC_handler.h>
68 <FSW-params.h>
68 <FSW-params.h>
69
69
70 1359377846 /opt/DEV_PLE/header/TC_handler.h
70 1359377846 /opt/DEV_PLE/header/TC_handler.h
71 <stdio.h>
71 <stdio.h>
72 <ccsds_types.h>
72 <ccsds_types.h>
73
73
74 1359372295 /opt/DEV_PLE/header/ccsds_types.h
74 1359640245 /opt/DEV_PLE/header/ccsds_types.h
75
75
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
77 <drvmgr/ambapp_bus.h>
77 <drvmgr/ambapp_bus.h>
78
78
79 1359452642 /opt/DEV_PLE/header/FSW-config.h
79 1359452642 /opt/DEV_PLE/header/FSW-config.h
80
80
81 1359440704 /opt/DEV_PLE/header/grlibregs.h
81 1359440704 /opt/DEV_PLE/header/grlibregs.h
82
82
83 1359382989 source:/opt/DEV_PLE/src/WF_handler.c
83 1359382989 source:/opt/DEV_PLE/src/WF_handler.c
84
84
85 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c
85 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c
86 <FSW-misc.h>
86 <FSW-misc.h>
87 <FSW-params.h>
87 <FSW-params.h>
88
88
89 1359459330 /opt/DEV_PLE/header/FSW-misc.h
89 1359459330 /opt/DEV_PLE/header/FSW-misc.h
90 <rtems.h>
90 <rtems.h>
91 <stdio.h>
91 <stdio.h>
92 <FSW-rtems.h>
92 <FSW-rtems.h>
93 <FSW-params.h>
93 <FSW-params.h>
94 <grlibregs.h>
94 <grlibregs.h>
95 <grspw.h>
95 <grspw.h>
96 <ccsds_types.h>
96 <ccsds_types.h>
97
97
98 1359459364 /opt/DEV_PLE/header/FSW-rtems.h
98 1359459364 /opt/DEV_PLE/header/FSW-rtems.h
99 <errno.h>
99 <errno.h>
100 <fcntl.h>
100 <fcntl.h>
101 <stdio.h>
101 <stdio.h>
102 <stdlib.h>
102 <stdlib.h>
103 <grspw.h>
103 <grspw.h>
104 <apbuart.h>
104 <apbuart.h>
105 <FSW-params.h>
105 <FSW-params.h>
106 <FSW-misc.h>
106 <FSW-misc.h>
107 <FSW-rtems-processing.h>
107 <FSW-rtems-processing.h>
108 <TC_handler.h>
108 <TC_handler.h>
109 <WF_handler.h>
109 <WF_handler.h>
110 <grlibregs.h>
110 <grlibregs.h>
111
111
112 1359458453 /opt/DEV_PLE/header/FSW-params.h
112 1359458453 /opt/DEV_PLE/header/FSW-params.h
113
113
114 1359459642 /opt/DEV_PLE/header/WF_handler.h
114 1359459642 /opt/DEV_PLE/header/WF_handler.h
115 <rtems.h>
115 <rtems.h>
116 <FSW-params.h>
116 <FSW-params.h>
117 <grspw.h>
117 <grspw.h>
118 <grlibregs.h>
118 <grlibregs.h>
119 <ccsds_types.h>
119 <ccsds_types.h>
120 <stdio.h>
120 <stdio.h>
121 <FSW-rtems.h>
121 <FSW-rtems.h>
122
122
123 1359464354 source:/opt/DEV_PLE/src/fsw_main.c
123 1359464354 source:/opt/DEV_PLE/src/fsw_main.c
124 <rtems.h>
124 <rtems.h>
125 <bsp.h>
125 <bsp.h>
126 <rtems/confdefs.h>
126 <rtems/confdefs.h>
127 <drvmgr/drvmgr_confdefs.h>
127 <drvmgr/drvmgr_confdefs.h>
128 <fsw_main.h>
128 <fsw_main.h>
129 <fsw_config.c>
129 <fsw_config.c>
130
130
131 1359464346 /opt/DEV_PLE/header/fsw_main.h
131 1359464346 /opt/DEV_PLE/header/fsw_main.h
132 <errno.h>
132 <errno.h>
133 <fcntl.h>
133 <fcntl.h>
134 <stdio.h>
134 <stdio.h>
135 <stdlib.h>
135 <stdlib.h>
136 <grspw.h>
136 <grspw.h>
137 <apbuart.h>
137 <apbuart.h>
138 <fsw_params.h>
138 <fsw_params.h>
139 <fsw_misc.h>
139 <fsw_misc.h>
140 <fsw_processing.h>
140 <fsw_processing.h>
141 <tc_handler.h>
141 <tc_handler.h>
142 <wf_handler.h>
142 <wf_handler.h>
143 <grlib_regs.h>
143 <grlib_regs.h>
144
144
145 1359464984 /opt/DEV_PLE/header/fsw_params.h
145 1359616894 /opt/DEV_PLE/header/fsw_params.h
146
146
147 1359464293 /opt/DEV_PLE/header/fsw_misc.h
147 1359614518 /opt/DEV_PLE/header/fsw_misc.h
148 <rtems.h>
148 <rtems.h>
149 <stdio.h>
149 <stdio.h>
150 <fsw_main.h>
150 <fsw_init.h>
151 <fsw_params.h>
151 <fsw_params.h>
152 <grlib_regs.h>
152 <grlib_regs.h>
153 <grspw.h>
153 <grspw.h>
154 <ccsds_types.h>
154 <ccsds_types.h>
155
155
156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
157
157
158 1359465021 /opt/DEV_PLE/header/fsw_processing.h
158 1359614517 /opt/DEV_PLE/header/fsw_processing.h
159 <rtems.h>
159 <rtems.h>
160 <grlib_regs.h>
160 <grlib_regs.h>
161 <fsw_params.h>
161 <fsw_params.h>
162
162
163 1359377846 /opt/DEV_PLE/header/tc_handler.h
163 1359643450 /opt/DEV_PLE/header/tc_handler.h
164 <rtems.h>
164 <stdio.h>
165 <stdio.h>
166 <unistd.h>
167 <sys/ioctl.h>
165 <ccsds_types.h>
168 <ccsds_types.h>
169 <grspw.h>
170 <fsw_init.h>
166
171
167 1359464293 /opt/DEV_PLE/header/wf_handler.h
172 1359614518 /opt/DEV_PLE/header/wf_handler.h
168 <rtems.h>
173 <rtems.h>
169 <fsw_params.h>
174 <fsw_params.h>
170 <grspw.h>
175 <grspw.h>
171 <grlib_regs.h>
176 <grlib_regs.h>
172 <ccsds_types.h>
177 <ccsds_types.h>
173 <stdio.h>
178 <stdio.h>
174 <fsw_main.h>
179 <fsw_init.h>
175
180
176 1359365823 /opt/DEV_PLE/src/fsw_config.c
181 1359365823 /opt/DEV_PLE/src/fsw_config.c
177 <drvmgr/ambapp_bus.h>
182 <drvmgr/ambapp_bus.h>
178
183
179 1359464327 source:/opt/DEV_PLE/src/fsw_misc.c
184 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c
180 <fsw_misc.h>
185 <fsw_misc.h>
181 <fsw_params.h>
186 <fsw_params.h>
182
187
183 1359464327 source:/opt/DEV_PLE/src/tc_handler.c
188 1359643720 source:/opt/DEV_PLE/src/tc_handler.c
184 <tc_handler.h>
189 <tc_handler.h>
185 <fsw_params.h>
190 <fsw_params.h>
186
191
187 1359464346 source:/opt/DEV_PLE/src/wf_handler.c
192 1359614518 source:/opt/DEV_PLE/src/wf_handler.c
188 <wf_handler.h>
193 <wf_handler.h>
189
194
190 1359465021 source:/opt/DEV_PLE/src/fsw_globals.c
195 1359615705 source:/opt/DEV_PLE/src/fsw_globals.c
191 <fsw_processing.h>
196 <fsw_processing.h>
197 <rtems.h>
192
198
199 1359622160 source:/opt/DEV_PLE/src/fsw_init.c
200 <rtems.h>
201 <bsp.h>
202 <rtems/confdefs.h>
203 <drvmgr/drvmgr_confdefs.h>
204 <fsw_init.h>
205 <fsw_config.c>
206
207 1359615705 /opt/DEV_PLE/header/fsw_init.h
208 <errno.h>
209 <fcntl.h>
210 <stdio.h>
211 <stdlib.h>
212 <grspw.h>
213 <apbuart.h>
214 <fsw_params.h>
215 <fsw_misc.h>
216 <fsw_processing.h>
217 <tc_handler.h>
218 <wf_handler.h>
219 <grlib_regs.h>
220
221 1359614518 source:/opt/DEV_PLE/src/fsw_processing.c
222 <fsw_processing.h>
223 <math.h>
224 <stdio.h>
225 <leon.h>
226
@@ -1,43 +1,53
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_layout_file>
2 <CodeBlocks_layout_file>
3 <ActiveTarget name="Debug" />
3 <ActiveTarget name="Debug" />
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="5">
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="5">
5 <Cursor position="1172" topLine="24" />
5 <Cursor position="1172" topLine="24" />
6 </File>
6 </File>
7 <File name="../header/fsw_init.h" open="1" top="0" tabpos="3">
7 <File name="../header/fsw_init.h" open="1" top="0" tabpos="3">
8 <Cursor position="410" topLine="16" />
8 <Cursor position="410" topLine="16" />
9 </File>
9 </File>
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 <Cursor position="114" topLine="0" />
11 <Cursor position="114" topLine="0" />
12 </File>
12 </File>
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
14 <Cursor position="1320" topLine="8" />
14 <Cursor position="1320" topLine="8" />
15 </File>
15 </File>
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 <Cursor position="510" topLine="0" />
17 <Cursor position="510" topLine="0" />
18 </File>
18 </File>
19 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
19 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
20 <Cursor position="634" topLine="0" />
20 <Cursor position="634" topLine="0" />
21 </File>
21 </File>
22 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
22 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
23 <Cursor position="212" topLine="0" />
23 <Cursor position="212" topLine="0" />
24 </File>
24 </File>
25 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4">
25 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4">
26 <Cursor position="46" topLine="0" />
26 <Cursor position="46" topLine="0" />
27 </File>
27 </File>
28 <<<<<<< local
29 <File name="../src/fsw_init.c" open="1" top="1" tabpos="0">
30 <Cursor position="1703" topLine="36" />
31 =======
28 <File name="../src/fsw_init.c" open="1" top="1" tabpos="2">
32 <File name="../src/fsw_init.c" open="1" top="1" tabpos="2">
29 <Cursor position="3361" topLine="60" />
33 <Cursor position="3361" topLine="60" />
34 >>>>>>> other
30 </File>
35 </File>
31 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
36 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
32 <Cursor position="20" topLine="0" />
37 <Cursor position="20" topLine="0" />
33 </File>
38 </File>
34 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
39 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
35 <Cursor position="1175" topLine="46" />
40 <Cursor position="1175" topLine="46" />
36 </File>
41 </File>
42 <<<<<<< local
43 <File name="../src/tc_handler.c" open="0" top="0" tabpos="3">
44 <Cursor position="2672" topLine="26" />
45 =======
37 <File name="../src/tc_handler.c" open="1" top="0" tabpos="1">
46 <File name="../src/tc_handler.c" open="1" top="0" tabpos="1">
38 <Cursor position="11070" topLine="270" />
47 <Cursor position="11070" topLine="270" />
48 >>>>>>> other
39 </File>
49 </File>
40 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
50 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
41 <Cursor position="3936" topLine="62" />
51 <Cursor position="3936" topLine="62" />
42 </File>
52 </File>
43 </CodeBlocks_layout_file>
53 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,118 +1,141
1 #ifndef CCSDS_H_INCLUDED
1 #ifndef CCSDS_H_INCLUDED
2 #define CCSDS_H_INCLUDED
2 #define CCSDS_H_INCLUDED
3
3
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
7 #define CCSDS_TC_PKT_MAX_SIZE 248
7 #define CCSDS_TC_PKT_MAX_SIZE 50 // size of the TC_LFR_UPDATE_INFO packet
8 #define CCSDS_TC_TM_PACKET_OFFSET 7
8 #define CCSDS_TC_TM_PACKET_OFFSET 7
9 #define CCSDS_PROCESS_ID 76
9 #define CCSDS_PROCESS_ID 76
10 #define CCSDS_PACKET_CATEGORY 12
10 #define CCSDS_PACKET_CATEGORY 12
11 #define CCSDS_DESTINATION_ID 0x21
11 #define CCSDS_DESTINATION_ID 0x21
12 #define CCSDS_PROTOCOLE_ID 0x02
12 #define CCSDS_PROTOCOLE_ID 0x02
13 #define CCSDS_USER_APP 0x00
13 #define CCSDS_USER_APP 0x00
14
14
15 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
15 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
16 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
16 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
17
17
18 #define ILLEGAL_APID 0
18 #define ILLEGAL_APID 0
19 #define WRONG_LEN_PACKET 1
19 #define WRONG_LEN_PACKET 1
20 #define INCOR_CHECKSUM 2
20 #define INCOR_CHECKSUM 2
21 #define ILL_TYPE 3
21 #define ILL_TYPE 3
22 #define ILL_SUBTYPE 4
22 #define ILL_SUBTYPE 4
23 #define WRONG_APP_DATA 5
23 #define WRONG_APP_DATA 5
24 #define WRONG_CMD_CODE 6
24 #define WRONG_CMD_CODE 6
25 #define CCSDS_TM_VALID 7
25 #define CCSDS_TM_VALID 7
26 //
26 //
27 #define TC_NOT_EXE 40000
27 #define TC_NOT_EXE 40000
28 #define WRONG_SRC_ID 40001
28 #define WRONG_SRC_ID 40001
29 #define FUNCT_NOT_IMPL 40002
29 #define FUNCT_NOT_IMPL 40002
30 #define FAIL_DETECTED 40003
30 #define FAIL_DETECTED 40003
31 #define NOT_ALLOWED 40004
31 #define NOT_ALLOWED 40004
32 #define CORRUPTED 40005
32 #define CORRUPTED 40005
33 //
33
34 #define SID_TC_RESET 3
34 // // TC SUBTYPES
35 #define SID_TC_LOAD_COMM 20
35 #define TC_SUBTYPE_RESET 3
36 #define SID_TC_LOAD_NORM 21
36 #define TC_SUBTYPE_LOAD_COMM 20
37 #define SID_TC_LOAD_BURST 24
37 #define TC_SUBTYPE_LOAD_NORM 21
38 #define SID_TC_LOAD_SBM1 27
38 #define TC_SUBTYPE_LOAD_BURST 24
39 #define SID_TC_LOAD_SBM2 28
39 #define TC_SUBTYPE_LOAD_SBM1 27
40 #define SID_TC_DUMP 30
40 #define TC_SUBTYPE_LOAD_SBM2 28
41 #define SID_TC_ENTER 40
41 #define TC_SUBTYPE_DUMP 30
42 #define SID_TC_UPDT_INFO 50
42 #define TC_SUBTYPE_ENTER 40
43 #define SID_TC_EN_CAL 60
43 #define TC_SUBTYPE_UPDT_INFO 50
44 #define SID_TC_DIS_CAL 61
44 #define TC_SUBTYPE_EN_CAL 60
45 #define SID_TC_UPDT_TIME 129
45 #define TC_SUBTYPE_DIS_CAL 61
46 #define TC_SUBTYPE_UPDT_TIME 129
46
47
47 #define SID_DEFAULT 0
48 #define SID_DEFAULT 0
48 #define SID_EXE_INC 5
49 #define SID_EXE_INC 5
49 #define SID_NOT_EXE 40000
50 #define SID_NOT_EXE 40000
50 #define SID_NOT_IMP 40002
51 #define SID_NOT_IMP 40002
51 #define SID_EXE_ERR 40003
52 #define SID_EXE_ERR 40003
52 #define SID_EXE_CORR 40005
53 #define SID_EXE_CORR 40005
53
54
54 #define SID_NORM_SWF_F0 3
55 #define SID_NORM_SWF_F0 3
55 #define SID_NORM_SWF_F1 4
56 #define SID_NORM_SWF_F1 4
56 #define SID_NORM_SWF_F2 5
57 #define SID_NORM_SWF_F2 5
57 #define SID_NORM_CWF_F3 1
58 #define SID_NORM_CWF_F3 1
59 #define SID_BURST_CWF_F2 2
60 #define SID_SBM1_CWF_F1 24
61 #define SID_SBM2_CWF_F2 25
62 #define SID_NORM_ASM_F0 11
63 #define SID_NORM_ASM_F1 12
64 #define SID_NORM_ASM_F2 13
65 #define SID_NORM_BP1_F0 14
66 #define SID_NORM_BP1_F1 15
67 #define SID_NORM_BP1_F2 16
68 #define SID_NORM_BP2_F0 19
69 #define SID_NORM_BP2_F1 20
70 #define SID_NORM_BP2_F2 21
71 #define SID_BURST_BP1_F0 17
72 #define SID_BURST_BP2_F0 22
73 #define SID_BURST_BP1_F1 18
74 #define SID_BURST_BP2_F1 23
75 #define SID_SBM1_BP1_F0 28
76 #define SID_SBM1_BP2_F0 31
77 #define SID_SBM2_BP1_F0 29
78 #define SID_SBM2_BP2_F0 32
79 #define SID_SBM1_BP1_F1 30
80 #define SID_SBM1_BP2_F1 33
58
81
59 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
82 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
60 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
83 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
61 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
84 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
62 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
85 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
63 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
86 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
64 #define TM_HEADER_LEN 16
87 #define TM_HEADER_LEN 16
65 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
88 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
66 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
89 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
67
90
68 enum TM_TYPE{
91 enum TM_TYPE{
69 TM_LFR_TC_EXE_OK,
92 TM_LFR_TC_EXE_OK,
70 TM_LFR_TC_EXE_ERR,
93 TM_LFR_TC_EXE_ERR,
71 TM_LFR_HK,
94 TM_LFR_HK,
72 TM_LFR_SCI,
95 TM_LFR_SCI,
73 TM_LFR_SCI_SBM,
96 TM_LFR_SCI_SBM,
74 TM_LFR_PAR_DUMP
97 TM_LFR_PAR_DUMP
75 };
98 };
76
99
77 struct TMHeader_str
100 struct TMHeader_str
78 {
101 {
79 volatile unsigned char targetLogicalAddress;
102 volatile unsigned char targetLogicalAddress;
80 volatile unsigned char protocolIdentifier;
103 volatile unsigned char protocolIdentifier;
81 volatile unsigned char reserved;
104 volatile unsigned char reserved;
82 volatile unsigned char userApplication;
105 volatile unsigned char userApplication;
83 volatile unsigned char packetID[2];
106 volatile unsigned char packetID[2];
84 volatile unsigned char packetSequenceControl[2];
107 volatile unsigned char packetSequenceControl[2];
85 volatile unsigned char packetLength[2];
108 volatile unsigned char packetLength[2];
86 volatile unsigned char dataFieldHeader[10];
109 volatile unsigned char dataFieldHeader[10];
87 };
110 };
88 typedef struct TMHeader_str TMHeader_t;
111 typedef struct TMHeader_str TMHeader_t;
89
112
90 struct ExtendedTMHeader_str
113 struct ExtendedTMHeader_str
91 {
114 {
92 volatile unsigned char targetLogicalAddress;
115 volatile unsigned char targetLogicalAddress;
93 volatile unsigned char protocolIdentifier;
116 volatile unsigned char protocolIdentifier;
94 volatile unsigned char reserved;
117 volatile unsigned char reserved;
95 volatile unsigned char userApplication;
118 volatile unsigned char userApplication;
96 volatile unsigned char packetID[2];
119 volatile unsigned char packetID[2];
97 volatile unsigned char packetSequenceControl[2];
120 volatile unsigned char packetSequenceControl[2];
98 volatile unsigned char packetLength[2];
121 volatile unsigned char packetLength[2];
99 volatile unsigned char dataFieldHeader[10];
122 volatile unsigned char dataFieldHeader[10];
100 volatile unsigned char auxiliaryHeader[6];
123 volatile unsigned char auxiliaryHeader[6];
101 };
124 };
102 typedef struct ExtendedTMHeader_str ExtendedTMHeader_t;
125 typedef struct ExtendedTMHeader_str ExtendedTMHeader_t;
103
126
104 struct ccsdsTelecommandPacket_str
127 struct ccsdsTelecommandPacket_str
105 {
128 {
106 //unsigned char targetLogicalAddress; // removed by the grspw module
129 //unsigned char targetLogicalAddress; // removed by the grspw module
107 volatile unsigned char protocolIdentifier;
130 volatile unsigned char protocolIdentifier;
108 volatile unsigned char reserved;
131 volatile unsigned char reserved;
109 volatile unsigned char userApplication;
132 volatile unsigned char userApplication;
110 volatile unsigned char packetID[2];
133 volatile unsigned char packetID[2];
111 volatile unsigned char packetSequenceControl[2];
134 volatile unsigned char packetSequenceControl[2];
112 volatile unsigned char packetLength[2];
135 volatile unsigned char packetLength[2];
113 volatile unsigned char dataFieldHeader[4];
136 volatile unsigned char dataFieldHeader[4];
114 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
137 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
115 };
138 };
116 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
139 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
117
140
118 #endif // CCSDS_H_INCLUDED
141 #endif // CCSDS_H_INCLUDED
@@ -1,41 +1,45
1 #ifndef FSW_RTEMS_H_INCLUDED
1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
3
4 #include <errno.h>
4 #include <errno.h>
5 #include <fcntl.h>
5 #include <fcntl.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <stdlib.h>
7 #include <stdlib.h>
8
8
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <apbuart.h>
10 #include <apbuart.h>
11
11
12 #include <fsw_params.h>
12 #include <fsw_params.h>
13 #include <fsw_misc.h>
13 #include <fsw_misc.h>
14 #include <fsw_processing.h>
14 #include <fsw_processing.h>
15 #include <tc_handler.h>
15 #include <tc_handler.h>
16 #include <wf_handler.h>
16 #include <wf_handler.h>
17 #include <grlib_regs.h>
17 #include <grlib_regs.h>
18
18
19 extern int sched_yield();
19 extern int sched_yield();
20 extern int errno;
20 extern int errno;
21 extern rtems_name misc_names[ ];
21 extern rtems_id Task_id[ ]; /* array of task ids */
22 extern rtems_name Task_name[ ]; /* array of task names */
23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 extern int fdSPW; // grspw file descriptor
25 extern int fdUART; // uart file descriptor
22
26
23 // RTEMS TASKS
27 // RTEMS TASKS
24 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
28 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
25 rtems_task spw_recv_task(rtems_task_argument argument);
29 rtems_task recv_task(rtems_task_argument argument);
26 rtems_task spw_spiq_task(rtems_task_argument argument);
30 rtems_task spiq_task(rtems_task_argument argument);
27 rtems_task spw_stat_task(rtems_task_argument argument);
31 rtems_task stat_task(rtems_task_argument argument);
28 rtems_task spw_wfrm_task(rtems_task_argument argument);
32 rtems_task wfrm_task(rtems_task_argument argument);
29 int create_all_tasks();
33 int create_all_tasks();
30 int start_all_tasks();
34 int start_all_tasks();
31 int create_message_queue();
35 int create_message_queue();
32
36
33 // OTHER functions
37 // OTHER functions
34 int configure_spw_link();
38 int configure_spw_link();
35 int send_console_outputs_on_serial_port();
39 int send_console_outputs_on_serial_port();
36 extern int rtems_cpu_usage_report();
40 extern int rtems_cpu_usage_report();
37 extern int rtems_cpu_usage_reset();
41 extern int rtems_cpu_usage_reset();
38 void print_statistics(spw_stats *);
42 void print_statistics(spw_stats *);
39 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
43 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
40
44
41 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
45 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,19 +1,19
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include <fsw_init.h>
7 #include <fsw_init.h>
8 #include <fsw_params.h>
8 #include <fsw_params.h>
9 #include <grlib_regs.h>
9 #include <grlib_regs.h>
10 #include <grspw.h>
10 #include <grspw.h>
11 #include <ccsds_types.h>
11 #include <ccsds_types.h>
12
12
13 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
13 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
15 void print_statistics(spw_stats *stats);
15 void print_statistics(spw_stats *stats);
16 int send_console_outputs_on_serial_port();
16 int send_console_outputs_on_serial_port();
17 rtems_task spw_stat_task(rtems_task_argument argument);
17 rtems_task stat_task(rtems_task_argument argument);
18
18
19 #endif // FSW_MISC_H_INCLUDED
19 #endif // FSW_MISC_H_INCLUDED
@@ -1,51 +1,60
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3
3
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 #define UART_DEVICE_NAME "/dev/console"
5 #define UART_DEVICE_NAME "/dev/console"
6
6
7 //*****************************
8 // APB REGISTERS BASE ADDRESSES
7 #define REGS_ADDR_APBUART 0x80000100
9 #define REGS_ADDR_APBUART 0x80000100
8 #define REGS_ADDR_GPTIMER 0x80000300
10 #define REGS_ADDR_GPTIMER 0x80000300
9 #define REGS_ADDR_GRSPW 0x80000500
11 #define REGS_ADDR_GRSPW 0x80000500
10 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
12 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
11
13
12 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
14 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
13
15
14 #define IRQ_SM 9
16 #define IRQ_SM 9
15 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
17 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
16 #define IRQ_WF 10
18 #define IRQ_WF 10
17 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
19 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
18
20
19 #define CLKDIV_SM_SIMULATOR 9999
21 #define CLKDIV_SM_SIMULATOR 9999
20 #define CLKDIV_WF_SIMULATOR 9999999
22 #define CLKDIV_WF_SIMULATOR 9999999
21 #define TIMER_SM_SIMULATOR 1
23 #define TIMER_SM_SIMULATOR 1
22 #define TIMER_WF_SIMULATOR 2
24 #define TIMER_WF_SIMULATOR 2
23
25
26 //******
27 // RTEMS
24 #define TASKID_RECV 1
28 #define TASKID_RECV 1
29 #define TASKID_ACTN 1
25 #define TASKID_SPIQ 3
30 #define TASKID_SPIQ 3
26 #define TASKID_SMIQ 4
31 #define TASKID_SMIQ 4
27 #define TASKID_STAT 5
32 #define TASKID_STAT 5
28 #define TASKID_AVF0 6
33 #define TASKID_AVF0 6
29 #define TASKID_BPF0 7
34 #define TASKID_BPF0 7
30 #define TASKID_WFRM 8
35 #define TASKID_WFRM 8
31
36
37 #define ACTION_MSG_QUEUE_COUNT 10
38
39 //*******
40 // MACROS
32 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
41 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
33 #ifdef PRINT_MESSAGES_ON_CONSOLE
42 #ifdef PRINT_MESSAGES_ON_CONSOLE
34 #define PRINTF(x) printf(x);
43 #define PRINTF(x) printf(x);
35 #define PRINTF1(x,y) printf(x,y);
44 #define PRINTF1(x,y) printf(x,y);
36 #define PRINTF2(x,y,z) printf(x,y,z);
45 #define PRINTF2(x,y,z) printf(x,y,z);
37 #else
46 #else
38 #define PRINTF(x) ;
47 #define PRINTF(x) ;
39 #define PRINTF1(x,y) ;
48 #define PRINTF1(x,y) ;
40 #define PRINTF2(x,y,z) ;
49 #define PRINTF2(x,y,z) ;
41 #endif
50 #endif
42
51
43 #define NB_SAMPLES_PER_SNAPSHOT 2048
52 #define NB_SAMPLES_PER_SNAPSHOT 2048
44 #define NB_BYTES_SWF_BLK 2 * 6
53 #define NB_BYTES_SWF_BLK 2 * 6
45
54
46 extern volatile int wf_snap_f0[ ]; // 24576 bytes
55 extern volatile int wf_snap_f0[ ]; // 24576 bytes
47 extern volatile int wf_snap_f1[ ]; // 24576 bytes
56 extern volatile int wf_snap_f1[ ]; // 24576 bytes
48 extern volatile int wf_snap_f2[ ]; // 24576 bytes
57 extern volatile int wf_snap_f2[ ]; // 24576 bytes
49 extern volatile int wf_cont_f3[ ]; // 24576 bytes
58 extern volatile int wf_cont_f3[ ]; // 24576 bytes
50
59
51 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
60 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,44 +1,44
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
3
3
4 #define NB_BINS_spec_mat 128
4 #define NB_BINS_spec_mat 128
5 #define NB_VALUES_PER_spec_mat 25
5 #define NB_VALUES_PER_spec_mat 25
6 #define TOTAL_SIZE_SPEC_MAT NB_BINS_spec_mat * NB_VALUES_PER_spec_mat
6 #define TOTAL_SIZE_SPEC_MAT NB_BINS_spec_mat * NB_VALUES_PER_spec_mat
7 #define NB_BINS_COMPRESSED_MATRIX_f0 11
7 #define NB_BINS_COMPRESSED_MATRIX_f0 11
8 #define SIZE_COMPRESSED_spec_mat_f1 13
8 #define SIZE_COMPRESSED_spec_mat_f1 13
9 #define SIZE_COMPRESSED_spec_mat_f2 12
9 #define SIZE_COMPRESSED_spec_mat_f2 12
10 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_spec_mat
10 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_spec_mat
11 #define NB_AVERAGE_NORMAL_f0 96*4
11 #define NB_AVERAGE_NORMAL_f0 96*4
12 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
12 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
13
13
14 #include <rtems.h>
14 #include <rtems.h>
15 #include <grlib_regs.h>
15 #include <grlib_regs.h>
16 #include <fsw_params.h>
16 #include <fsw_params.h>
17
17
18 struct BP1_str{
18 struct BP1_str{
19 volatile unsigned char PE[2];
19 volatile unsigned char PE[2];
20 volatile unsigned char PB[2];
20 volatile unsigned char PB[2];
21 volatile unsigned char V0;
21 volatile unsigned char V0;
22 volatile unsigned char V1;
22 volatile unsigned char V1;
23 volatile unsigned char V2_ELLIP_DOP;
23 volatile unsigned char V2_ELLIP_DOP;
24 volatile unsigned char SZ;
24 volatile unsigned char SZ;
25 volatile unsigned char VPHI;
25 volatile unsigned char VPHI;
26 };
26 };
27 typedef struct BP1_str BP1_t;
27 typedef struct BP1_str BP1_t;
28
28
29 // ISR
29 // ISR
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
31 // RTEMS TASKS
31 // RTEMS TASKS
32 rtems_task spw_bppr_task(rtems_task_argument argument);
32 rtems_task spw_bppr_task(rtems_task_argument argument);
33 rtems_task spw_avf0_task(rtems_task_argument argument);
33 rtems_task avf0_task(rtems_task_argument argument);
34 rtems_task spw_bpf0_task(rtems_task_argument argument);
34 rtems_task bpf0_task(rtems_task_argument argument);
35 rtems_task spw_smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
35 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
36 //
36 //
37 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
37 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
38 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
38 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
39 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
39 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
40 void matrix_reset(float *averaged_spec_mat);
40 void matrix_reset(float *averaged_spec_mat);
41 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
41 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
42 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
42 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
43
43
44 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
44 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
@@ -1,40 +1,48
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6 #include <unistd.h> // for the read call
6 #include <unistd.h> // for the read call
7 #include <sys/ioctl.h> // for the ioctl call
7 #include <sys/ioctl.h> // for the ioctl call
8 #include <ccsds_types.h>
8 #include <ccsds_types.h>
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <fsw_init.h>
10
11
11 extern int fdSPW;
12 extern int fdSPW;
13 extern rtems_name misc_name[ ];
14 extern rtems_name misc_id[ ];
12 extern rtems_id Task_id[ ]; /* array of task ids */
15 extern rtems_id Task_id[ ]; /* array of task ids */
13
16
14 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
17 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
15 unsigned char currentTC_COMPUTED_CRC[2];
18 unsigned char currentTC_COMPUTED_CRC[2];
16 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
19 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
17 unsigned int currentTM_length;
20 unsigned int currentTM_length;
18 unsigned char currentTC_processedFlag;
21 unsigned char currentTC_processedFlag;
19
22
20 //**********************
23 //**********************
21 // GENERAL USE FUNCTIONS
24 // GENERAL USE FUNCTIONS
22 unsigned int lookUpTableForCRC[256];
25 unsigned int lookUpTableForCRC[256];
23 void InitLookUpTableForCRC();
26 void InitLookUpTableForCRC();
24 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
27 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
25
28
26 //*********************
29 //*********************
27 // ACCEPTANCE FUNCTIONS
30 // ACCEPTANCE FUNCTIONS
28 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
31 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
29
32
30 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
33 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
31 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
34 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
32 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
35 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
33 unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV,
36 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
34 TMHeader_t *TM_Header, unsigned int *hlen, char *data);
35
37
36 //***********
38 //***********
37 // RTEMS TASK
39 // RTEMS TASK
38 rtems_task spw_recv_task( rtems_task_argument unused );
40 rtems_task recv_task( rtems_task_argument unused );
41 rtems_task actn_task( rtems_task_argument unused );
42 int create_message_queue();
43
44 //***********
45 // TC ACTIONS
46 int default_action(ccsdsTelecommandPacket_t *TC);
39
47
40 #endif // TC_HANDLER_H_INCLUDED
48 #endif // TC_HANDLER_H_INCLUDED
@@ -1,20 +1,20
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <fsw_params.h>
5 #include <fsw_params.h>
6 #include <grspw.h>
6 #include <grspw.h>
7 #include <grlib_regs.h>
7 #include <grlib_regs.h>
8 #include <ccsds_types.h>
8 #include <ccsds_types.h>
9 #include <stdio.h>
9 #include <stdio.h>
10 #include <fsw_init.h>
10 #include <fsw_init.h>
11
11
12 //#include <sys/ioctl.h>
12 //#include <sys/ioctl.h>
13
13
14 extern rtems_id Task_id[]; /* array of task ids */
14 extern rtems_id Task_id[]; /* array of task ids */
15 extern int fdSPW;
15 extern int fdSPW;
16
16
17 rtems_isr waveforms_isr( rtems_vector_number vector );
17 rtems_isr waveforms_isr( rtems_vector_number vector );
18 rtems_task spw_wfrm_task(rtems_task_argument argument);
18 rtems_task wfrm_task(rtems_task_argument argument);
19
19
20 #endif // WF_HANDLER_H_INCLUDED
20 #endif // WF_HANDLER_H_INCLUDED
@@ -1,29 +1,34
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3
3
4 // RTEMS GLOBAL VARIABLES
4 // RTEMS GLOBAL VARIABLES
5 rtems_name misc_names[5];
5 rtems_name misc_name[5];
6 rtems_name misc_id[5];
7 rtems_id Task_id[10]; /* array of task ids */
8 rtems_name Task_name[10]; /* array of task names */
9 int fdSPW;
10 int fdUART;
6
11
7 // WAVEFORMS GLOBAL VARIABLES
12 // WAVEFORMS GLOBAL VARIABLES
8 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
13 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
9 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
14 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
10 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
15 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
11 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
16 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
12
17
13 // SPECTRAL MATRICES GLOBAL VARIABLES
18 // SPECTRAL MATRICES GLOBAL VARIABLES
14 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
19 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
15 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
20 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
16 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
21 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
17 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
22 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
18 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
23 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
19 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
24 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
20 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
25 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
21 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
26 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
22 //
27 //
23 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
28 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
24 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
29 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
25
30
26 // BASIC PARAMETERS GLOBAL VAIRABLES
31 // BASIC PARAMETERS GLOBAL VAIRABLES
27 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
32 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
28
33
29 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
34 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
@@ -1,257 +1,255
1 //*************************
1 //*************************
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 #include <rtems.h>
5 #include <rtems.h>
6
6
7 /* configuration information */
7 /* configuration information */
8
8
9 #define CONFIGURE_INIT
9 #define CONFIGURE_INIT
10
10
11 #include <bsp.h> /* for device driver prototypes */
11 #include <bsp.h> /* for device driver prototypes */
12
12
13 /* configuration information */
13 /* configuration information */
14
14
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17
17
18 #define CONFIGURE_MAXIMUM_TASKS 10
18 #define CONFIGURE_MAXIMUM_TASKS 10
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 1
24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
25
26
26 #include <rtems/confdefs.h>
27 #include <rtems/confdefs.h>
27
28
28 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
29 #ifdef RTEMS_DRVMGR_STARTUP
30 #ifdef RTEMS_DRVMGR_STARTUP
30 #ifdef LEON3
31 #ifdef LEON3
31 /* Add Timer and UART Driver */
32 /* Add Timer and UART Driver */
32 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
33 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
34 #endif
35 #endif
35 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
37 #endif
38 #endif
38 #endif
39 #endif
39 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
40 #include <drvmgr/drvmgr_confdefs.h>
41 #include <drvmgr/drvmgr_confdefs.h>
41 #endif
42 #endif
42
43
43 #include <fsw_init.h>
44 #include <fsw_init.h>
44 #include <fsw_config.c>
45 #include <fsw_config.c>
45
46 int fdSPW;
47 int fdUART;
48
46
49 char *link_status(int status);
47 char *link_status(int status);
50
48
51 char *lstates[6] = {"Error-reset",
49 char *lstates[6] = {"Error-reset",
52 "Error-wait",
50 "Error-wait",
53 "Ready",
51 "Ready",
54 "Started",
52 "Started",
55 "Connecting",
53 "Connecting",
56 "Run"
54 "Run"
57 };
55 };
58
59 rtems_id Task_id[10]; /* array of task ids */
60 rtems_name Task_name[10]; /* array of task names */
61
56
62 rtems_task Init( rtems_task_argument ignored )
57 rtems_task Init( rtems_task_argument ignored )
63 {
58 {
64 rtems_status_code status;
59 rtems_status_code status;
65
60
66 //send_console_outputs_on_serial_port();
61 //send_console_outputs_on_serial_port();
67
62
68 InitLookUpTableForCRC(); // in tc_handler.h
63 InitLookUpTableForCRC(); // in tc_handler.h
69
64
70 create_message_queue();
65 create_message_queue();
71 create_all_tasks();
66 create_all_tasks();
72 start_all_tasks();
67 start_all_tasks();
73
68
74 configure_spw_link();
69 configure_spw_link();
75 // configure timer for spectral matrices simulation
70 // configure timer for spectral matrices simulation
76 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
71 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
77 IRQ_SPARC_SM, spectral_matrices_isr );
72 IRQ_SPARC_SM, spectral_matrices_isr );
78 // configure timer for waveforms simulation
73 // configure timer for waveforms simulation
79 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
80 IRQ_SPARC_WF, waveforms_isr );
75 IRQ_SPARC_WF, waveforms_isr );
81
76
82 LEON_Unmask_interrupt( IRQ_SM );
77 LEON_Unmask_interrupt( IRQ_SM );
83 LEON_Unmask_interrupt( IRQ_WF );
78 LEON_Unmask_interrupt( IRQ_WF );
84
79
85 status = rtems_task_delete(RTEMS_SELF);
80 status = rtems_task_delete(RTEMS_SELF);
86 }
81 }
87
82
88 rtems_task spw_spiq_task(rtems_task_argument unused)
83 rtems_task spiq_task(rtems_task_argument unused)
89 {
84 {
90 rtems_event_set event_out;
85 rtems_event_set event_out;
91 struct grspw_regs_str *grspw_regs;
86 struct grspw_regs_str *grspw_regs;
92 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
87 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
93
88
94 while(1){
89 while(1){
95 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
90 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
96 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
91 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
97
92
98 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
93 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
99 PRINTF("In SPIQ *** Error suspending RECV Task\n")
94 PRINTF("In SPIQ *** Error suspending RECV Task\n")
100
95
101 configure_spw_link();
96 configure_spw_link();
102
97
103 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
98 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
104 PRINTF("In SPIQ *** Error resume RECV Task\n")
99 PRINTF("In SPIQ *** Error resume RECV Task\n")
105 }
100 }
106 }
101 }
107
102
108 int create_message_queue()
109 {
110 misc_names[0] = rtems_build_name( 'D', 'O', 'I', 'T' );
111 return 0;
112 }
113
114 int create_all_tasks()
103 int create_all_tasks()
115 {
104 {
116 rtems_status_code status;
105 rtems_status_code status;
117
106
118 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
107 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
108 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
119 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
109 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
120 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
110 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
121 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
111 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
122 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
112 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
123 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
113 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
124 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
114 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
125
115
126 // RECV
116 // RECV
127 status = rtems_task_create(
117 status = rtems_task_create(
128 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
118 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
129 RTEMS_DEFAULT_MODES,
119 RTEMS_DEFAULT_MODES,
130 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
120 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
121 );
122 // ACTN
123 status = rtems_task_create(
124 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
125 RTEMS_DEFAULT_MODES,
126 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
131 );
127 );
132 // SPIQ
128 // SPIQ
133 status = rtems_task_create(
129 status = rtems_task_create(
134 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
130 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
135 RTEMS_DEFAULT_MODES,
131 RTEMS_DEFAULT_MODES,
136 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
132 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
137 );
133 );
138 // SMIQ
134 // SMIQ
139 status = rtems_task_create(
135 status = rtems_task_create(
140 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
136 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
141 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
137 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
142 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
138 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
143 );
139 );
144 // STAT
140 // STAT
145 status = rtems_task_create(
141 status = rtems_task_create(
146 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
142 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
147 RTEMS_DEFAULT_MODES,
143 RTEMS_DEFAULT_MODES,
148 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
144 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
149 );
145 );
150 // AVF0
146 // AVF0
151 status = rtems_task_create(
147 status = rtems_task_create(
152 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
148 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
153 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
149 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
154 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
150 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
155 );
151 );
156 // BPF0
152 // BPF0
157 status = rtems_task_create(
153 status = rtems_task_create(
158 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
154 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
159 RTEMS_DEFAULT_MODES,
155 RTEMS_DEFAULT_MODES,
160 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
156 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
161 );
157 );
162 // WFRM
158 // WFRM
163 status = rtems_task_create(
159 status = rtems_task_create(
164 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
160 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
165 RTEMS_DEFAULT_MODES,
161 RTEMS_DEFAULT_MODES,
166 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
162 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
167 );
163 );
168
164
169 return 0;
165 return 0;
170 }
166 }
171
167
172 int start_all_tasks()
168 int start_all_tasks()
173 {
169 {
174 rtems_status_code status;
170 rtems_status_code status;
175
171
176 status = rtems_task_start( Task_id[3], spw_spiq_task, 1 );
172 status = rtems_task_start( Task_id[3], spiq_task, 1 );
177 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
173 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
178
174
179 status = rtems_task_start( Task_id[1], spw_recv_task, 1 );
175 status = rtems_task_start( Task_id[1], recv_task, 1 );
180 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
176 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
181
177
182 //status = rtems_task_start( Task_id[4], spw_bppr_task_rate_monotonic, 1 );
178 status = rtems_task_start( Task_id[2], actn_task, 1 );
183 status = rtems_task_start( Task_id[4], spw_smiq_task, 1 );
179 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
180
181 status = rtems_task_start( Task_id[4], smiq_task, 1 );
184 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
182 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
185
183
186 status = rtems_task_start( Task_id[5], spw_stat_task, 1 );
184 status = rtems_task_start( Task_id[5], stat_task, 1 );
187 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
185 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
188
186
189 status = rtems_task_start( Task_id[6], spw_avf0_task, 1 );
187 status = rtems_task_start( Task_id[6], avf0_task, 1 );
190 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
188 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
191
189
192 status = rtems_task_start( Task_id[7], spw_bpf0_task, 1 );
190 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
193 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
191 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
194
192
195 status = rtems_task_start( Task_id[8], spw_wfrm_task, 1 );
193 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
196 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
194 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
197
195
198 return 0;
196 return 0;
199 }
197 }
200
198
201 int configure_spw_link()
199 int configure_spw_link()
202 {
200 {
203 rtems_status_code status;
201 rtems_status_code status;
204
202
205 close(fdSPW); // close the device if it is already open
203 close(fdSPW); // close the device if it is already open
206 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
204 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
207 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
205 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
208 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
206 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
209 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
207 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
210 close(fdSPW); // close the device
208 close(fdSPW); // close the device
211 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
209 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
212 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
210 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
213 rtems_task_wake_after(100);
211 rtems_task_wake_after(100);
214 }
212 }
215
213
216 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
214 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
217
215
218 // sets a few parameters of the link
216 // sets a few parameters of the link
219 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
217 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
220 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
218 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
221 //
219 //
222 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
220 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
223 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
221 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
224 //
222 //
225 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
223 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
226 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
224 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
227 //
225 //
228 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
226 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
229 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
227 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
230 //
228 //
231 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
229 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
232 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
230 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
233
231
234 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
232 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
235 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
233 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
236 //
234 //
237 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
235 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
238 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
236 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
239 //
237 //
240 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
238 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
241
239
242 return RTEMS_SUCCESSFUL;
240 return RTEMS_SUCCESSFUL;
243 }
241 }
244
242
245 char *link_status(int status){
243 char *link_status(int status){
246 return lstates[status];
244 return lstates[status];
247 }
245 }
248
246
249 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
247 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
250 {
248 {
251 rtems_status_code status;
249 rtems_status_code status;
252 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
250 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
253 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
251 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
254 return status;
252 return status;
255 }
253 }
256
254
257
255
@@ -1,73 +1,73
1 #include <fsw_misc.h>
1 #include <fsw_misc.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 extern rtems_id Task_id[]; /* array of task ids */
4 extern rtems_id Task_id[]; /* array of task ids */
5 extern int fdSPW;
5 extern int fdSPW;
6
6
7 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
7 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
8 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
8 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
9 { // configure the timer for the waveforms simulation
9 { // configure the timer for the waveforms simulation
10 rtems_status_code status;
10 rtems_status_code status;
11 rtems_isr_entry old_isr_handler;
11 rtems_isr_entry old_isr_handler;
12
12
13 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
13 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
14 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
14 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
15
15
16 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
16 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
17 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
17 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
18 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
18 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
19 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
19 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
20 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
20 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
21 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
21 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
22
22
23 return 1;
23 return 1;
24 }
24 }
25
25
26 void print_statistics(spw_stats *stats)
26 void print_statistics(spw_stats *stats)
27 {
27 {
28 //printf(" ******** STATISTICS ******** \n");
28 //printf(" ******** STATISTICS ******** \n");
29 printf("Transmit link errors: %i\n", stats->tx_link_err);
29 printf("Transmit link errors: %i\n", stats->tx_link_err);
30 printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err);
30 printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err);
31 printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err);
31 printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err);
32 printf("Receiver EEP errors: %i\n", stats->rx_eep_err);
32 printf("Receiver EEP errors: %i\n", stats->rx_eep_err);
33 printf("Receiver truncation errors: %i\n", stats->rx_truncated);
33 printf("Receiver truncation errors: %i\n", stats->rx_truncated);
34 printf("Parity errors: %i\n", stats->parity_err);
34 printf("Parity errors: %i\n", stats->parity_err);
35 printf("Escape errors: %i\n", stats->escape_err);
35 printf("Escape errors: %i\n", stats->escape_err);
36 printf("Credit errors: %i\n", stats->credit_err);
36 printf("Credit errors: %i\n", stats->credit_err);
37 printf("Disconnect errors: %i\n", stats->disconnect_err);
37 printf("Disconnect errors: %i\n", stats->disconnect_err);
38 printf("Write synchronization errors: %i\n", stats->write_sync_err);
38 printf("Write synchronization errors: %i\n", stats->write_sync_err);
39 printf("Early EOP/EEP: %i\n", stats->early_ep);
39 printf("Early EOP/EEP: %i\n", stats->early_ep);
40 printf("Invalid Node Address: %i\n", stats->invalid_address);
40 printf("Invalid Node Address: %i\n", stats->invalid_address);
41 printf("Packets transmitted: %i\n", stats->packets_sent);
41 printf("Packets transmitted: %i\n", stats->packets_sent);
42 printf("Packets received: %i\n", stats->packets_received);
42 printf("Packets received: %i\n", stats->packets_received);
43 }
43 }
44
44
45 int send_console_outputs_on_serial_port() // Send the console outputs on the serial port
45 int send_console_outputs_on_serial_port() // Send the console outputs on the serial port
46 {
46 {
47 struct apbuart_regs_str *apbuart_regs;
47 struct apbuart_regs_str *apbuart_regs;
48
48
49 apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
49 apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
50 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
50 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
51 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
51 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
52
52
53 return 0;
53 return 0;
54 }
54 }
55
55
56 rtems_task spw_stat_task(rtems_task_argument argument)
56 rtems_task stat_task(rtems_task_argument argument)
57 {
57 {
58 int i;
58 int i;
59 i = 0;
59 i = 0;
60 PRINTF("In STAT *** \n")
60 PRINTF("In STAT *** \n")
61 while(1){
61 while(1){
62 rtems_task_wake_after(1000);
62 rtems_task_wake_after(1000);
63 PRINTF1("%d\n", i)
63 PRINTF1("%d\n", i)
64 if (i == 2) {
64 if (i == 2) {
65 rtems_cpu_usage_report();
65 rtems_cpu_usage_report();
66 rtems_cpu_usage_reset();
66 rtems_cpu_usage_reset();
67 i = 0;
67 i = 0;
68 }
68 }
69 else i++;
69 else i++;
70 }
70 }
71 }
71 }
72
72
73
73
@@ -1,423 +1,423
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <math.h>
2 #include <math.h>
3 #include <stdio.h>
3 #include <stdio.h>
4 #include <leon.h>
4 #include <leon.h>
5
5
6 float k14_re = 1;
6 float k14_re = 1;
7 float k14_im = 1;
7 float k14_im = 1;
8 float k14_bis_re = 1;
8 float k14_bis_re = 1;
9 float k14_bis_im = 1;
9 float k14_bis_im = 1;
10 float k14_tris_re = 1;
10 float k14_tris_re = 1;
11 float k14_tris_im = 1;
11 float k14_tris_im = 1;
12 float k15_re = 1;
12 float k15_re = 1;
13 float k15_im = 1;
13 float k15_im = 1;
14 float k15_bis_re = 1;
14 float k15_bis_re = 1;
15 float k15_bis_im = 1;
15 float k15_bis_im = 1;
16 float k24_re = 1;
16 float k24_re = 1;
17 float k24_im = 1;
17 float k24_im = 1;
18 float k24_bis_re = 1;
18 float k24_bis_re = 1;
19 float k24_bis_im = 1;
19 float k24_bis_im = 1;
20 float k24_tris_re = 1;
20 float k24_tris_re = 1;
21 float k24_tris_im = 1;
21 float k24_tris_im = 1;
22 float k25_re = 1;
22 float k25_re = 1;
23 float k25_im = 1;
23 float k25_im = 1;
24 float k25_bis_re = 1;
24 float k25_bis_re = 1;
25 float k25_bis_im = 1;
25 float k25_bis_im = 1;
26 float k34_re = 1;
26 float k34_re = 1;
27 float k34_im = 1;
27 float k34_im = 1;
28 float k44 = 1;
28 float k44 = 1;
29 float k55 = 1;
29 float k55 = 1;
30 float k45_re = 1;
30 float k45_re = 1;
31 float k45_im = 1;
31 float k45_im = 1;
32 float alpha_M = M_PI/4;
32 float alpha_M = M_PI/4;
33
33
34 extern volatile int spec_mat_f0_a[ ];
34 extern volatile int spec_mat_f0_a[ ];
35 extern volatile int spec_mat_f0_b[ ];
35 extern volatile int spec_mat_f0_b[ ];
36 extern volatile int spec_mat_f0_c[ ];
36 extern volatile int spec_mat_f0_c[ ];
37 extern volatile int spec_mat_f0_d[ ];
37 extern volatile int spec_mat_f0_d[ ];
38 extern volatile int spec_mat_f0_e[ ];
38 extern volatile int spec_mat_f0_e[ ];
39 extern volatile int spec_mat_f0_f[ ];
39 extern volatile int spec_mat_f0_f[ ];
40 extern volatile int spec_mat_f0_g[ ];
40 extern volatile int spec_mat_f0_g[ ];
41 extern volatile int spec_mat_f0_h[ ];
41 extern volatile int spec_mat_f0_h[ ];
42 extern float averaged_spec_mat_f0[ ];
42 extern float averaged_spec_mat_f0[ ];
43 extern float compressed_spec_mat_f0[ ];
43 extern float compressed_spec_mat_f0[ ];
44 extern unsigned char LFR_BP1_F0[ ];
44 extern unsigned char LFR_BP1_F0[ ];
45
45
46 extern BP1_t data_BP1[ ];
46 extern BP1_t data_BP1[ ];
47
47
48 extern rtems_id Task_id[ ]; /* array of task ids */
48 extern rtems_id Task_id[ ]; /* array of task ids */
49
49
50 spectral_matrices_regs_t *spectral_matrices_regs;
50 spectral_matrices_regs_t *spectral_matrices_regs;
51
51
52 // Interrupt Service Routine for spectral matrices processing
52 // Interrupt Service Routine for spectral matrices processing
53 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
53 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
54 {
54 {
55 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
55 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
57 }
57 }
58
58
59 rtems_task spw_smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
59 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
60 {
60 {
61 rtems_event_set event_out;
61 rtems_event_set event_out;
62 gptimer_regs_t *gptimer_regs;
62 gptimer_regs_t *gptimer_regs;
63 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
63 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
64 unsigned char nb_interrupt_f0 = 0;
64 unsigned char nb_interrupt_f0 = 0;
65
65
66 while(1){
66 while(1){
67 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
67 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
71 printf("In spw_smiq_task *** Error sending event to AVF0\n");
71 printf("In smiq_task *** Error sending event to AVF0\n");
72 nb_interrupt_f0 = 0;
72 nb_interrupt_f0 = 0;
73 }
73 }
74 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
74 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
75 }
75 }
76 }
76 }
77
77
78 rtems_task spw_bppr_task(rtems_task_argument argument)
78 rtems_task spw_bppr_task(rtems_task_argument argument)
79 {
79 {
80 rtems_status_code status;
80 rtems_status_code status;
81 rtems_event_set event_out;
81 rtems_event_set event_out;
82 static int nb_average_f0 = 0;
82 static int nb_average_f0 = 0;
83 //static int nb_average_f1 = 0;
83 //static int nb_average_f1 = 0;
84 //static int nb_average_f2 = 0;
84 //static int nb_average_f2 = 0;
85
85
86 while(1)
86 while(1)
87
87
88 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
88 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
89 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
89 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
90 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
90 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
91
91
92 printf("In BPPR ***\n");
92 printf("In BPPR ***\n");
93
93
94 while(1){ // wait for an event to begin with the processing
94 while(1){ // wait for an event to begin with the processing
95 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
95 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
96 if (status == RTEMS_SUCCESSFUL){
96 if (status == RTEMS_SUCCESSFUL){
97 if ((spectral_matrices_regs->ctrl & 0x00000001)==1){
97 if ((spectral_matrices_regs->ctrl & 0x00000001)==1){
98 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
98 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
99 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
99 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
100 //printf("f0_a\n");
100 //printf("f0_a\n");
101 nb_average_f0++;
101 nb_average_f0++;
102 }
102 }
103 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){
103 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){
104 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
104 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
105 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
105 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
106 //printf("f0_b\n");
106 //printf("f0_b\n");
107 nb_average_f0++;
107 nb_average_f0++;
108 }
108 }
109 if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){
109 if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){
110 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
110 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
111 //printf("f0 compressed\n");
111 //printf("f0 compressed\n");
112 nb_average_f0 = 0;
112 nb_average_f0 = 0;
113 matrix_reset(averaged_spec_mat_f0);
113 matrix_reset(averaged_spec_mat_f0);
114 }
114 }
115 }
115 }
116 }
116 }
117 }
117 }
118
118
119 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
119 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
120 {
120 {
121 int i;
121 int i;
122 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
122 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
123 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
123 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
124 + spec_mat_f0_b[i]
124 + spec_mat_f0_b[i]
125 + spec_mat_f0_c[i]
125 + spec_mat_f0_c[i]
126 + spec_mat_f0_d[i]
126 + spec_mat_f0_d[i]
127 + spec_mat_f0_e[i]
127 + spec_mat_f0_e[i]
128 + spec_mat_f0_f[i]
128 + spec_mat_f0_f[i]
129 + spec_mat_f0_g[i]
129 + spec_mat_f0_g[i]
130 + spec_mat_f0_h[i];
130 + spec_mat_f0_h[i];
131 }
131 }
132 }
132 }
133
133
134 void matrix_reset(float *averaged_spec_mat)
134 void matrix_reset(float *averaged_spec_mat)
135 {
135 {
136 int i;
136 int i;
137 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
137 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
138 averaged_spec_mat_f0[i] = 0;
138 averaged_spec_mat_f0[i] = 0;
139 }
139 }
140 }
140 }
141
141
142 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
142 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
143 {
143 {
144 int i, j;
144 int i, j;
145 switch (fChannel){
145 switch (fChannel){
146 case 0:
146 case 0:
147 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
147 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
148 j = 17 + i * 8;
148 j = 17 + i * 8;
149 compressed_spec_mat[i] = (averaged_spec_mat[j]
149 compressed_spec_mat[i] = (averaged_spec_mat[j]
150 + averaged_spec_mat[j+1]
150 + averaged_spec_mat[j+1]
151 + averaged_spec_mat[j+2]
151 + averaged_spec_mat[j+2]
152 + averaged_spec_mat[j+3]
152 + averaged_spec_mat[j+3]
153 + averaged_spec_mat[j+4]
153 + averaged_spec_mat[j+4]
154 + averaged_spec_mat[j+5]
154 + averaged_spec_mat[j+5]
155 + averaged_spec_mat[j+6]
155 + averaged_spec_mat[j+6]
156 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
156 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
157 }
157 }
158 break;
158 break;
159 case 1:
159 case 1:
160 // case fChannel = f1 tp be completed later
160 // case fChannel = f1 tp be completed later
161 break;
161 break;
162 case 2:
162 case 2:
163 // case fChannel = f1 tp be completed later
163 // case fChannel = f1 tp be completed later
164 break;
164 break;
165 default:
165 default:
166 break;
166 break;
167 }
167 }
168 }
168 }
169
169
170 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
170 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
171 int i, j;
171 int i, j;
172 unsigned char tmp_u_char;
172 unsigned char tmp_u_char;
173 unsigned char * pt_char;
173 unsigned char * pt_char;
174 float PSDB, PSDE;
174 float PSDB, PSDE;
175 float NVEC_V0, NVEC_V1, NVEC_V2;
175 float NVEC_V0, NVEC_V1, NVEC_V2;
176 float significand;
176 float significand;
177 int exponent;
177 int exponent;
178 float aux, tr_SB_SB, tmp;
178 float aux, tr_SB_SB, tmp;
179 float e_cross_b_re, e_cross_b_im;
179 float e_cross_b_re, e_cross_b_im;
180 float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0;
180 float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0;
181 float nx = 0, ny = 0;
181 float nx = 0, ny = 0;
182 float bz_bz_star = 0;
182 float bz_bz_star = 0;
183 for(i=0; i<nb_bins_compressed_spec_mat; i++){
183 for(i=0; i<nb_bins_compressed_spec_mat; i++){
184 //==============================================
184 //==============================================
185 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
185 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
186 PSDB = compressed_spec_mat[i*30] // S11
186 PSDB = compressed_spec_mat[i*30] // S11
187 + compressed_spec_mat[i*30+10] // S22
187 + compressed_spec_mat[i*30+10] // S22
188 + compressed_spec_mat[i*30+18]; // S33
188 + compressed_spec_mat[i*30+18]; // S33
189 significand = frexp(PSDB, &exponent);
189 significand = frexp(PSDB, &exponent);
190 pt_char = (unsigned char*) &PSDB;
190 pt_char = (unsigned char*) &PSDB;
191 LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float
191 LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float
192 LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float
192 LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float
193 //==============================================
193 //==============================================
194 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
194 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
195 PSDE = compressed_spec_mat[i*30+24] * k44 // S44
195 PSDE = compressed_spec_mat[i*30+24] * k44 // S44
196 + compressed_spec_mat[i*30+28] * k55 // S55
196 + compressed_spec_mat[i*30+28] * k55 // S55
197 + compressed_spec_mat[i*30+26] * k45_re // S45
197 + compressed_spec_mat[i*30+26] * k45_re // S45
198 - compressed_spec_mat[i*30+27] * k45_im; // S45
198 - compressed_spec_mat[i*30+27] * k45_im; // S45
199 pt_char = (unsigned char*) &PSDE;
199 pt_char = (unsigned char*) &PSDE;
200 LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float
200 LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float
201 LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float
201 LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float
202 //==============================================================================
202 //==============================================================================
203 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
203 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
204 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
204 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
205 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
205 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
206 tmp = sqrt(
206 tmp = sqrt(
207 compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12
207 compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12
208 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13
208 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13
209 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23
209 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23
210 );
210 );
211 NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23
211 NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23
212 NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13
212 NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13
213 NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12
213 NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12
214 LFR_BP1[i*9+4] = (char) (NVEC_V0*256);
214 LFR_BP1[i*9+4] = (char) (NVEC_V0*256);
215 LFR_BP1[i*9+3] = (char) (NVEC_V1*256);
215 LFR_BP1[i*9+3] = (char) (NVEC_V1*256);
216 pt_char = (unsigned char*) &NVEC_V2;
216 pt_char = (unsigned char*) &NVEC_V2;
217 LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
217 LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
218 //=======================================================
218 //=======================================================
219 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
219 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
220 aux = 2*tmp / PSDB; // compute the ellipticity
220 aux = 2*tmp / PSDB; // compute the ellipticity
221 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
221 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
222 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
222 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
223 //==============================================================
223 //==============================================================
224 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
224 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
225 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
225 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
226 tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30]
226 tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30]
227 + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10]
227 + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10]
228 + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18]
228 + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18]
229 + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2]
229 + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2]
230 + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3]
230 + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3]
231 + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4]
231 + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4]
232 + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5]
232 + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5]
233 + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12]
233 + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12]
234 + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13];
234 + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13];
235 }
235 }
236 aux = PSDB*PSDB;
236 aux = PSDB*PSDB;
237 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux );
237 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux );
238 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
238 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
239 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char
239 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char
240 //=======================================================================================
240 //=======================================================================================
241 // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
241 // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
242 e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re
242 e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re
243 + compressed_spec_mat[i*30+6]*k14_re
243 + compressed_spec_mat[i*30+6]*k14_re
244 + compressed_spec_mat[i*30+8]*k15_re
244 + compressed_spec_mat[i*30+8]*k15_re
245 + compressed_spec_mat[i*30+14]*k24_re
245 + compressed_spec_mat[i*30+14]*k24_re
246 + compressed_spec_mat[i*30+16]*k25_re;
246 + compressed_spec_mat[i*30+16]*k25_re;
247 e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im
247 e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im
248 + compressed_spec_mat[i*30+7]*k14_im
248 + compressed_spec_mat[i*30+7]*k14_im
249 + compressed_spec_mat[i*30+9]*k15_im
249 + compressed_spec_mat[i*30+9]*k15_im
250 + compressed_spec_mat[i*30+15]*k24_im
250 + compressed_spec_mat[i*30+15]*k24_im
251 + compressed_spec_mat[i*30+17]*k25_im;
251 + compressed_spec_mat[i*30+17]*k25_im;
252 tmp = e_cross_b_re / PSDE; // compute ReaSz
252 tmp = e_cross_b_re / PSDE; // compute ReaSz
253 LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
253 LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
254 tmp = e_cross_b_re * e_cross_b_im;
254 tmp = e_cross_b_re * e_cross_b_im;
255 pt_char = (unsigned char*) &tmp;
255 pt_char = (unsigned char*) &tmp;
256 LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz
256 LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz
257 //======================================================================
257 //======================================================================
258 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
258 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
259 nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1;
259 nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1;
260 ny = NVEC_V2;
260 ny = NVEC_V2;
261 bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11
261 bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11
262 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22
262 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22
263 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12
263 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12
264 n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re
264 n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re
265 +compressed_spec_mat[i*30+6]*k14_bis_re
265 +compressed_spec_mat[i*30+6]*k14_bis_re
266 +compressed_spec_mat[i*30+16]*k25_bis_re
266 +compressed_spec_mat[i*30+16]*k25_bis_re
267 +compressed_spec_mat[i*30+14]*k24_bis_re)
267 +compressed_spec_mat[i*30+14]*k24_bis_re)
268 + ny * (compressed_spec_mat[i*30+6]*k14_tris_re
268 + ny * (compressed_spec_mat[i*30+6]*k14_tris_re
269 +compressed_spec_mat[i*30+14]*k24_tris_re);
269 +compressed_spec_mat[i*30+14]*k24_tris_re);
270 n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im
270 n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im
271 +compressed_spec_mat[i*30+6]*k14_bis_im
271 +compressed_spec_mat[i*30+6]*k14_bis_im
272 +compressed_spec_mat[i*30+16]*k25_bis_im
272 +compressed_spec_mat[i*30+16]*k25_bis_im
273 +compressed_spec_mat[i*30+14]*k24_bis_im)
273 +compressed_spec_mat[i*30+14]*k24_bis_im)
274 + ny * (compressed_spec_mat[i*30+6]*k14_tris_im
274 + ny * (compressed_spec_mat[i*30+6]*k14_tris_im
275 +compressed_spec_mat[i*30+14]*k24_tris_im);
275 +compressed_spec_mat[i*30+14]*k24_tris_im);
276 tmp = n_cross_e_scal_b_re / bz_bz_star;
276 tmp = n_cross_e_scal_b_re / bz_bz_star;
277 LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
277 LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
278 tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im;
278 tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im;
279 pt_char = (unsigned char*) &tmp;
279 pt_char = (unsigned char*) &tmp;
280 LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV
280 LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV
281 }
281 }
282
282
283 }
283 }
284
284
285 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
285 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
286 // BP2 autocorrelation
286 // BP2 autocorrelation
287 int i, aux = 0;
287 int i, aux = 0;
288 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
288 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
289 // S12
289 // S12
290 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]);
290 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]);
291 compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux;
291 compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux;
292 compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux;
292 compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux;
293 // S13
293 // S13
294 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]);
294 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]);
295 compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux;
295 compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux;
296 compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux;
296 compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux;
297 // S23
297 // S23
298 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]);
298 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]);
299 compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux;
299 compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux;
300 compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux;
300 compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux;
301 // S45
301 // S45
302 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]);
302 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]);
303 compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux;
303 compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux;
304 compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux;
304 compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux;
305 // S14
305 // S14
306 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]);
306 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]);
307 compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux;
307 compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux;
308 compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux;
308 compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux;
309 // S15
309 // S15
310 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]);
310 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]);
311 compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux;
311 compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux;
312 compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux;
312 compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux;
313 // S24
313 // S24
314 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]);
314 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]);
315 compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux;
315 compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux;
316 compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux;
316 compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux;
317 // S25
317 // S25
318 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]);
318 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]);
319 compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux;
319 compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux;
320 compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux;
320 compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux;
321 // S34
321 // S34
322 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]);
322 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]);
323 compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux;
323 compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux;
324 compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux;
324 compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux;
325 // S35
325 // S35
326 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]);
326 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]);
327 compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux;
327 compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux;
328 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
328 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
329 }
329 }
330 }
330 }
331
331
332 rtems_task spw_avf0_task(rtems_task_argument argument){
332 rtems_task avf0_task(rtems_task_argument argument){
333 int i;
333 int i;
334 static int nb_average;
334 static int nb_average;
335 rtems_event_set event_out;
335 rtems_event_set event_out;
336 rtems_status_code status;
336 rtems_status_code status;
337
337
338 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
338 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
339 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
339 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
340 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
340 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
341
341
342 nb_average = 0;
342 nb_average = 0;
343
343
344 PRINTF("In AVFO *** \n")
344 PRINTF("In AVFO *** \n")
345
345
346 while(1){
346 while(1){
347 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
347 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
348 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
348 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
349 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
349 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
350 + spec_mat_f0_b[i]
350 + spec_mat_f0_b[i]
351 + spec_mat_f0_c[i]
351 + spec_mat_f0_c[i]
352 + spec_mat_f0_d[i]
352 + spec_mat_f0_d[i]
353 + spec_mat_f0_e[i]
353 + spec_mat_f0_e[i]
354 + spec_mat_f0_f[i]
354 + spec_mat_f0_f[i]
355 + spec_mat_f0_g[i]
355 + spec_mat_f0_g[i]
356 + spec_mat_f0_h[i];
356 + spec_mat_f0_h[i];
357 }
357 }
358 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
358 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
359 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
359 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
360 if (nb_average == NB_AVERAGE_NORMAL_f0) {
360 if (nb_average == NB_AVERAGE_NORMAL_f0) {
361 nb_average = 0;
361 nb_average = 0;
362 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
362 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
363 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
363 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
364 }
364 }
365 }
365 }
366 }
366 }
367
367
368 rtems_task spw_bpf0_task(rtems_task_argument argument){
368 rtems_task bpf0_task(rtems_task_argument argument){
369 rtems_event_set event_out;
369 rtems_event_set event_out;
370
370
371 while(1){
371 while(1){
372 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
372 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
373 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
373 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
374 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
374 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
375 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
375 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
376 }
376 }
377 }
377 }
378
378
379 //*******
379 //*******
380 // UNUSED
380 // UNUSED
381 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
381 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
382 {/*
382 {/*
383 rtems_status_code status;
383 rtems_status_code status;
384 //static int nb_average_f1 = 0;
384 //static int nb_average_f1 = 0;
385 //static int nb_average_f2 = 0;
385 //static int nb_average_f2 = 0;
386
386
387 rtems_name name;
387 rtems_name name;
388 rtems_id period;
388 rtems_id period;
389 name = rtems_build_name( 'P', 'E', 'R', 'D' );
389 name = rtems_build_name( 'P', 'E', 'R', 'D' );
390 status = rtems_rate_monotonic_create( name, &period );
390 status = rtems_rate_monotonic_create( name, &period );
391 if( status != RTEMS_SUCCESSFUL ) {
391 if( status != RTEMS_SUCCESSFUL ) {
392 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
392 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
393 //exit( 1 );
393 //exit( 1 );
394 }
394 }
395
395
396 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
396 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
397 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
397 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
398 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
398 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
399
399
400 printf("In BPPR BIS ***\n");
400 printf("In BPPR BIS ***\n");
401
401
402 while(1){ // launch the rate monotonic task
402 while(1){ // launch the rate monotonic task
403 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
403 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
404 printf("TIMEOUT\n");
404 printf("TIMEOUT\n");
405 //break;
405 //break;
406 }
406 }
407 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
407 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
408 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
408 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
409 }
409 }
410
410
411 status = rtems_rate_monotonic_delete( period );
411 status = rtems_rate_monotonic_delete( period );
412 if ( status != RTEMS_SUCCESSFUL ) {
412 if ( status != RTEMS_SUCCESSFUL ) {
413 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
413 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
414 //exit( 1 );
414 //exit( 1 );
415 }
415 }
416 status = rtems_task_delete( RTEMS_SELF ); // should not return
416 status = rtems_task_delete( RTEMS_SELF ); // should not return
417 printf( "rtems_task_delete returned with status of %d.\n", status );
417 printf( "rtems_task_delete returned with status of %d.\n", status );
418 //exit( 1 );*/
418 //exit( 1 );*/
419 }
419 }
420
420
421
421
422
422
423
423
@@ -1,331 +1,396
1 #include <tc_handler.h>
1 #include <tc_handler.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
5 "WRONG_LEN_PACKET 1",
5 "WRONG_LEN_PACKET 1",
6 "INCOR_CHECKSUM 2",
6 "INCOR_CHECKSUM 2",
7 "ILL_TYPE 3",
7 "ILL_TYPE 3",
8 "ILL_SUBTYPE 4",
8 "ILL_SUBTYPE 4",
9 "WRONG_APP_DATA 5",
9 "WRONG_APP_DATA 5",
10 "WRONG_CMD_CODE 6",
10 "WRONG_CMD_CODE 6",
11 "CCSDS_TM_VALID 7"
11 "CCSDS_TM_VALID 7"
12 };
12 };
13
13
14 //**********************
14 //**********************
15 // GENERAL USE FUNCTIONS
15 // GENERAL USE FUNCTIONS
16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
17 {
17 {
18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
19 }
19 }
20
20
21 void InitLookUpTableForCRC()
21 void InitLookUpTableForCRC()
22 {
22 {
23 unsigned int i, tmp;
23 unsigned int i, tmp;
24 for (i=0; i<256; i++)
24 for (i=0; i<256; i++)
25 {
25 {
26 tmp = 0;
26 tmp = 0;
27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
33 if((i & 64) != 0) tmp = tmp ^ 0x48c4;
33 if((i & 64) != 0) tmp = tmp ^ 0x48c4;
34 if((i & 128) != 0) tmp = tmp ^ 0x9188;
34 if((i & 128) != 0) tmp = tmp ^ 0x9188;
35 lookUpTableForCRC[i] = tmp;
35 lookUpTableForCRC[i] = tmp;
36 }
36 }
37 }
37 }
38
38
39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
40 {
40 {
41 unsigned int Chk;
41 unsigned int Chk;
42 int j;
42 int j;
43 Chk = 0xffff; // reset the syndrom to all ones
43 Chk = 0xffff; // reset the syndrom to all ones
44 for (j=0; j<sizeOfData; j++) {
44 for (j=0; j<sizeOfData; j++) {
45 Chk = Crc_opt(data[j], Chk);
45 Chk = Crc_opt(data[j], Chk);
46 }
46 }
47 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
47 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
49 }
49 }
50
50
51
51
52 //*********************
52 //*********************
53 // ACCEPTANCE FUNCTIONS
53 // ACCEPTANCE FUNCTIONS
54 unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV,
54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
55 TMHeader_t *TM_Header, unsigned int *hlen, char *data)
56 {
55 {
56 rtems_status_code status;
57 spw_ioctl_pkt_send spw_ioctl_send;
58 TMHeader_t TM_header;
57 unsigned int code = 0;
59 unsigned int code = 0;
58 unsigned int data_length = 0;
59 unsigned char computed_CRC[2];
60 unsigned char computed_CRC[2];
60 unsigned char subtype = 0;
61 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
61
62
62 subtype = TC->dataFieldHeader[2];
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, TC_LEN_RCV + 5 );
64 code = acceptTM( TC, tc_len_recv ) ;
64 code = acceptTM( TC, TC_LEN_RCV ) ;
65 //PRINTF1("in TC_checker *** %s\n", errorCCSDSMsg[code]);
66 if ( (code == 0) | (code == 1) | (code == 2)
65 if ( (code == 0) | (code == 1) | (code == 2)
67 | (code == 3) | (code == 4) | (code == 5) )
66 | (code == 3) | (code == 4) | (code == 5) )
68 { // generate TM_LFR_TC_EXE_CORRUPTED
67 { // generate TM_LFR_TC_EXE_CORRUPTED
69 // BUILD HEADER
68 // BUILD HEADER
70 TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, TM_Header);
69 TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
71 // BUILD DATA
70 // BUILD DATA
72 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
71 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
73 data_length = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
72 // PREPARE TM SENDING
74 }
73 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
75 if (subtype == SID_TC_UPDT_TIME){
74 spw_ioctl_send.hdr = (char*) &TM_header;
76 // BUILD HEADER
75 spw_ioctl_send.dlen = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
77 TM_build_header( TM_LFR_TC_EXE_OK, SID_DEFAULT, TM_LEN_EXE, 0, 0, TM_Header);
76 spw_ioctl_send.data = data;
78 // BUILD DATA
77 // SEND PACKET
79 TM_build_data( TC, data, SID_DEFAULT, computed_CRC);
78 write_spw(&spw_ioctl_send);
80 data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
81 }
79 }
82 else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED
80 else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED
83 // BUILD HEADER
81 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET);
84 TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, TM_Header);
82 return -1;
85 // BUILD DATA
86 TM_build_data( TC, data, SID_NOT_IMP, computed_CRC);
87 data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
88 }
83 }
89
84 return -1;
90 return data_length;
91 }
85 }
92
86
93 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
87 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
94 {
88 {
95 unsigned char pid = 0;
89 unsigned char pid = 0;
96 unsigned char category = 0;
90 unsigned char category = 0;
97 unsigned int length = 0;
91 unsigned int length = 0;
98 unsigned char packetType = 0;
92 unsigned char packetType = 0;
99 unsigned char packetSubtype = 0;
93 unsigned char packetSubtype = 0;
100 unsigned char * CCSDSContent;
94 unsigned char * CCSDSContent;
101
95
102 // APID check *** APID on 2 bytes
96 // APID check *** APID on 2 bytes
103 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
97 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
104 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
98 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
105 if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID;
99 if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID;
106 if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID;
100 if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID;
107
101
108 // packet length check
102 // packet length check
109 length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1];
103 length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1];
110 if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
104 if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
111 if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
105 if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
112
106
113 packetType = TMPacket->dataFieldHeader[1];
107 packetType = TMPacket->dataFieldHeader[1];
114 packetSubtype = TMPacket->dataFieldHeader[2];
108 packetSubtype = TMPacket->dataFieldHeader[2];
115 // service type, subtype and packet length check
109 // service type, subtype and packet length check
116 if (packetType == 181){
110 if (packetType == 181){
117 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
111 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
118 case 3:
112 case 3:
119 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
113 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
120 break;
114 break;
121 case 20:
115 case 20:
122 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
116 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
123 break;
117 break;
124 case 21:
118 case 21:
125 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
119 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
126 break;
120 break;
127 case 24:
121 case 24:
128 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
122 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
129 break;
123 break;
130 case 27:
124 case 27:
131 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
125 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
132 break;
126 break;
133 case 28:
127 case 28:
134 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
128 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
135 break;
129 break;
136 case 30:
130 case 30:
137 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
131 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
138 break;
132 break;
139 case 40:
133 case 40:
140 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
134 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
141 break;
135 break;
142 case 50:
136 case 50:
143 if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
137 if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
144 break;
138 break;
145 case 60:
139 case 60:
146 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
140 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
147 break;
141 break;
148 case 61:
142 case 61:
149 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
143 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
150 break;
144 break;
151 default:
145 default:
152 return ILL_SUBTYPE;
146 return ILL_SUBTYPE;
153 break;
147 break;
154 }
148 }
155 }
149 }
156 else if (packetType == 9){
150 else if (packetType == 9){
157 if (packetSubtype!=129) return ILL_SUBTYPE;
151 if (packetSubtype!=129) return ILL_SUBTYPE;
158 if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
152 if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
159 }
153 }
160 else return ILL_TYPE;
154 else return ILL_TYPE;
161
155
162 // source ID check // Source ID not documented in the ICD
156 // source ID check // Source ID not documented in the ICD
163
157
164 // packet error control, CRC check
158 // packet error control, CRC check
165 CCSDSContent = (unsigned char*) TMPacket->packetID;
159 CCSDSContent = (unsigned char*) TMPacket->packetID;
166 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
160 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
167 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM;
161 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM;
168 if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM;
162 if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM;
169
163
170 return CCSDS_TM_VALID;
164 return CCSDS_TM_VALID;
171 }
165 }
172
166
173 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
167 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
174 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
168 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
175 {
169 {
176 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
170 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
177 TMHeader->protocolIdentifier = 0x02;
171 TMHeader->protocolIdentifier = 0x02;
178 TMHeader->reserved = 0x00;
172 TMHeader->reserved = 0x00;
179 TMHeader->userApplication = 0x00;
173 TMHeader->userApplication = 0x00;
180 TMHeader->packetID[0] = 0x0c;
174 TMHeader->packetID[0] = 0x0c;
181 TMHeader->packetSequenceControl[0] = 0xc0;
175 TMHeader->packetSequenceControl[0] = 0xc0;
182 TMHeader->packetSequenceControl[1] = 0x00;
176 TMHeader->packetSequenceControl[1] = 0x00;
183 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
177 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
184 TMHeader->packetLength[1] = (unsigned char) packetLength;
178 TMHeader->packetLength[1] = (unsigned char) packetLength;
185 TMHeader->dataFieldHeader[0] = 0x10;
179 TMHeader->dataFieldHeader[0] = 0x10;
186 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
180 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
187 switch (tm_type){
181 switch (tm_type){
188 case(TM_LFR_TC_EXE_OK):
182 case(TM_LFR_TC_EXE_OK):
189 TMHeader->packetID[1] = 0xc1;
183 TMHeader->packetID[1] = 0xc1;
190 TMHeader->dataFieldHeader[1] = 1; // type
184 TMHeader->dataFieldHeader[1] = 1; // type
191 TMHeader->dataFieldHeader[2] = 7; // subtype
185 TMHeader->dataFieldHeader[2] = 7; // subtype
192 break;
186 break;
193 case(TM_LFR_TC_EXE_ERR):
187 case(TM_LFR_TC_EXE_ERR):
194 TMHeader->packetID[1] = 0xc1;
188 TMHeader->packetID[1] = 0xc1;
195 TMHeader->dataFieldHeader[1] = 1; // type
189 TMHeader->dataFieldHeader[1] = 1; // type
196 TMHeader->dataFieldHeader[2] = 8; // subtype
190 TMHeader->dataFieldHeader[2] = 8; // subtype
197 break;
191 break;
198 case(TM_LFR_HK):
192 case(TM_LFR_HK):
199 TMHeader->packetID[1] = 0xc4;
193 TMHeader->packetID[1] = 0xc4;
200 TMHeader->dataFieldHeader[1] = 3; // type
194 TMHeader->dataFieldHeader[1] = 3; // type
201 TMHeader->dataFieldHeader[2] = 25; // subtype
195 TMHeader->dataFieldHeader[2] = 25; // subtype
202 break;
196 break;
203 case(TM_LFR_SCI):
197 case(TM_LFR_SCI):
204 TMHeader->packetID[1] = 0xcc;
198 TMHeader->packetID[1] = 0xcc;
205 TMHeader->dataFieldHeader[1] = 21; // type
199 TMHeader->dataFieldHeader[1] = 21; // type
206 TMHeader->dataFieldHeader[2] = 3; // subtype
200 TMHeader->dataFieldHeader[2] = 3; // subtype
207 break;
201 break;
208 case(TM_LFR_SCI_SBM):
202 case(TM_LFR_SCI_SBM):
209 TMHeader->packetID[1] = 0xfc;
203 TMHeader->packetID[1] = 0xfc;
210 TMHeader->dataFieldHeader[1] = 21; // type
204 TMHeader->dataFieldHeader[1] = 21; // type
211 TMHeader->dataFieldHeader[2] = 3; // subtype
205 TMHeader->dataFieldHeader[2] = 3; // subtype
212 break;
206 break;
213 case(TM_LFR_PAR_DUMP):
207 case(TM_LFR_PAR_DUMP):
214 TMHeader->packetID[1] = 0xc9;
208 TMHeader->packetID[1] = 0xc9;
215 TMHeader->dataFieldHeader[1] = 181; // type
209 TMHeader->dataFieldHeader[1] = 181; // type
216 TMHeader->dataFieldHeader[2] = 31; // subtype
210 TMHeader->dataFieldHeader[2] = 31; // subtype
217 break;
211 break;
218 default:
212 default:
219 return 0;
213 return 0;
220 }
214 }
221 /*TMHeader->dataFieldHeader[4] = (unsigned char) (coarseTime>>24);
215 /*TMHeader->dataFieldHeader[4] = (unsigned char) (coarseTime>>24);
222 TMHeader->dataFieldHeader[5] = (unsigned char) (coarseTime>>16);
216 TMHeader->dataFieldHeader[5] = (unsigned char) (coarseTime>>16);
223 TMHeader->dataFieldHeader[6] = (unsigned char) (coarseTime>>8);
217 TMHeader->dataFieldHeader[6] = (unsigned char) (coarseTime>>8);
224 TMHeader->dataFieldHeader[7] = (unsigned char) (coarseTime);
218 TMHeader->dataFieldHeader[7] = (unsigned char) (coarseTime);
225 TMHeader->dataFieldHeader[8] = (unsigned char) (fineTime>>8);
219 TMHeader->dataFieldHeader[8] = (unsigned char) (fineTime>>8);
226 TMHeader->dataFieldHeader[9] = (unsigned char) (fineTime);*/
220 TMHeader->dataFieldHeader[9] = (unsigned char) (fineTime);*/
227 TMHeader->dataFieldHeader[4] = 0xaa;
221 TMHeader->dataFieldHeader[4] = 0xaa;
228 TMHeader->dataFieldHeader[5] = 0xbb;
222 TMHeader->dataFieldHeader[5] = 0xbb;
229 TMHeader->dataFieldHeader[6] = 0xcc;
223 TMHeader->dataFieldHeader[6] = 0xcc;
230 TMHeader->dataFieldHeader[7] = 0xdd;
224 TMHeader->dataFieldHeader[7] = 0xdd;
231 TMHeader->dataFieldHeader[8] = 0xee;
225 TMHeader->dataFieldHeader[8] = 0xee;
232 TMHeader->dataFieldHeader[9] = 0xff;
226 TMHeader->dataFieldHeader[9] = 0xff;
233 return 1;
227 return 1;
234 }
228 }
235
229
236 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
230 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
237 {
231 {
238 unsigned int packetLength;
232 unsigned int packetLength;
239 packetLength = TC->packetLength[0] * 256 + TC->packetLength[1];
233 packetLength = TC->packetLength[0] * 256 + TC->packetLength[1];
240 switch (SID){
234 switch (SID){
241 case (SID_NOT_EXE):
235 case (SID_NOT_EXE):
242 break;
236 break;
243 case (SID_NOT_IMP):
237 case (SID_NOT_IMP):
244 data[0] = 0x9c;
238 data[0] = 0x9c;
245 data[1] = 0x42;
239 data[1] = 0x42;
246 data[2] = TC->packetID[0];
240 data[2] = TC->packetID[0];
247 data[3] = TC->packetID[1];
241 data[3] = TC->packetID[1];
248 data[4] = TC->packetSequenceControl[0];
242 data[4] = TC->packetSequenceControl[0];
249 data[5] = TC->packetSequenceControl[1];
243 data[5] = TC->packetSequenceControl[1];
250 data[6] = TC->dataFieldHeader[1]; // type
244 data[6] = TC->dataFieldHeader[1]; // type
251 data[7] = TC->dataFieldHeader[2]; // subtype
245 data[7] = TC->dataFieldHeader[2]; // subtype
252 break;
246 break;
253 case (SID_EXE_ERR):
247 case (SID_EXE_ERR):
254 break;
248 break;
255 case (SID_EXE_CORR):
249 case (SID_EXE_CORR):
256 data[0] = 0x9c;
250 data[0] = 0x9c;
257 data[1] = 0x45;
251 data[1] = 0x45;
258 data[2] = TC->packetID[0];
252 data[2] = TC->packetID[0];
259 data[3] = TC->packetID[1];
253 data[3] = TC->packetID[1];
260 data[4] = TC->packetSequenceControl[0];
254 data[4] = TC->packetSequenceControl[0];
261 data[5] = TC->packetSequenceControl[1];
255 data[5] = TC->packetSequenceControl[1];
262 data[6] = TC->dataFieldHeader[1]; // type
256 data[6] = TC->dataFieldHeader[1]; // type
263 data[7] = TC->dataFieldHeader[2]; // subtype
257 data[7] = TC->dataFieldHeader[2]; // subtype
264 data[8] = currentTC_LEN_RCV[0];
258 data[8] = currentTC_LEN_RCV[0];
265 data[9] = currentTC_LEN_RCV[1];
259 data[9] = currentTC_LEN_RCV[1];
266 data[10] = TC->packetLength[0];
260 data[10] = TC->packetLength[0];
267 data[11] = TC->packetLength[1];
261 data[11] = TC->packetLength[1];
268 data[12] = TC->dataAndCRC[packetLength];
262 data[12] = TC->dataAndCRC[packetLength];
269 data[13] = TC->dataAndCRC[packetLength+1];
263 data[13] = TC->dataAndCRC[packetLength+1];
270 data[14] = computed_CRC[0];
264 data[14] = computed_CRC[0];
271 data[15] = computed_CRC[1];
265 data[15] = computed_CRC[1];
272 break;
266 break;
273 default:
267 default:
274 return 0;
268 return 0;
275 }
269 }
276 return 1;
270 return 1;
277 }
271 }
278
272
279 unsigned char actionLauncher(unsigned int sid)
280 {
281 return 0;
282 }
283
284 //***********
273 //***********
285 // RTEMS TASK
274 // RTEMS TASK
286 rtems_task spw_recv_task( rtems_task_argument unused )
275 rtems_task recv_task( rtems_task_argument unused )
287 {
276 {
288 rtems_status_code status;
289 int len = 0;
277 int len = 0;
290 unsigned int i = 0;
278 unsigned int i = 0;
291 unsigned int data_length = 0;
279 unsigned int data_length = 0;
292 ccsdsTelecommandPacket_t currentTC;
280 ccsdsTelecommandPacket_t currentTC;
293 spw_ioctl_pkt_send spw_ioctl_send;
294 TMHeader_t TM_header;
295 char data[100];
281 char data[100];
296
282
297 for(i=0; i<100; i++) data[i] = 0;
283 for(i=0; i<100; i++) data[i] = 0;
298
284
299 PRINTF("In RECV *** \n")
285 PRINTF("In RECV *** \n")
300
286
301 while(1){
287 while(1)
288 {
302 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
289 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
303 if (len == -1){ // error during the read call
290 if (len == -1){ // error during the read call
304 PRINTF("In RECV *** last read call returned -1\n")
291 PRINTF("In RECV *** last read call returned -1\n")
305 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
292 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
306 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
293 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
307 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
294 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
308 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
295 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
309 }
296 }
310 else {
297 else {
311 //PRINTF1("In RECV *** Got Message of length %d\n", len)
298 //PRINTF1("In RECV *** Got Message of length %d\n", len)
312 currentTC_LEN_RCV[0] = 0x00;
299 currentTC_LEN_RCV[0] = 0x00;
313 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
300 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
314 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
301 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
315 // CHECK THE TC AND BUILD THE APPROPRIATE TM
302 // CHECK THE TC AND BUILD THE APPROPRIATE TM
316 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt,
303 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
317 &TM_header, &spw_ioctl_send.hlen, data);
304 if (data_length!=-1)
318 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
305 {
319 spw_ioctl_send.hdr = (char*) &TM_header;
306 }
320 spw_ioctl_send.dlen = data_length;
321 spw_ioctl_send.data = data;
322 //printf("hlen %d, dlen %d\n", spw_ioctl_send.hlen, spw_ioctl_send.dlen);
323 // SEND PACKET
324 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
325 if (status!=RTEMS_SUCCESSFUL) printf("In TC_checker *** Error SPACEWIRE_IOCTRL_SEND\n");
326 //PRINTF1("In TC_checker *** packet of size %d sent\n", spw_ioctl_send.sent)
327 }
307 }
328 }
308 }
329 }
309 }
330
310
311 rtems_task actn_task( rtems_task_argument unused )
312 {
313 rtems_status_code status; // RTEMS status code
314 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
315 size_t size; // size of the incoming TC packet
316 unsigned char subtype = 0; // subtype of the current TC packet
331
317
318 while(1)
319 {
320 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
321 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
322 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
323 else
324 {
325 subtype = TC.dataFieldHeader[2];
326 switch(subtype)
327 {
328 case TC_SUBTYPE_RESET:
329 break;
330 case TC_SUBTYPE_LOAD_COMM:
331 break;
332 case TC_SUBTYPE_LOAD_NORM:
333 break;
334 case TC_SUBTYPE_LOAD_BURST:
335 break;
336 case TC_SUBTYPE_LOAD_SBM1:
337 break;
338 case TC_SUBTYPE_LOAD_SBM2:
339 break;
340 case TC_SUBTYPE_DUMP:
341 default_action( &TC );
342 break;
343 case TC_SUBTYPE_ENTER:
344 break;
345 case TC_SUBTYPE_UPDT_INFO:
346 break;
347 case TC_SUBTYPE_EN_CAL:
348 break;
349 case TC_SUBTYPE_DIS_CAL:
350 break;
351 case TC_SUBTYPE_UPDT_TIME:
352 break;
353 default:
354 break;
355 }
356 }
357 }
358 }
359
360 int create_message_queue()
361 {
362 rtems_status_code status;
363 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
364 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
365 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
366 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
367
368 return 0;
369 }
370
371 //***********
372 // TC ACTIONS
373 int default_action(ccsdsTelecommandPacket_t *TC)
374 {
375 char data[100]; // buffer for the generic TM packet
376 TMHeader_t TM_header; // TM header
377 spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any
378 // BUILD HEADER
379 TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, &TM_header);
380 // BUILD DATA
381 TM_build_data( TC, data, SID_NOT_IMP, NULL);
382 // filling the strture for the spcawire transmission
383 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
384 spw_ioctl_send.hdr = (char*) &TM_header;
385 spw_ioctl_send.dlen = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
386 spw_ioctl_send.data = data;
387 // SEND DATA
388 write_spw(&spw_ioctl_send);
389
390 return 0;
391 }
392
393
394
395
396
@@ -1,113 +1,113
1 #include <wf_handler.h>
1 #include <wf_handler.h>
2
2
3 rtems_isr waveforms_isr( rtems_vector_number vector )
3 rtems_isr waveforms_isr( rtems_vector_number vector )
4 {
4 {
5 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
5 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
7 }
7 }
8
8
9 rtems_task spw_wfrm_task(rtems_task_argument argument)
9 rtems_task wfrm_task(rtems_task_argument argument)
10 {
10 {
11 unsigned int length;
11 unsigned int length;
12 unsigned int i = 0;
12 unsigned int i = 0;
13 spw_ioctl_pkt_send spw_ioctl_send;
13 spw_ioctl_pkt_send spw_ioctl_send;
14 rtems_event_set event_out;
14 rtems_event_set event_out;
15 gptimer_regs_t *gptimer_regs;
15 gptimer_regs_t *gptimer_regs;
16 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
16 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
17 ExtendedTMHeader_t header;
17 ExtendedTMHeader_t header;
18
18
19 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
19 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
20 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
20 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
21 header.reserved = 0x00;
21 header.reserved = 0x00;
22 header.userApplication = CCSDS_USER_APP;
22 header.userApplication = CCSDS_USER_APP;
23 header.packetID[0] = 0x0c;
23 header.packetID[0] = 0x0c;
24 header.packetID[1] = 0xcc;
24 header.packetID[1] = 0xcc;
25 header.packetSequenceControl[0] = 0x00;
25 header.packetSequenceControl[0] = 0x00;
26 header.packetSequenceControl[1] = 0x00;
26 header.packetSequenceControl[1] = 0x00;
27 header.packetLength[0] = 0x00;
27 header.packetLength[0] = 0x00;
28 header.packetLength[1] = 0x00;
28 header.packetLength[1] = 0x00;
29 header.dataFieldHeader[0] = 0x10;
29 header.dataFieldHeader[0] = 0x10;
30 header.dataFieldHeader[1] = 0x15; // service type
30 header.dataFieldHeader[1] = 0x15; // service type
31 header.dataFieldHeader[2] = 0x03; // service subtype
31 header.dataFieldHeader[2] = 0x03; // service subtype
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
33 header.dataFieldHeader[4] = 0xaa;
33 header.dataFieldHeader[4] = 0xaa;
34 header.dataFieldHeader[5] = 0xbb;
34 header.dataFieldHeader[5] = 0xbb;
35 header.dataFieldHeader[6] = 0xcc;
35 header.dataFieldHeader[6] = 0xcc;
36 header.dataFieldHeader[7] = 0xdd;
36 header.dataFieldHeader[7] = 0xdd;
37 header.dataFieldHeader[8] = 0xee;
37 header.dataFieldHeader[8] = 0xee;
38 header.dataFieldHeader[9] = 0xff;
38 header.dataFieldHeader[9] = 0xff;
39
39
40 header.auxiliaryHeader[0] = 0x00;
40 header.auxiliaryHeader[0] = 0x00;
41 header.auxiliaryHeader[1] = 0x1f;
41 header.auxiliaryHeader[1] = 0x1f;
42 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
42 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
43 header.auxiliaryHeader[3] = 0x00; // PKT_NR
43 header.auxiliaryHeader[3] = 0x00; // PKT_NR
44 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
44 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
45 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
45 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
46
46
47 // BUILD THE PACKET HEADER
47 // BUILD THE PACKET HEADER
48 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
48 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
49 spw_ioctl_send.hdr = (char*) &header;
49 spw_ioctl_send.hdr = (char*) &header;
50
50
51 while(1){
51 while(1){
52 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
52 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
53 for (i=0; i<7; i++) // send F0
53 for (i=0; i<7; i++) // send F0
54 {
54 {
55 // BUILD THE DATA
55 // BUILD THE DATA
56 if (i==6) {
56 if (i==6) {
57 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
57 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
58 length = TM_LEN_SCI_NORM_SWF_340;
58 length = TM_LEN_SCI_NORM_SWF_340;
59 }
59 }
60 else {
60 else {
61 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
61 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
62 length = TM_LEN_SCI_NORM_SWF_8;
62 length = TM_LEN_SCI_NORM_SWF_8;
63 }
63 }
64 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
64 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
65 // BUILD THE HEADER
65 // BUILD THE HEADER
66 header.packetLength[0] = (unsigned char) (length>>8);
66 header.packetLength[0] = (unsigned char) (length>>8);
67 header.packetLength[1] = (unsigned char) (length);
67 header.packetLength[1] = (unsigned char) (length);
68 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
68 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
69 // SEND PACKET
69 // SEND PACKET
70 write_spw(&spw_ioctl_send);
70 write_spw(&spw_ioctl_send);
71 }
71 }
72 for (i=0; i<7; i++) // send F1
72 for (i=0; i<7; i++) // send F1
73 {
73 {
74 // BUILD THE DATA
74 // BUILD THE DATA
75 if (i==6) {
75 if (i==6) {
76 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
76 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
77 length = TM_LEN_SCI_NORM_SWF_340;
77 length = TM_LEN_SCI_NORM_SWF_340;
78 }
78 }
79 else {
79 else {
80 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
80 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
81 length = TM_LEN_SCI_NORM_SWF_8;
81 length = TM_LEN_SCI_NORM_SWF_8;
82 }
82 }
83 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
83 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
84 // BUILD THE HEADER
84 // BUILD THE HEADER
85 header.packetLength[0] = (unsigned char) (length>>8);
85 header.packetLength[0] = (unsigned char) (length>>8);
86 header.packetLength[1] = (unsigned char) (length);
86 header.packetLength[1] = (unsigned char) (length);
87 header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID
87 header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID
88 // SEND PACKET
88 // SEND PACKET
89 write_spw(&spw_ioctl_send);
89 write_spw(&spw_ioctl_send);
90 }
90 }
91 for (i=0; i<7; i++) // send F0
91 for (i=0; i<7; i++) // send F0
92 {
92 {
93 // BUILD THE DATA
93 // BUILD THE DATA
94 if (i==6) {
94 if (i==6) {
95 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
95 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
96 length = TM_LEN_SCI_NORM_SWF_340;
96 length = TM_LEN_SCI_NORM_SWF_340;
97 }
97 }
98 else {
98 else {
99 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
99 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
100 length = TM_LEN_SCI_NORM_SWF_8;
100 length = TM_LEN_SCI_NORM_SWF_8;
101 }
101 }
102 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
102 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
103 // BUILD THE HEADER
103 // BUILD THE HEADER
104 header.packetLength[0] = (unsigned char) (length>>8);
104 header.packetLength[0] = (unsigned char) (length>>8);
105 header.packetLength[1] = (unsigned char) (length);
105 header.packetLength[1] = (unsigned char) (length);
106 header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID
106 header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID
107 // SEND PACKET
107 // SEND PACKET
108 write_spw(&spw_ioctl_send);
108 write_spw(&spw_ioctl_send);
109 }
109 }
110 // irq processed, reset the related register of the timer unit
110 // irq processed, reset the related register of the timer unit
111 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
111 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
112 }
112 }
113 }
113 }
General Comments 0
You need to be logged in to leave comments. Login now