##// END OF EJS Templates
Header files inclusion reworked...
paul -
r40:d6dd28d83c6c default
parent child
Show More
@@ -0,0 +1,19
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
3
4 #include "tc_handler.h"
5
6 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
7 int action_load_normal_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
8 int action_load_burst_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
9 int action_load_sbm1_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
10 int action_load_sbm2_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
11 int action_dump_par(rtems_id queue_id );
12
13 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
14 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
15 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
16 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
17 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
18
19 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -0,0 +1,377
1 /** Functions to load and dump parameters in the LFR registers.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 * TC_LFR_LOAD_COMMON_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
12 *
13 */
14
15 #include "tc_load_dump_parameters.h"
16
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 {
19 /** This function updates the LFR registers with the incoming common parameters.
20 *
21 * @param TC points to the TeleCommand packet that is being processed
22 *
23 *
24 */
25 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
26 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
27 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
28 return LFR_SUCCESSFUL;
29 }
30
31 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
32 {
33 /** This function updates the LFR registers with the incoming normal parameters.
34 *
35 * @param TC points to the TeleCommand packet that is being processed
36 * @param queue_id is the id of the queue which handles TM related to this execution step
37 *
38 */
39 int result;
40 int flag;
41
42 flag = LFR_SUCCESSFUL;
43 result = LFR_SUCCESSFUL;
44
45 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
46 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
47 flag = LFR_DEFAULT;
48 }
49
50 //***************
51 // sy_lfr_n_swf_l
52 if (flag == LFR_SUCCESSFUL)
53 {
54 result = set_sy_lfr_n_swf_l( TC, queue_id );
55 if (result != LFR_SUCCESSFUL)
56 {
57 flag = LFR_DEFAULT;
58 }
59 }
60
61 //***************
62 // sy_lfr_n_swf_p
63 if (flag == LFR_SUCCESSFUL)
64 {
65 result = set_sy_lfr_n_swf_p( TC, queue_id );
66 if (result != LFR_SUCCESSFUL)
67 {
68 flag = LFR_DEFAULT;
69 }
70 }
71
72 //***************
73 // sy_lfr_n_asm_p
74 if (flag == LFR_SUCCESSFUL)
75 {
76 result = set_sy_lfr_n_asm_p( TC, queue_id );
77 if (result != LFR_SUCCESSFUL)
78 {
79 flag = LFR_DEFAULT;
80 }
81 }
82
83 //***************
84 // sy_lfr_n_bp_p0
85 if (flag == LFR_SUCCESSFUL)
86 {
87 result = set_sy_lfr_n_bp_p0( TC, queue_id );
88 if (result != LFR_SUCCESSFUL)
89 {
90 flag = LFR_DEFAULT;
91 }
92 }
93
94 //***************
95 // sy_lfr_n_bp_p1
96 if (flag == LFR_SUCCESSFUL)
97 {
98 result = set_sy_lfr_n_bp_p1( TC, queue_id );
99 if (result != LFR_SUCCESSFUL)
100 {
101 flag = LFR_DEFAULT;
102 }
103 }
104
105 return result;
106 }
107
108 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
109 {
110 /** This function updates the LFR registers with the incoming burst parameters.
111 *
112 * @param TC points to the TeleCommand packet that is being processed
113 * @param queue_id is the id of the queue which handles TM related to this execution step
114 *
115 */
116 int result;
117 unsigned char lfrMode;
118
119 result = LFR_DEFAULT;
120 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
121
122 if ( lfrMode == LFR_MODE_BURST ) {
123 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
124 result = LFR_DEFAULT;
125 }
126 else {
127 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
128 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
129
130 result = LFR_SUCCESSFUL;
131 }
132
133 return result;
134 }
135
136 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
137 {
138 /** This function updates the LFR registers with the incoming sbm1 parameters.
139 *
140 * @param TC points to the TeleCommand packet that is being processed
141 * @param queue_id is the id of the queue which handles TM related to this execution step
142 *
143 */
144 int result;
145 unsigned char lfrMode;
146
147 result = LFR_DEFAULT;
148 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
149
150 if ( lfrMode == LFR_MODE_SBM1 ) {
151 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
152 result = LFR_DEFAULT;
153 }
154 else {
155 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
156 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
157
158 result = LFR_SUCCESSFUL;
159 }
160
161 return result;
162 }
163
164 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
165 {
166 /** This function updates the LFR registers with the incoming sbm2 parameters.
167 *
168 * @param TC points to the TeleCommand packet that is being processed
169 * @param queue_id is the id of the queue which handles TM related to this execution step
170 *
171 */
172
173 int result;
174 unsigned char lfrMode;
175
176 result = LFR_DEFAULT;
177 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
178
179 if ( lfrMode == LFR_MODE_SBM2 ) {
180 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
181 result = LFR_DEFAULT;
182 }
183 else {
184 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
185 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
186
187 result = LFR_SUCCESSFUL;
188 }
189
190 return result;
191 }
192
193 int action_dump_par( rtems_id queue_id )
194 {
195 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
196 *
197 * @param queue_id is the id of the queue which handles TM related to this execution step.
198 *
199 * @return RTEMS directive status codes:
200 * - RTEMS_SUCCESSFUL - message sent successfully
201 * - RTEMS_INVALID_ID - invalid queue id
202 * - RTEMS_INVALID_SIZE - invalid message size
203 * - RTEMS_INVALID_ADDRESS - buffer is NULL
204 * - RTEMS_UNSATISFIED - out of message buffers
205 * - RTEMS_TOO_MANY - queue s limit has been reached
206 *
207 */
208
209 int status;
210
211 // SEND DATA
212 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
213 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
214 if (status != RTEMS_SUCCESSFUL) {
215 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
216 }
217
218 return status;
219 }
220
221 //***********************
222 // NORMAL MODE PARAMETERS
223
224 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
225 {
226 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
227 *
228 * @param TC points to the TeleCommand packet that is being processed
229 * @param queue_id is the id of the queue which handles TM related to this execution step
230 *
231 */
232
233 unsigned int tmp;
234 int result;
235 unsigned char msb;
236 unsigned char lsb;
237
238 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
239 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
240
241 tmp = ( unsigned int ) floor(
242 ( ( msb*256 ) + lsb ) / 16
243 ) * 16;
244
245 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
246 { // 2048 is the maximum limit due to thesize of the buffers
247 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
248 result = WRONG_APP_DATA;
249 }
250 else if (tmp != 2048)
251 {
252 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
253 result = FUNCT_NOT_IMPL;
254 }
255 else
256 {
257 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
258 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
259 result = LFR_SUCCESSFUL;
260 }
261
262 return result;
263 }
264
265 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
266 {
267 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
268 *
269 * @param TC points to the TeleCommand packet that is being processed
270 * @param queue_id is the id of the queue which handles TM related to this execution step
271 *
272 */
273
274 unsigned int tmp;
275 int result;
276 unsigned char msb;
277 unsigned char lsb;
278
279 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
280 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
281
282 tmp = ( unsigned int ) floor(
283 ( ( msb*256 ) + lsb ) / 8
284 ) * 8;
285
286 if ( (tmp < 16) || (tmp > 65528) )
287 {
288 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
289 result = WRONG_APP_DATA;
290 }
291 else
292 {
293 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
294 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
295 result = LFR_SUCCESSFUL;
296 }
297
298 return result;
299 }
300
301 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
302 {
303 /** This function sets the time between two full spectral matrices transmission, in s (sy_lfr_n_asm_p).
304 *
305 * @param TC points to the TeleCommand packet that is being processed
306 * @param queue_id is the id of the queue which handles TM related to this execution step
307 *
308 */
309
310 int result;
311 unsigned char msb;
312 unsigned char lsb;
313
314 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
315 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
316
317 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
318 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
319 result = LFR_SUCCESSFUL;
320
321 return result;
322 }
323
324 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
325 {
326 /** This function sets the time between two basic parameter sets, in s (sy_lfr_n_bp_p0).
327 *
328 * @param TC points to the TeleCommand packet that is being processed
329 * @param queue_id is the id of the queue which handles TM related to this execution step
330 *
331 */
332
333 int status;
334
335 status = LFR_SUCCESSFUL;
336
337 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
338
339 return status;
340 }
341
342 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
343 {
344 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
345 *
346 * @param TC points to the TeleCommand packet that is being processed
347 * @param queue_id is the id of the queue which handles TM related to this execution step
348 *
349 */
350
351 int status;
352
353 status = LFR_SUCCESSFUL;
354
355 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
356
357 return status;
358 }
359
360 //**********************
361 // BURST MODE PARAMETERS
362
363 //*********************
364 // SBM1 MODE PARAMETERS
365
366 //*********************
367 // SBM2 MODE PARAMETERS
368
369
370
371
372
373
374
375
376
377
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 11 10:41:32 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 17 10:12:11 2013
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -49,14 +49,18 SOURCES = ../src/wf_handler.c \
49 ../src/fsw_misc.c \
49 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
50 ../src/fsw_init.c \
51 ../src/fsw_globals.c \
51 ../src/fsw_globals.c \
52 ../src/fsw_spacewire.c
52 ../src/fsw_spacewire.c \
53 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c
53 OBJECTS = obj/wf_handler.o \
55 OBJECTS = obj/wf_handler.o \
54 obj/tc_handler.o \
56 obj/tc_handler.o \
55 obj/fsw_processing.o \
57 obj/fsw_processing.o \
56 obj/fsw_misc.o \
58 obj/fsw_misc.o \
57 obj/fsw_init.o \
59 obj/fsw_init.o \
58 obj/fsw_globals.o \
60 obj/fsw_globals.o \
59 obj/fsw_spacewire.o
61 obj/fsw_spacewire.o \
62 obj/tc_load_dump_parameters.o \
63 obj/tm_lfr_tc_exe.o
60 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
64 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
61 /usr/lib64/qt4/mkspecs/common/linux.conf \
65 /usr/lib64/qt4/mkspecs/common/linux.conf \
62 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
66 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
@@ -214,7 +218,7 obj/fsw_processing.o: ../src/fsw_process
214 obj/fsw_misc.o: ../src/fsw_misc.c
218 obj/fsw_misc.o: ../src/fsw_misc.c
215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
219 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
216
220
217 obj/fsw_init.o: ../src/fsw_init.c
221 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
219
223
220 obj/fsw_globals.o: ../src/fsw_globals.c
224 obj/fsw_globals.o: ../src/fsw_globals.c
@@ -223,6 +227,12 obj/fsw_globals.o: ../src/fsw_globals.c
223 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
227 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
225
229
230 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
232
233 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
235
226 ####### Install
236 ####### Install
227
237
228 install: FORCE
238 install: FORCE
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -29,6 +29,10 contains( CONFIG, boot_messages ) {
29 DEFINES += BOOT_MESSAGES
29 DEFINES += BOOT_MESSAGES
30 }
30 }
31
31
32 #doxygen.target = doxygen
33 #doxygen.commands = doxygen ../doc/Doxyfile
34 #QMAKE_EXTRA_TARGETS += doxygen
35
32 TARGET = fsw
36 TARGET = fsw
33 contains( CONFIG, gsa ) {
37 contains( CONFIG, gsa ) {
34 DEFINES += GSA
38 DEFINES += GSA
@@ -46,7 +50,9 SOURCES += \
46 ../src/fsw_misc.c \
50 ../src/fsw_misc.c \
47 ../src/fsw_init.c \
51 ../src/fsw_init.c \
48 ../src/fsw_globals.c \
52 ../src/fsw_globals.c \
49 ../src/fsw_spacewire.c
53 ../src/fsw_spacewire.c \
54 ../src/tc_load_dump_parameters.c \
55 ../src/tm_lfr_tc_exe.c
50
56
51 HEADERS += \
57 HEADERS += \
52 ../header/wf_handler.h \
58 ../header/wf_handler.h \
@@ -59,5 +65,7 HEADERS += \
59 ../header/ccsds_types.h \
65 ../header/ccsds_types.h \
60 ../header/fsw_params_processing.h \
66 ../header/fsw_params_processing.h \
61 ../header/fsw_spacewire.h \
67 ../header/fsw_spacewire.h \
62 ../header/tm_byte_positions.h
68 ../header/tm_byte_positions.h \
69 ../header/tc_load_dump_parameters.h \
70 ../header/tm_lfr_tc_exe
63
71
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.0, 2013-10-11T07:07:36. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-17T08:46:24. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -56,7 +56,7
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@@ -79,7 +79,7
79 <value type="QString">-r</value>
79 <value type="QString">-r</value>
80 </valuelist>
80 </valuelist>
81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 </valuemap>
84 </valuemap>
85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
@@ -239,7 +239,55
239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 </valuemap>
241 </valuemap>
242 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
242 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
243 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
244 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
245 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
246 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
247 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
248 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
250 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
251 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
252 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
253 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
254 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
255 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
256 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
257 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
258 <value type="int">0</value>
259 <value type="int">1</value>
260 <value type="int">2</value>
261 <value type="int">3</value>
262 <value type="int">4</value>
263 <value type="int">5</value>
264 <value type="int">6</value>
265 <value type="int">7</value>
266 <value type="int">8</value>
267 <value type="int">9</value>
268 <value type="int">10</value>
269 <value type="int">11</value>
270 <value type="int">12</value>
271 <value type="int">13</value>
272 <value type="int">14</value>
273 </valuelist>
274 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
275 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
276 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
277 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
278 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
279 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
280 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
281 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
282 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
283 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
284 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
285 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
286 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
287 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
288 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
289 </valuemap>
290 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
243 </valuemap>
291 </valuemap>
244 </data>
292 </data>
245 <data>
293 <data>
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -111,23 +111,15
111 #define INCOR_CHECKSUM 2
111 #define INCOR_CHECKSUM 2
112 #define ILL_TYPE 3
112 #define ILL_TYPE 3
113 #define ILL_SUBTYPE 4
113 #define ILL_SUBTYPE 4
114 #define WRONG_APP_DATA 5
114 #define WRONG_APP_DATA 5 // 0x00 0x05
115 //
115 //
116 #define WRONG_CMD_CODE 6
117 #define CCSDS_TM_VALID 7
116 #define CCSDS_TM_VALID 7
118 #define FAILURE_CODE_INCONSISTENT 5 // 0x00 0x05
117 #define TC_NOT_EXE 42000 // 0xa4 0x10
119 #define FAILURE_CODE_NOT_EXECUTABLE 42000 // 0xa4 0x10
118 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
120 #define FAILURE_CODE_NOT_IMPLEMENTED 42002 // 0xa4 0x12
119 #define FAIL_DETECTED 42003 // 0xa4 0x13
121 #define FAILURE_CODE_ERROR 42003 // 0xa4 0x13
120 #define CORRUPTED 42005 // 0xa4 0x15
122 #define FAILURE_CODE_CORRUPTED 42005 // 0xa4 0x15
123
121
124 // TM SID
122 // TM SID
125 #define SID_DEFAULT 0
126 #define SID_EXE_INC 5
127 #define SID_NOT_EXE 42000 // 0xa4 0x10
128 #define SID_NOT_IMP 42002 // 0xa4 0x12
129 #define SID_EXE_ERR 42003 // 0xa4 0x13
130 #define SID_EXE_CORR 42005 // 0xa4 0x15
131 #define SID_HK 1
123 #define SID_HK 1
132 #define SID_PARAMETER_DUMP 10
124 #define SID_PARAMETER_DUMP 10
133
125
@@ -5,18 +5,19
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 #include <unistd.h> // for the read call
9 #include <sys/ioctl.h> // for the ioctl call
8
10
11 #include <rtems.h>
9 #include <grspw.h>
12 #include <grspw.h>
10 #include <apbuart.h>
13 #include <apbuart.h>
14 #include <leon.h>
11
15
12 #include "fsw_params.h"
16 #include "fsw_params.h"
13 #include "fsw_misc.h"
17 #include "fsw_misc.h"
14 #include "tm_byte_positions.h"
15 #include "fsw_processing.h"
18 #include "fsw_processing.h"
16 #include "tc_handler.h"
19 #include "tc_handler.h"
17 #include "wf_handler.h"
20 #include "wf_handler.h"
18 #include "grlib_regs.h"
19 #include "ccsds_types.h"
20
21
21 #include "fsw_spacewire.h"
22 #include "fsw_spacewire.h"
22
23
@@ -35,10 +36,7 extern Packet_TM_LFR_PARAMETER_DUMP_t pa
35 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
36 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
36
37
37 // RTEMS TASKS
38 // RTEMS TASKS
38 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
39 rtems_task Init( rtems_task_argument argument);
39 rtems_task recv_task(rtems_task_argument argument);
40 rtems_task stat_task(rtems_task_argument argument);
41 rtems_task wfrm_task(rtems_task_argument argument);
42
40
43 // OTHER functions
41 // OTHER functions
44 int create_names( void );
42 int create_names( void );
@@ -1,15 +1,7
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>
5 #include <stdio.h>
6
7 #include <grspw.h>
8
9 #include "fsw_init.h"
4 #include "fsw_init.h"
10 #include "fsw_params.h"
11 #include "grlib_regs.h"
12 #include "ccsds_types.h"
13
5
14 rtems_name HK_name; // name of the HK rate monotonic
6 rtems_name HK_name; // name of the HK rate monotonic
15 rtems_id HK_id; // id of the HK rate monotonic period
7 rtems_id HK_id; // id of the HK rate monotonic period
@@ -24,7 +16,7 void update_spacewire_statistics();
24
16
25 // SERIAL LINK
17 // SERIAL LINK
26 int send_console_outputs_on_apbuart_port( void );
18 int send_console_outputs_on_apbuart_port( void );
27 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
19 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
28
20
29 // RTEMS TASKS
21 // RTEMS TASKS
30 rtems_task stat_task(rtems_task_argument argument);
22 rtems_task stat_task(rtems_task_argument argument);
@@ -1,7 +1,9
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 #include "grlib_regs.h"
4 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
6 #include "tm_byte_positions.h"
5 #include "ccsds_types.h"
7 #include "ccsds_types.h"
6
8
7 #define GRSPW_DEVICE_NAME "/dev/grspw0"
9 #define GRSPW_DEVICE_NAME "/dev/grspw0"
@@ -138,7 +140,7
138
140
139 #define ACTION_MSG_QUEUE_COUNT 10
141 #define ACTION_MSG_QUEUE_COUNT 10
140 #define ACTION_MSG_PKTS_COUNT 50
142 #define ACTION_MSG_PKTS_COUNT 50
141 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
143 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
142 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
144 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
143
145
144 #define QUEUE_QUEU 0
146 #define QUEUE_QUEU 0
@@ -1,17 +1,7
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 #include <rtems.h>
4 #include "fsw_init.h"
5 #include <grspw.h>
6 #include <leon.h>
7
8 #include <fsw_init.h>
9 #include <fsw_params.h>
10 #include <grlib_regs.h>
11 #include <ccsds_types.h>
12
13 #include <stdio.h>
14 #include <stdlib.h>
15
5
16 extern volatile int spec_mat_f0_0[ ];
6 extern volatile int spec_mat_f0_0[ ];
17 extern volatile int spec_mat_f0_1[ ];
7 extern volatile int spec_mat_f0_1[ ];
@@ -50,9 +40,6 rtems_task bpf0_task(rtems_task_argument
50 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
40 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
51 rtems_task matr_task(rtems_task_argument argument);
41 rtems_task matr_task(rtems_task_argument argument);
52
42
53 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
54
55 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat);
56 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
43 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
57 void matrix_reset(volatile float *averaged_spec_mat);
44 void matrix_reset(volatile float *averaged_spec_mat);
58 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
45 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
@@ -62,7 +49,7 void init_header_asm( Header_TM_LFR_SCIE
62 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
49 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
63 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
50 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
64 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
51 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
65 void fill_averaged_spectral_matrix();
52 void fill_averaged_spectral_matrix( void );
66 void reset_spectral_matrix_regs();
53 void reset_spectral_matrix_regs();
67
54
68 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
55 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
@@ -1,17 +1,7
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include "fsw_init.h"
5
6 #include <grspw.h>
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <fcntl.h>
11
12 #include "fsw_params.h"
13 #include "ccsds_types.h"
14 #include "fsw_misc.h"
15
5
16 extern spw_stats spacewire_stats;
6 extern spw_stats spacewire_stats;
17 extern spw_stats spacewire_stats_backup;
7 extern spw_stats spacewire_stats_backup;
@@ -23,7 +13,7 int spacewire_configure_link( void );
23 int spacewire_wait_for_link(void);
13 int spacewire_wait_for_link(void);
24 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
14 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
25 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
15 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
26 void spacewire_compute_stats_offsets();
16 void spacewire_compute_stats_offsets(void);
27
17
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
18 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
19
@@ -1,16 +1,9
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>
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
6 #include <stdio.h>
7 #include <unistd.h> // for the read call
8 #include <sys/ioctl.h> // for the ioctl call
9 #include <ccsds_types.h>
10 #include <grspw.h>
11
12 #include "fsw_init.h"
4 #include "fsw_init.h"
13 #include "fsw_misc.h"
5 #include "tc_load_dump_parameters.h"
6 #include "tm_lfr_tc_exe.h"
14
7
15 // MODE PARAMETERS
8 // MODE PARAMETERS
16 extern struct param_sbm1_str param_sbm1;
9 extern struct param_sbm1_str param_sbm1;
@@ -33,8 +26,12 void updateLFRCurrentMode();
33
26
34 //*********************
27 //*********************
35 // ACCEPTANCE FUNCTIONS
28 // ACCEPTANCE FUNCTIONS
36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_queu_id, rtems_id queue_pkts_id);
29 int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_queu_id, rtems_id queue_pkts_id);
37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV);
30 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV);
31 int tc_check_type( unsigned char packetType );
32 int tc_check_subtype( unsigned char packetType );
33 int tc_check_length( unsigned char packetType, unsigned int length );
34 int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length );
38
35
39 //***********
36 //***********
40 // RTEMS TASK
37 // RTEMS TASK
@@ -45,12 +42,6 rtems_task dumb_task( rtems_task_argumen
45 //***********
42 //***********
46 // TC ACTIONS
43 // TC ACTIONS
47 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
44 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
48 int action_load_common_par(ccsdsTelecommandPacket_t *TC);
49 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
50 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
51 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
52 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
53 int action_dump_par(ccsdsTelecommandPacket_t *TC);
54 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
45 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
55 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
46 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
56 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
47 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
@@ -73,12 +64,6 int suspend_science_tasks();
73 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
64 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
74 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
65 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
75 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
66 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
76 //
77 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
78 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char byte_position, unsigned char rcv_value);
79 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
80 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
81 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
82
67
83 #endif // TC_HANDLER_H_INCLUDED
68 #endif // TC_HANDLER_H_INCLUDED
84
69
@@ -3,4 +3,20
3
3
4 #define BYTE_POS_CP_LFR_MODE 11
4 #define BYTE_POS_CP_LFR_MODE 11
5
5
6 // TC_LFR_LOAD_COMMON_PAR
7
8 // TC_LFR_LOAD_NORMAL_PAR
9 #define BYTE_POS_SY_LFR_N_SWF_L 0
10 #define BYTE_POS_SY_LFR_N_SWF_P 2
11 #define BYTE_POS_SY_LFR_N_ASM_P 4
12 #define BYTE_POS_SY_LFR_N_BP_P0 6
13 #define BYTE_POS_SY_LFR_N_BP_P1 7
14
15 // TC_LFR_LOAD_BURST_PAR
16
17 // TC_LFR_LOAD_SBM1_PAR
18
19 // TC_LFR_LOAD_SBM2_PAR
20
21
6 #endif // TM_BYTE_POSITIONS_H
22 #endif // TM_BYTE_POSITIONS_H
@@ -1,21 +1,12
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 "fsw_init.h"
5 #include <grspw.h>
6
5
7 #include <stdio.h>
8 #include <math.h>
6 #include <math.h>
9
7
10 #include "fsw_params.h"
11 #include "grlib_regs.h"
12 #include "ccsds_types.h"
13 #include "fsw_init.h"
14
15 #define pi 3.1415
8 #define pi 3.1415
16
9
17 //#include <sys/ioctl.h>
18
19 extern int fdSPW;
10 extern int fdSPW;
20 extern volatile int wf_snap_f0[ ];
11 extern volatile int wf_snap_f0[ ];
21 //
12 //
@@ -1,9 +1,9
1 //#include <fsw_processing.h>
1 //#include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3 #include <grspw.h>
3 #include <grspw.h>
4 #include <ccsds_types.h>
4 #include "ccsds_types.h"
5 #include <grlib_regs.h>
5 #include "grlib_regs.h"
6 #include <fsw_params.h>
6 #include "fsw_params.h"
7
7
8 // RTEMS GLOBAL VARIABLES
8 // RTEMS GLOBAL VARIABLES
9 rtems_name misc_name[5];
9 rtems_name misc_name[5];
@@ -46,8 +46,8
46 #include <drvmgr/drvmgr_confdefs.h>
46 #include <drvmgr/drvmgr_confdefs.h>
47 #endif
47 #endif
48
48
49 #include <fsw_init.h>
49 #include "fsw_init.h"
50 #include <fsw_config.c>
50 #include "fsw_config.c"
51
51
52 rtems_task Init( rtems_task_argument ignored )
52 rtems_task Init( rtems_task_argument ignored )
53 {
53 {
@@ -63,7 +63,6 rtems_task Init( rtems_task_argument ign
63 //send_console_outputs_on_apbuart_port();
63 //send_console_outputs_on_apbuart_port();
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
65
65
66 initLookUpTableForCRC(); // in tc_handler.h
67 init_parameter_dump();
66 init_parameter_dump();
68 init_local_mode_parameters();
67 init_local_mode_parameters();
69 init_housekeeping_parameters();
68 init_housekeeping_parameters();
@@ -72,11 +71,23 rtems_task Init( rtems_task_argument ign
72
71
73 create_message_queues();
72 create_message_queues();
74
73
75 create_all_tasks(); // create all tasks
74 status = create_all_tasks(); // create all tasks
75 if (status != RTEMS_SUCCESSFUL)
76 {
77 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
78 }
76
79
77 start_all_tasks(); // start all tasks
80 status = start_all_tasks(); // start all tasks
81 if (status != RTEMS_SUCCESSFUL)
82 {
83 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
84 }
78
85
79 stop_current_mode(); // go in STANDBY mode
86 status = stop_current_mode(); // go in STANDBY mode
87 if (status != RTEMS_SUCCESSFUL)
88 {
89 PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status)
90 }
80
91
81 grspw_timecode_callback = &timecode_irq_handler;
92 grspw_timecode_callback = &timecode_irq_handler;
82
93
@@ -224,8 +235,15 void init_housekeeping_parameters( void
224 updateLFRCurrentMode();
235 updateLFRCurrentMode();
225 }
236 }
226
237
227 int create_names( void )
238 int create_names( void ) // create all names for tasks and queues
228 {
239 {
240 /** This function creates all RTEMS names used in the software for tasks and queues.
241 *
242 * @return RTEMS directive status codes:
243 * - RTEMS_SUCCESSFUL - message sent successfully
244 *
245 */
246
229 // task names
247 // task names
230 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
248 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
231 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
249 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
@@ -249,11 +267,25 int create_names( void )
249 misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' );
267 misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' );
250 misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' );
268 misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' );
251
269
252 return 0;
270 return RTEMS_SUCCESSFUL;
253 }
271 }
254
272
255 int create_all_tasks( void )
273 int create_all_tasks( void ) // create all tasks which run in the software
256 {
274 {
275 /** This function creates all RTEMS tasks used in the software.
276 *
277 * @return RTEMS directive status codes:
278 * - RTEMS_SUCCESSFUL - task created successfully
279 * - RTEMS_INVALID_ADDRESS - id is NULL
280 * - RTEMS_INVALID_NAME - invalid task name
281 * - RTEMS_INVALID_PRIORITY - invalid task priority
282 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
283 * - RTEMS_TOO_MANY - too many tasks created
284 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
285 * - RTEMS_TOO_MANY - too many global objects
286 *
287 */
288
257 rtems_status_code status;
289 rtems_status_code status;
258
290
259 // RECV
291 // RECV
@@ -262,96 +294,137 int create_all_tasks( void )
262 RTEMS_DEFAULT_MODES,
294 RTEMS_DEFAULT_MODES,
263 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
295 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
264 );
296 );
265 // ACTN
297
298 if (status == RTEMS_SUCCESSFUL) // ACTN
299 {
266 status = rtems_task_create(
300 status = rtems_task_create(
267 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
301 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
268 RTEMS_DEFAULT_MODES,
302 RTEMS_DEFAULT_MODES,
269 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
303 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
270 );
304 );
271 // SPIQ
305 }
306 if (status == RTEMS_SUCCESSFUL) // SPIQ
307 {
272 status = rtems_task_create(
308 status = rtems_task_create(
273 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
309 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
274 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
310 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
275 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
276 );
312 );
277 // SMIQ
313 }
314 if (status == RTEMS_SUCCESSFUL) // SMIQ
315 {
278 status = rtems_task_create(
316 status = rtems_task_create(
279 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
317 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
280 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
318 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
319 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
282 );
320 );
283 // STAT
321 }
322 if (status == RTEMS_SUCCESSFUL) // STAT
323 {
284 status = rtems_task_create(
324 status = rtems_task_create(
285 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
325 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
286 RTEMS_DEFAULT_MODES,
326 RTEMS_DEFAULT_MODES,
287 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
327 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
288 );
328 );
289 // AVF0
329 }
330 if (status == RTEMS_SUCCESSFUL) // AVF0
331 {
290 status = rtems_task_create(
332 status = rtems_task_create(
291 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
333 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
292 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
334 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
335 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
294 );
336 );
295 // BPF0
337 }
338 if (status == RTEMS_SUCCESSFUL) // BPF0
339 {
296 status = rtems_task_create(
340 status = rtems_task_create(
297 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
341 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
298 RTEMS_DEFAULT_MODES,
342 RTEMS_DEFAULT_MODES,
299 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
343 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
300 );
344 );
301 // WFRM
345 }
346 if (status == RTEMS_SUCCESSFUL) // WFRM
347 {
302 status = rtems_task_create(
348 status = rtems_task_create(
303 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
349 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
304 RTEMS_DEFAULT_MODES,
350 RTEMS_DEFAULT_MODES,
305 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
351 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
306 );
352 );
307 // DUMB
353 }
354 if (status == RTEMS_SUCCESSFUL) // DUMB
355 {
308 status = rtems_task_create(
356 status = rtems_task_create(
309 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
357 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
310 RTEMS_DEFAULT_MODES,
358 RTEMS_DEFAULT_MODES,
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
359 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
312 );
360 );
313 // HOUS
361 }
362 if (status == RTEMS_SUCCESSFUL) // HOUS
363 {
314 status = rtems_task_create(
364 status = rtems_task_create(
315 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
365 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
316 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_MODES,
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
367 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
318 );
368 );
319 // MATR
369 }
370 if (status == RTEMS_SUCCESSFUL) // MATR
371 {
320 status = rtems_task_create(
372 status = rtems_task_create(
321 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
373 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
322 RTEMS_DEFAULT_MODES,
374 RTEMS_DEFAULT_MODES,
323 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
324 );
376 );
325 // CWF3
377 }
378 if (status == RTEMS_SUCCESSFUL) // CWF3
379 {
326 status = rtems_task_create(
380 status = rtems_task_create(
327 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
381 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
328 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_MODES,
329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
383 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
330 );
384 );
331 // CWF2
385 }
386 if (status == RTEMS_SUCCESSFUL) // CWF2
387 {
332 status = rtems_task_create(
388 status = rtems_task_create(
333 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
389 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
334 RTEMS_DEFAULT_MODES,
390 RTEMS_DEFAULT_MODES,
335 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
336 );
392 );
337 // CWF1
393 }
394 if (status == RTEMS_SUCCESSFUL) // CWF1
395 {
338 status = rtems_task_create(
396 status = rtems_task_create(
339 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
397 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
340 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_MODES,
341 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
342 );
400 );
343 // SEND
401 }
402 if (status == RTEMS_SUCCESSFUL) // SEND
403 {
344 status = rtems_task_create(
404 status = rtems_task_create(
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
405 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
346 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
406 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
407 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
348 );
408 );
409 }
349
410
350 return 0;
411 return status;
351 }
412 }
352
413
353 int start_all_tasks( void )
414 int start_all_tasks( void )
354 {
415 {
416 /** This function starts all RTEMS tasks used in the software.
417 *
418 * @return RTEMS directive status codes:
419 * - RTEMS_SUCCESSFUL - ask started successfully
420 * - RTEMS_INVALID_ADDRESS - invalid task entry point
421 * - RTEMS_INVALID_ID - invalid task id
422 * - RTEMS_INCORRECT_STATE - task not in the dormant state
423 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
424 *
425 */
426 // starts all the tasks fot eh flight software
427
355 rtems_status_code status;
428 rtems_status_code status;
356
429
357 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
430 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
@@ -359,85 +432,128 int start_all_tasks( void )
359 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
432 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
360 }
433 }
361
434
435 if (status == RTEMS_SUCCESSFUL) // SMIQ
436 {
362 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
437 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
363 if (status!=RTEMS_SUCCESSFUL) {
438 if (status!=RTEMS_SUCCESSFUL) {
364 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
439 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
365 }
440 }
441 }
366
442
443 if (status == RTEMS_SUCCESSFUL) // RECV
444 {
367 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
445 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
368 if (status!=RTEMS_SUCCESSFUL) {
446 if (status!=RTEMS_SUCCESSFUL) {
369 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
447 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
370 }
448 }
449 }
371
450
451 if (status == RTEMS_SUCCESSFUL) // SEND
452 {
372 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
453 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
373 if (status!=RTEMS_SUCCESSFUL) {
454 if (status!=RTEMS_SUCCESSFUL) {
374 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
455 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
375 }
456 }
457 }
376
458
459 if (status == RTEMS_SUCCESSFUL) // ACTN
460 {
377 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
461 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
378 if (status!=RTEMS_SUCCESSFUL) {
462 if (status!=RTEMS_SUCCESSFUL) {
379 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
463 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
380 }
464 }
465 }
381
466
467 if (status == RTEMS_SUCCESSFUL) // STAT
468 {
382 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
469 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
383 if (status!=RTEMS_SUCCESSFUL) {
470 if (status!=RTEMS_SUCCESSFUL) {
384 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
471 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
385 }
472 }
473 }
386
474
475 if (status == RTEMS_SUCCESSFUL) // AVF0
476 {
387 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
477 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
388 if (status!=RTEMS_SUCCESSFUL) {
478 if (status!=RTEMS_SUCCESSFUL) {
389 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
479 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
390 }
480 }
481 }
391
482
483 if (status == RTEMS_SUCCESSFUL) // BPF0
484 {
392 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
485 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
393 if (status!=RTEMS_SUCCESSFUL) {
486 if (status!=RTEMS_SUCCESSFUL) {
394 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
487 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
395 }
488 }
489 }
396
490
491 if (status == RTEMS_SUCCESSFUL) // WFRM
492 {
397 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
493 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
398 if (status!=RTEMS_SUCCESSFUL) {
494 if (status!=RTEMS_SUCCESSFUL) {
399 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
495 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
400 }
496 }
497 }
401
498
499 if (status == RTEMS_SUCCESSFUL) // DUMB
500 {
402 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
501 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
403 if (status!=RTEMS_SUCCESSFUL) {
502 if (status!=RTEMS_SUCCESSFUL) {
404 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
503 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
405 }
504 }
505 }
406
506
507 if (status == RTEMS_SUCCESSFUL) // HOUS
508 {
407 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
509 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
408 if (status!=RTEMS_SUCCESSFUL) {
510 if (status!=RTEMS_SUCCESSFUL) {
409 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
511 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
410 }
512 }
513 }
411
514
515 if (status == RTEMS_SUCCESSFUL) // MATR
516 {
412 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
517 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
413 if (status!=RTEMS_SUCCESSFUL) {
518 if (status!=RTEMS_SUCCESSFUL) {
414 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
519 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
415 }
520 }
521 }
416
522
523 if (status == RTEMS_SUCCESSFUL) // CWF3
524 {
417 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
525 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
418 if (status!=RTEMS_SUCCESSFUL) {
526 if (status!=RTEMS_SUCCESSFUL) {
419 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
527 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
420 }
528 }
529 }
421
530
531 if (status == RTEMS_SUCCESSFUL) // CWF2
532 {
422 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
533 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
423 if (status!=RTEMS_SUCCESSFUL) {
534 if (status!=RTEMS_SUCCESSFUL) {
424 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
535 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
425 }
536 }
537 }
426
538
539 if (status == RTEMS_SUCCESSFUL) // CWF1
540 {
427 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
541 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
428 if (status!=RTEMS_SUCCESSFUL) {
542 if (status!=RTEMS_SUCCESSFUL) {
429 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
543 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
430 }
544 }
431
432 return 0;
433 }
545 }
434
546
435 rtems_status_code create_message_queues( void )
547 return status;
548 }
549
550 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
436 {
551 {
437 rtems_status_code status;
552 rtems_status_code status;
438 rtems_status_code ret;
553 rtems_status_code ret;
439 rtems_id queue_id;
554 rtems_id queue_id;
440
555
556 // create the queue for handling TM packet sending
441 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT,
557 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT,
442 ACTION_MSG_PKTS_MAX_SIZE,
558 ACTION_MSG_PKTS_MAX_SIZE,
443 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
559 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
@@ -445,6 +561,7 rtems_status_code create_message_queues(
445 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
561 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
446 }
562 }
447
563
564 // create the queue for handling valid TCs
448 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
565 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
449 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
566 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
450 if (status != RTEMS_SUCCESSFUL) {
567 if (status != RTEMS_SUCCESSFUL) {
@@ -1,5 +1,4
1 #include <fsw_misc.h>
1 #include "fsw_misc.h"
2 #include <fsw_params.h>
3
2
4 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
3 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
5 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
4 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
@@ -120,14 +119,21 int send_console_outputs_on_apbuart_port
120 return 0;
119 return 0;
121 }
120 }
122
121
123 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
122 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
124 {
123 {
124 /** This function sets the scaler reload register of the apbuart module
125 *
126 * @param regs is the address of the apbuart registers in memory
127 * @param value is the value that will be stored in the scaler register
128 *
129 * The value shall be set by the software to get data on the serial interface.
130 *
131 */
132
125 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
133 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
126
134
127 apbuart_regs->scaler = value;
135 apbuart_regs->scaler = value;
128 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
136 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
129
130 return 0;
131 }
137 }
132
138
133 //************
139 //************
@@ -135,34 +135,11 rtems_task spw_bppr_task(rtems_task_argu
135 {
135 {
136 rtems_status_code status;
136 rtems_status_code status;
137 rtems_event_set event_out;
137 rtems_event_set event_out;
138 static int Nb_average_f0 = 0;
139 //static int nb_average_f1 = 0;
140 //static int nb_average_f2 = 0;
141
138
142 BOOT_PRINTF("in BPPR ***\n");
139 BOOT_PRINTF("in BPPR ***\n");
143
140
144 while(true){ // wait for an event to begin with the processing
141 while( true ){ // wait for an event to begin with the processing
145 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
142 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
146 if (status == RTEMS_SUCCESSFUL) {
147 if ((spectral_matrix_regs->status & 0x00000001)==1) {
148 matrix_average(spec_mat_f0_0, averaged_spec_mat_f0);
149 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
150 //printf("f0_a\n");
151 Nb_average_f0++;
152 }
153 if (((spectral_matrix_regs->status>>1) & 0x00000001)==1) {
154 matrix_average(spec_mat_f0_1, compressed_spec_mat_f0);
155 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
156 //printf("f0_b\n");
157 Nb_average_f0++;
158 }
159 if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) {
160 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
161 //printf("f0 compressed\n");
162 Nb_average_f0 = 0;
163 matrix_reset(averaged_spec_mat_f0);
164 }
165 }
166 }
143 }
167 }
144 }
168
145
@@ -249,20 +226,6 rtems_task matr_task(rtems_task_argument
249
226
250 //*****************************
227 //*****************************
251 // Spectral matrices processing
228 // Spectral matrices processing
252 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat)
253 {
254 int i;
255 for(i=0; i<TOTAL_SIZE_SM; i++){
256 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_0[i]
257 + spec_mat_f0_1[i]
258 + spec_mat_f0_c[i]
259 + spec_mat_f0_d[i]
260 + spec_mat_f0_e[i]
261 + spec_mat_f0_f[i]
262 + spec_mat_f0_g[i]
263 + spec_mat_f0_h[i];
264 }
265 }
266
229
267 void matrix_reset(volatile float *averaged_spec_mat)
230 void matrix_reset(volatile float *averaged_spec_mat)
268 {
231 {
@@ -586,8 +549,13 void convert_averaged_spectral_matrix( v
586 }
549 }
587 }
550 }
588
551
589 void fill_averaged_spectral_matrix( )
552 void fill_averaged_spectral_matrix(void)
590 {
553 {
554 /** This function fills spectral matrices related buffers with arbitrary data.
555 *
556 * This function is for testing purpose only.
557 *
558 */
591
559
592 #ifdef GSA
560 #ifdef GSA
593 float offset = 10.;
561 float offset = 10.;
@@ -671,6 +639,19 void fill_averaged_spectral_matrix( )
671
639
672 void reset_spectral_matrix_regs()
640 void reset_spectral_matrix_regs()
673 {
641 {
642 /** This function resets the spectral matrices module registers.
643 *
644 * The registers affected by this function are located at the following offset addresses:
645 *
646 * - 0x00 config
647 * - 0x04 status
648 * - 0x08 matrixF0_Address0
649 * - 0x10 matrixFO_Address1
650 * - 0x14 matrixF1_Address
651 * - 0x18 matrixF2_Address
652 *
653 */
654
674 #ifdef GSA
655 #ifdef GSA
675 #else
656 #else
676 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
657 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
@@ -157,8 +157,15 void spacewire_set_RE(unsigned char val,
157 }
157 }
158 }
158 }
159
159
160 void spacewire_compute_stats_offsets()
160 void spacewire_compute_stats_offsets( void )
161 {
161 {
162 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
163 *
164 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
165 * to keep the counters consistent even after a reset of the SpaceWire driver.
166 *
167 */
168
162 spw_stats spacewire_stats_grspw;
169 spw_stats spacewire_stats_grspw;
163 rtems_status_code status;
170 rtems_status_code status;
164
171
This diff has been collapsed as it changes many lines, (950 lines changed) Show them Hide them
@@ -1,5 +1,16
1 #include <tc_handler.h>
1 /** Functions and tasks related to TeleCommand handling.
2 #include <fsw_params.h>
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
8 * TC parsing\n
9 * ...
10 *
11 */
12
13 #include "tc_handler.h"
3
14
4 char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0
15 char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0
5 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
16 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
@@ -10,7 +21,6 char *DumbMessages[6] = {"in DUMB *** de
10 };
21 };
11
22
12 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
23 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
13 unsigned char currentTC_COMPUTED_CRC[2];
14 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
24 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
15 unsigned int currentTM_length;
25 unsigned int currentTM_length;
16 unsigned char currentTC_processedFlag;
26 unsigned char currentTC_processedFlag;
@@ -21,11 +31,25 unsigned int lookUpTableForCRC[256];
21 // GENERAL USE FUNCTIONS
31 // GENERAL USE FUNCTIONS
22 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
32 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
23 {
33 {
34 /** This function generate the CRC for one byte and returns the value of the new syndrome.
35 *
36 * @param D is the current byte of data.
37 * @param Chk is the current syndrom value.
38 * @return the value of the new syndrome on two bytes.
39 *
40 */
41
24 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
42 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
25 }
43 }
26
44
27 void initLookUpTableForCRC( void )
45 void initLookUpTableForCRC( void )
28 {
46 {
47 /** This function is used to initiates the look-up table for fast CRC computation.
48 *
49 * The global table lookUpTableForCRC[256] is initiated.
50 *
51 */
52
29 unsigned int i;
53 unsigned int i;
30 unsigned int tmp;
54 unsigned int tmp;
31
55
@@ -62,6 +86,16 void initLookUpTableForCRC( void )
62
86
63 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
87 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
64 {
88 {
89 /** This function calculates a two bytes Cyclic Redundancy Code.
90 *
91 * @param data points to a buffer containing the data on which to compute the CRC.
92 * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored.
93 * @param sizeOfData is the number of bytes of *data* used to compute the CRC.
94 *
95 * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A.
96 *
97 */
98
65 unsigned int Chk;
99 unsigned int Chk;
66 int j;
100 int j;
67 Chk = 0xffff; // reset the syndrom to all ones
101 Chk = 0xffff; // reset the syndrom to all ones
@@ -74,74 +108,44 void GetCRCAsTwoBytes(unsigned char* dat
74
108
75 void updateLFRCurrentMode()
109 void updateLFRCurrentMode()
76 {
110 {
111 /** This function updates the value of the global variable lfrCurrentMode.
112 *
113 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
114 *
115 */
116 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
77 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
117 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
78 }
118 }
79
119
80 //*********************
120 //*********************
81 // ACCEPTANCE FUNCTIONS
121 // ACCEPTANCE FUNCTIONS
82 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_queu_id, rtems_id queue_pkts_id)
122 int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_queu_id, rtems_id queue_pkts_id)
83 {
123 {
124 /** This function executes the TeleCommand acceptance steps.
125 *
126 * @param TC points to the TeleCommand packet which is under investigation.
127 * @param tc_len_recv contains the length of the packet that has been received.
128 * @param queue_queu_id is the id of the rtems queue in which messages are written if the acceptance is not successful
129 * @param queue_pkts_id is the id of the rtems queue in which messages are written if the acceptance is successful
130 * @return status code
131 *
132 * The acceptance steps can result in two different actions.
133 * 1. If the acceptance is successful, the TC is sent in the receiving queue for processing.
134 * 2. If the acceptance fails, a TM packet is transmitted to report the error.
135 *
136 */
137
84 int ret = 0;
138 int ret = 0;
85 rtems_status_code status;
139 rtems_status_code status;
86 Packet_TM_LFR_TC_EXE_CORRUPTED_t packet;
87 unsigned int parserCode = 0;
140 unsigned int parserCode = 0;
88 unsigned char computed_CRC[2];
141 unsigned char computed_CRC[2];
89 unsigned int packetLength;
90 unsigned char *packetDataField;
91
142
92 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
143 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
93 parserCode = TC_parser( TC, tc_len_recv ) ;
144 parserCode = tc_parser( TC, tc_len_recv ) ;
94 if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM)
145 if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM)
95 | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) )
146 | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) )
96 { // generate TM_LFR_TC_EXE_CORRUPTED
147 { // send TM_LFR_TC_EXE_CORRUPTED
97 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
148 send_tm_lfr_tc_exe_corrupted( TC, queue_queu_id, computed_CRC, currentTC_LEN_RCV );
98 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length
99 //
100 packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
101 packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
102 packet.reserved = DEFAULT_RESERVED;
103 packet.userApplication = CCSDS_USER_APP;
104 // PACKET HEADER
105 packet.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
106 packet.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
107 packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
108 packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
109 packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
110 packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
111 // DATA FIELD HEADER
112 packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
113 packet.serviceType = TM_TYPE_TC_EXE;
114 packet.serviceSubType = TM_SUBTYPE_EXE_NOK;
115 packet.destinationID = TM_DESTINATION_ID_GROUND;
116 packet.time[0] = (time_management_regs->coarse_time>>24 );
117 packet.time[1] = (time_management_regs->coarse_time>>16 );
118 packet.time[2] = (time_management_regs->coarse_time>>8 );
119 packet.time[3] = (time_management_regs->coarse_time );
120 packet.time[4] = (time_management_regs->fine_time>>8 );
121 packet.time[5] = (time_management_regs->fine_time );
122 //
123 packet.tc_failure_code[0] = (unsigned char) (FAILURE_CODE_CORRUPTED >> 8);
124 packet.tc_failure_code[1] = (unsigned char) (FAILURE_CODE_CORRUPTED );
125 packet.telecommand_pkt_id[0] = TC->packetID[0];
126 packet.telecommand_pkt_id[1] = TC->packetID[1];
127 packet.pkt_seq_control[0] = TC->packetSequenceControl[0];
128 packet.pkt_seq_control[0] = TC->packetSequenceControl[1];
129 packet.tc_service = TC->serviceType;
130 packet.tc_subtype = TC->serviceSubType;
131 packet.pkt_len_rcv_value[0] = TC->packetLength[0];
132 packet.pkt_len_rcv_value[1] = TC->packetLength[1];
133 packet.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
134 packet.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
135 packet.rcv_crc[0] = packetDataField[ packetLength - 1 ];
136 packet.rcv_crc[1] = packetDataField[ packetLength ];
137 packet.computed_crc[0] = computed_CRC[0];
138 packet.computed_crc[1] = computed_CRC[1];
139 // SEND DATA
140 status = rtems_message_queue_urgent( queue_pkts_id, &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
141 if (status != RTEMS_SUCCESSFUL) {
142 PRINTF("in TC_acceptance *** ERR rtems_message_queue_urgent\n")
143 ret = LFR_DEFAULT;
144 }
145 }
149 }
146 else { // send valid TC to the action launcher
150 else { // send valid TC to the action launcher
147 status = rtems_message_queue_send( queue_queu_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
151 status = rtems_message_queue_send( queue_queu_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
@@ -150,15 +154,32 int TC_acceptance(ccsdsTelecommandPacket
150 return ret;
154 return ret;
151 }
155 }
152
156
153 unsigned char TC_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV)
157 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV)
154 {
158 {
155 unsigned char ret = 0;
159 /** This function parses TeleCommands.
156 unsigned char pid = 0;
160 *
157 unsigned char category = 0;
161 * @param TC points to the TeleCommand that will be parsed.
158 unsigned int length = 0;
162 * @param TC_LEN_RCV is the received packet length.
159 unsigned char packetType = 0;
163 * @return Status code of the parsing.
160 unsigned char packetSubtype = 0;
164 *
161 unsigned char * CCSDSContent = NULL;
165 * The parsing checks:
166 * - process id
167 * - category
168 * - length: a global check is performed and a per subtype check also
169 * - type
170 * - subtype
171 * - crc
172 *
173 */
174
175 int status;
176 unsigned char pid;
177 unsigned char category;
178 unsigned int length;
179 unsigned char packetType;
180 unsigned char packetSubtype;
181
182 status = CCSDS_TM_VALID;
162
183
163 // APID check *** APID on 2 bytes
184 // APID check *** APID on 2 bytes
164 pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
185 pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
@@ -167,152 +188,266 unsigned char TC_parser(ccsdsTelecommand
167 packetType = TCPacket->serviceType;
188 packetType = TCPacket->serviceType;
168 packetSubtype = TCPacket->serviceSubType;
189 packetSubtype = TCPacket->serviceSubType;
169
190
170 if ( pid != CCSDS_PROCESS_ID ) {
191 if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID
171 ret = ILLEGAL_APID;
192 {
193 status = ILLEGAL_APID;
194 }
195 if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY
196 {
197 if ( category != CCSDS_PACKET_CATEGORY )
198 {
199 status = ILLEGAL_APID;
200 }
201 }
202 if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE
203 {
204 if (length != TC_LEN_RCV ) {
205 status = WRONG_LEN_PACKET;
206 }
172 }
207 }
173 else if ( category != CCSDS_PACKET_CATEGORY ) {
208 if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE
174 ret = ILLEGAL_APID;
209 {
210 if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
211 status = WRONG_LEN_PACKET;
212 }
213 }
214 if (status == CCSDS_TM_VALID) // CHECK THE TYPE
215 {
216 status = tc_check_type( packetType );
217 }
218 if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE
219 {
220 status = tc_check_subtype( packetSubtype );
221 }
222 if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE
223 {
224 status = tc_check_length( packetSubtype, length );
225 }
226 if (status == CCSDS_TM_VALID ) // CHECK CRC
227 {
228 status = tc_check_crc( TCPacket, length );
229 }
230
231 return status;
175 }
232 }
176 else if (length != TC_LEN_RCV ) { // packet length check
233
177 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
234 int tc_check_type( unsigned char packetType )
235 {
236 /** This function checks that the type of a TeleCommand is valid.
237 *
238 * @param packetType is the type to check.
239 * @return Status code CCSDS_TM_VALID or ILL_TYPE.
240 *
241 */
242
243 int status;
244
245 if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME))
246 {
247 status = CCSDS_TM_VALID;
248 }
249 else
250 {
251 status = ILL_TYPE;
252 }
253
254 return status;
178 }
255 }
179 else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
256
180 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
257 int tc_check_subtype( unsigned char packetSubType )
258 {
259 /** This function checks that the subtype of a TeleCommand is valid.
260 *
261 * @param packetSubType is the subtype to check.
262 * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE.
263 *
264 */
265
266 int status;
267
268 if ( (packetSubType == TC_SUBTYPE_RESET)
269 || (packetSubType == TC_SUBTYPE_LOAD_COMM)
270 || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST)
271 || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2)
272 || (packetSubType == TC_SUBTYPE_DUMP)
273 || (packetSubType == TC_SUBTYPE_ENTER)
274 || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME)
275 || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) )
276 {
277 status = CCSDS_TM_VALID;
181 }
278 }
182 else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check
279 else
183 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
280 {
281 status = ILL_TYPE;
282 }
283
284 return status;
285 }
286
287 int tc_check_length( unsigned char packetSubType, unsigned int length )
288 {
289 /** This function checks that the subtype and the length are compliant.
290 *
291 * @param packetSubType is the subtype to check.
292 * @param length is the length to check.
293 * @return Status code CCSDS_TM_VALID or ILL_TYPE.
294 *
295 */
296
297 int status;
298
299 status = LFR_SUCCESSFUL;
300
301 switch(packetSubType)
302 {
184 case TC_SUBTYPE_RESET:
303 case TC_SUBTYPE_RESET:
185 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
304 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
186 ret = WRONG_LEN_PACKET;
305 status = WRONG_LEN_PACKET;
187 }
306 }
188 else {
307 else {
189 ret = CCSDS_TM_VALID;
308 status = CCSDS_TM_VALID;
190 }
309 }
191 break;
310 break;
192 case TC_SUBTYPE_LOAD_COMM:
311 case TC_SUBTYPE_LOAD_COMM:
193 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
312 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
194 ret = WRONG_LEN_PACKET;
313 status = WRONG_LEN_PACKET;
195 }
314 }
196 else {
315 else {
197 ret = CCSDS_TM_VALID;
316 status = CCSDS_TM_VALID;
198 }
317 }
199 break;
318 break;
200 case TC_SUBTYPE_LOAD_NORM:
319 case TC_SUBTYPE_LOAD_NORM:
201 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
320 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
202 ret = WRONG_LEN_PACKET;
321 status = WRONG_LEN_PACKET;
203 }
322 }
204 else {
323 else {
205 ret = CCSDS_TM_VALID;
324 status = CCSDS_TM_VALID;
206 }
325 }
207 break;
326 break;
208 case TC_SUBTYPE_LOAD_BURST:
327 case TC_SUBTYPE_LOAD_BURST:
209 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
328 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
210 ret = WRONG_LEN_PACKET;
329 status = WRONG_LEN_PACKET;
211 }
330 }
212 else {
331 else {
213 ret = CCSDS_TM_VALID;
332 status = CCSDS_TM_VALID;
214 }
333 }
215 break;
334 break;
216 case TC_SUBTYPE_LOAD_SBM1:
335 case TC_SUBTYPE_LOAD_SBM1:
217 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
336 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
218 ret = WRONG_LEN_PACKET;
337 status = WRONG_LEN_PACKET;
219 }
338 }
220 else {
339 else {
221 ret = CCSDS_TM_VALID;
340 status = CCSDS_TM_VALID;
222 }
341 }
223 break;
342 break;
224 case TC_SUBTYPE_LOAD_SBM2:
343 case TC_SUBTYPE_LOAD_SBM2:
225 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
344 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
226 ret = WRONG_LEN_PACKET;
345 status = WRONG_LEN_PACKET;
227 }
346 }
228 else {
347 else {
229 ret = CCSDS_TM_VALID;
348 status = CCSDS_TM_VALID;
230 }
349 }
231 break;
350 break;
232 case TC_SUBTYPE_DUMP:
351 case TC_SUBTYPE_DUMP:
233 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
352 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
234 ret = WRONG_LEN_PACKET;
353 status = WRONG_LEN_PACKET;
235 }
354 }
236 else {
355 else {
237 ret = CCSDS_TM_VALID;
356 status = CCSDS_TM_VALID;
238 }
357 }
239 break;
358 break;
240 case TC_SUBTYPE_ENTER:
359 case TC_SUBTYPE_ENTER:
241 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
360 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
242 ret = WRONG_LEN_PACKET;
361 status = WRONG_LEN_PACKET;
243 }
362 }
244 else {
363 else {
245 ret = CCSDS_TM_VALID;
364 status = CCSDS_TM_VALID;
246 }
365 }
247 break;
366 break;
248 case TC_SUBTYPE_UPDT_INFO:
367 case TC_SUBTYPE_UPDT_INFO:
249 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
368 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
250 ret = WRONG_LEN_PACKET;
369 status = WRONG_LEN_PACKET;
251 }
370 }
252 else {
371 else {
253 ret = CCSDS_TM_VALID;
372 status = CCSDS_TM_VALID;
254 }
373 }
255 break;
374 break;
256 case TC_SUBTYPE_EN_CAL:
375 case TC_SUBTYPE_EN_CAL:
257 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
376 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
258 ret = WRONG_LEN_PACKET;
377 status = WRONG_LEN_PACKET;
259 }
378 }
260 else {
379 else {
261 ret = CCSDS_TM_VALID;
380 status = CCSDS_TM_VALID;
262 }
381 }
263 break;
382 break;
264 case TC_SUBTYPE_DIS_CAL:
383 case TC_SUBTYPE_DIS_CAL:
265 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
384 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
266 ret = WRONG_LEN_PACKET;
385 status = WRONG_LEN_PACKET;
267 }
386 }
268 else {
387 else {
269 ret = CCSDS_TM_VALID;
388 status = CCSDS_TM_VALID;
270 }
389 }
271 break;
390 break;
272 default:
391 case TC_SUBTYPE_UPDT_TIME:
273 ret = ILL_SUBTYPE;
392 if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
393 status = WRONG_LEN_PACKET;
394 }
395 else {
396 status = CCSDS_TM_VALID;
397 }
398 break;
399 default: // if the subtype is not a legal value, return ILL_SUBTYPE
400 status = ILL_SUBTYPE;
274 break;
401 break ;
275 }
402 }
276 }
403
277 else if ( packetType == TC_TYPE_TIME ){
404 return status;
278 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
279 ret = ILL_SUBTYPE;
280 }
281 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
282 ret = WRONG_LEN_PACKET;
283 }
284 else {
285 ret = CCSDS_TM_VALID;
286 }
287 }
288 else {
289 ret = ILL_TYPE;
290 }
405 }
291
406
292 // source ID check // Source ID not documented in the ICD
407 int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length )
408 {
409 /** This function checks the CRC validity of the corresponding TeleCommand packet.
410 *
411 * @param TCPacket points to the TeleCommand packet to check.
412 * @param length is the length of the TC packet.
413 * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM.
414 *
415 */
293
416
294 // packet error control, CRC check
417 int status;
295 if ( ret == CCSDS_TM_VALID ) {
418 unsigned char * CCSDSContent;
419 unsigned char currentTC_COMPUTED_CRC[2];
420
296 CCSDSContent = (unsigned char*) TCPacket->packetID;
421 CCSDSContent = (unsigned char*) TCPacket->packetID;
297 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
422 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
298 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
423 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
299 ret = INCOR_CHECKSUM;
424 status = INCOR_CHECKSUM;
300 }
425 }
301 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
426 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
302 ret = INCOR_CHECKSUM;
427 status = INCOR_CHECKSUM;
303 }
428 }
304 else {
429 else {
305 ret = CCSDS_TM_VALID;
430 status = CCSDS_TM_VALID;
306 }
307 }
431 }
308
432
309 return ret;
433 return status;
310 }
434 }
311
435
312 //***********
436 //***********
313 // RTEMS TASK
437 // RTEMS TASK
314 rtems_task recv_task( rtems_task_argument unused )
438 rtems_task recv_task( rtems_task_argument unused )
315 {
439 {
440 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
441 *
442 * @param unused is the starting argument of the RTEMS task
443 *
444 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
445 * 1. It reads the incoming data.
446 * 2. Launches the acceptance procedure.
447 * 3. If the Telecommand is valid, sends it to the ACTN task using an RTEMS message queue.
448 *
449 */
450
316 int len = 0;
451 int len = 0;
317 unsigned int i = 0;
452 unsigned int i = 0;
318 ccsdsTelecommandPacket_t currentTC;
453 ccsdsTelecommandPacket_t currentTC;
@@ -323,6 +458,8 rtems_task recv_task( rtems_task_argumen
323
458
324 for(i=0; i<100; i++) data[i] = 0;
459 for(i=0; i<100; i++) data[i] = 0;
325
460
461 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
462
326 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_queu_id );
463 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_queu_id );
327 if (status != RTEMS_SUCCESSFUL)
464 if (status != RTEMS_SUCCESSFUL)
328 {
465 {
@@ -352,7 +489,7 rtems_task recv_task( rtems_task_argumen
352 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
489 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
353 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
490 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
354 // CHECK THE TC
491 // CHECK THE TC
355 TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt, queue_queu_id, queue_pkts_id);
492 tc_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt, queue_queu_id, queue_pkts_id);
356 }
493 }
357 }
494 }
358 }
495 }
@@ -360,6 +497,15 rtems_task recv_task( rtems_task_argumen
360
497
361 rtems_task actn_task( rtems_task_argument unused )
498 rtems_task actn_task( rtems_task_argument unused )
362 {
499 {
500 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
501 *
502 * @param unused is the starting argument of the RTEMS task
503 *
504 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
505 * on the incoming TeleCommand.
506 *
507 */
508
363 int result;
509 int result;
364 rtems_status_code status; // RTEMS status code
510 rtems_status_code status; // RTEMS status code
365 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
511 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
@@ -426,7 +572,7 rtems_task actn_task( rtems_task_argumen
426 break;
572 break;
427 //
573 //
428 case TC_SUBTYPE_DUMP:
574 case TC_SUBTYPE_DUMP:
429 result = action_dump_par( &TC );
575 result = action_dump_par( queue_snd_id );
430 close_action( &TC, result, queue_snd_id );
576 close_action( &TC, result, queue_snd_id );
431 break;
577 break;
432 //
578 //
@@ -464,6 +610,14 rtems_task actn_task( rtems_task_argumen
464
610
465 rtems_task dumb_task( rtems_task_argument unused )
611 rtems_task dumb_task( rtems_task_argument unused )
466 {
612 {
613 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
614 *
615 * @param unused is the starting argument of the RTEMS task
616 *
617 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
618 *
619 */
620
467 unsigned int i;
621 unsigned int i;
468 unsigned int intEventOut;
622 unsigned int intEventOut;
469 unsigned int coarse_time = 0;
623 unsigned int coarse_time = 0;
@@ -493,154 +647,26 rtems_task dumb_task( rtems_task_argumen
493
647
494 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
648 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
495 {
649 {
650 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
651 *
652 * @param TC points to the TeleCommand packet that is being processed
653 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
654 *
655 */
656
496 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
657 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
497 return LFR_DEFAULT;
658 return LFR_DEFAULT;
498 }
659 }
499
660
500 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
501 {
502 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
503 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
504
505 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
506
507 return LFR_SUCCESSFUL;
508 }
509
510 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
511 {
512 int result;
513 unsigned int tmp;
514
515 result = LFR_SUCCESSFUL;
516
517 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
518 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
519 result = LFR_DEFAULT;
520 }
521 else {
522 // sy_lfr_n_swf_l
523 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0];
524 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1];
525
526 // sy_lfr_n_swf_p
527 tmp = ( unsigned int ) floor(
528 (TC->dataAndCRC[2] * 256
529 + TC->dataAndCRC[3])/8
530 ) * 8;
531 if ( (tmp < 16) || (tmp>65528) )
532 {
533 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, 12, TC->dataAndCRC[2]);
534 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, 13, TC->dataAndCRC[3]);
535 result = LFR_DEFAULT;
536 }
537 else
538 {
539 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
540 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
541 }
542
543 // sy_lfr_n_asm_p
544 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4];
545 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5];
546
547 // sy_lfr_n_bp_p0
548 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
549
550 // sy_lfr_n_bp_p1
551 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
552 }
553
554 return result;
555 }
556
557 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
558 {
559 int result;
560 unsigned char lfrMode;
561
562 result = LFR_DEFAULT;
563 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
564
565 if ( lfrMode == LFR_MODE_BURST ) {
566 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
567 result = LFR_DEFAULT;
568 }
569 else {
570 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
571 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
572
573 result = LFR_SUCCESSFUL;
574 }
575
576 return result;
577 }
578
579 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
580 {
581 int result;
582 unsigned char lfrMode;
583
584 result = LFR_DEFAULT;
585 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
586
587 if ( lfrMode == LFR_MODE_SBM1 ) {
588 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
589 result = LFR_DEFAULT;
590 }
591 else {
592 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
593 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
594
595 result = LFR_SUCCESSFUL;
596 }
597
598 return result;
599 }
600
601 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
602 {
603 int result;
604 unsigned char lfrMode;
605
606 result = LFR_DEFAULT;
607 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
608
609 if ( lfrMode == LFR_MODE_SBM2 ) {
610 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
611 result = LFR_DEFAULT;
612 }
613 else {
614 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
615 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
616
617 result = LFR_SUCCESSFUL;
618 }
619
620 return result;
621 }
622
623 int action_dump_par(ccsdsTelecommandPacket_t *TC)
624 {
625 int status;
626 // send parameter dump packet
627 status = write(fdSPW, (char *) &parameter_dump_packet,
628 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + 4);
629 if (status == -1)
630 {
631 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
632 status = RTEMS_UNSATISFIED;
633 }
634 else
635 {
636 status = RTEMS_SUCCESSFUL;
637 }
638
639 return status;
640 }
641
642 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
661 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
643 {
662 {
663 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
664 *
665 * @param TC points to the TeleCommand packet that is being processed
666 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
667 *
668 */
669
644 rtems_status_code status;
670 rtems_status_code status;
645 unsigned char requestedMode;
671 unsigned char requestedMode;
646
672
@@ -688,7 +714,15 int action_enter_mode(ccsdsTelecommandPa
688 return status;
714 return status;
689 }
715 }
690
716
691 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) {
717 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
718 {
719 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
720 *
721 * @param TC points to the TeleCommand packet that is being processed
722 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
723 *
724 */
725
692 unsigned int val;
726 unsigned int val;
693 int result;
727 int result;
694 unsigned char lfrMode;
728 unsigned char lfrMode;
@@ -714,6 +748,13 int action_update_info(ccsdsTelecommandP
714
748
715 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
749 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
716 {
750 {
751 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
752 *
753 * @param TC points to the TeleCommand packet that is being processed
754 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
755 *
756 */
757
717 int result;
758 int result;
718 unsigned char lfrMode;
759 unsigned char lfrMode;
719
760
@@ -733,6 +774,13 int action_enable_calibration(ccsdsTelec
733
774
734 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
775 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
735 {
776 {
777 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
778 *
779 * @param TC points to the TeleCommand packet that is being processed
780 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
781 *
782 */
783
736 int result;
784 int result;
737 unsigned char lfrMode;
785 unsigned char lfrMode;
738
786
@@ -752,6 +800,13 int action_disable_calibration(ccsdsTele
752
800
753 int action_update_time(ccsdsTelecommandPacket_t *TC)
801 int action_update_time(ccsdsTelecommandPacket_t *TC)
754 {
802 {
803 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
804 *
805 * @param TC points to the TeleCommand packet that is being processed
806 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
807 *
808 */
809
755 unsigned int val;
810 unsigned int val;
756
811
757 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
812 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
@@ -828,6 +883,15 int transition_validation(unsigned char
828
883
829 int stop_current_mode()
884 int stop_current_mode()
830 {
885 {
886 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
887 *
888 * @return RTEMS directive status codes:
889 * - RTEMS_SUCCESSFUL - task restarted successfully
890 * - RTEMS_INVALID_ID - task id invalid
891 * - RTEMS_ALREADY_SUSPENDED - task already suspended
892 *
893 */
894
831 rtems_status_code status;
895 rtems_status_code status;
832
896
833 status = RTEMS_SUCCESSFUL;
897 status = RTEMS_SUCCESSFUL;
@@ -851,12 +915,12 int stop_current_mode()
851 //**********************
915 //**********************
852 // suspend several tasks
916 // suspend several tasks
853 if (lfrCurrentMode != LFR_MODE_STANDBY) {
917 if (lfrCurrentMode != LFR_MODE_STANDBY) {
854 suspend_science_tasks();
918 status = suspend_science_tasks();
855 }
919 }
856
920
857 if (status != RTEMS_SUCCESSFUL)
921 if (status != RTEMS_SUCCESSFUL)
858 {
922 {
859 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
923 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
860 }
924 }
861
925
862 //*************************
926 //*************************
@@ -1079,325 +1143,69 int restart_science_tasks()
1079
1143
1080 int suspend_science_tasks()
1144 int suspend_science_tasks()
1081 {
1145 {
1082 rtems_status_code status[6];
1146 /** This function suspends the science tasks.
1083 rtems_status_code ret;
1147 *
1084
1148 * @return RTEMS directive status codes:
1085 ret = RTEMS_SUCCESSFUL;
1149 * - RTEMS_SUCCESSFUL - task restarted successfully
1150 * - RTEMS_INVALID_ID - task id invalid
1151 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1152 *
1153 */
1086
1154
1087 status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] );
1155 rtems_status_code status;
1088 if (status[0] != RTEMS_SUCCESSFUL)
1089 {
1090 PRINTF1("in suspend_science_task *** 0 ERR %d\n", status[0])
1091 }
1092
1156
1093 status[1] = rtems_task_suspend( Task_id[TASKID_BPF0] );
1157 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
1094 if (status[1] != RTEMS_SUCCESSFUL)
1158 if (status != RTEMS_SUCCESSFUL)
1095 {
1159 {
1096 PRINTF1("in suspend_science_task *** 1 ERR %d\n", status[1])
1160 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1097 }
1161 }
1098
1162 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
1099 status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] );
1163 {
1100 if (status[2] != RTEMS_SUCCESSFUL)
1164 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
1165 if (status != RTEMS_SUCCESSFUL)
1101 {
1166 {
1102 PRINTF1("in suspend_science_task *** 2 ERR %d\n", status[2])
1167 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
1168 }
1169 }
1170 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1171 {
1172 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1173 if (status != RTEMS_SUCCESSFUL)
1174 {
1175 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1176 }
1103 }
1177 }
1104
1178
1105 status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] );
1179 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1106 if (status[3] != RTEMS_SUCCESSFUL)
1107 {
1180 {
1108 PRINTF1("in suspend_science_task *** 3 ERR %d\n", status[3])
1181 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1182 if (status != RTEMS_SUCCESSFUL)
1183 {
1184 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1185 }
1109 }
1186 }
1110
1187 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1111 status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] );
1188 {
1112 if (status[4] != RTEMS_SUCCESSFUL)
1189 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1190 if (status != RTEMS_SUCCESSFUL)
1113 {
1191 {
1114 PRINTF1("in suspend_science_task *** 4 ERR %d\n", status[4])
1192 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1193 }
1194 }
1195 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1196 {
1197 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1198 if (status != RTEMS_SUCCESSFUL)
1199 {
1200 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1201 }
1115 }
1202 }
1116
1203
1117 status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] );
1204 return status;
1118 if (status[5] != RTEMS_SUCCESSFUL)
1119 {
1120 PRINTF1("in suspend_science_task *** 5 ERR %d\n", status[5])
1121 }
1122
1123 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1124 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1125 {
1126 ret = RTEMS_UNSATISFIED;
1127 }
1128
1129 return ret;
1130 }
1205 }
1131
1206
1132 //****************
1207 //****************
1133 // CLOSING ACTIONS
1208 // CLOSING ACTIONS
1134
1135 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1136 {
1137 int ret;
1138 rtems_status_code status;
1139 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
1140 unsigned char messageSize;
1141
1142 ret = LFR_SUCCESSFUL;
1143
1144 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1145 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1146 TM.reserved = DEFAULT_RESERVED;
1147 TM.userApplication = CCSDS_USER_APP;
1148 // PACKET HEADER
1149 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1150 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1151 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1152 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1153 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
1154 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
1155 // DATA FIELD HEADER
1156 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1157 TM.serviceType = TM_TYPE_TC_EXE;
1158 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
1159 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1160 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1161 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1162 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1163 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1164 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1165 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1166 //
1167 TM.telecommand_pkt_id[0] = TC->packetID[0];
1168 TM.telecommand_pkt_id[1] = TC->packetID[1];
1169 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1170 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1171
1172 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1173
1174 // SEND DATA
1175 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1176 if (status != RTEMS_SUCCESSFUL) {
1177 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1178 ret = LFR_DEFAULT;
1179 }
1180
1181 return LFR_SUCCESSFUL;
1182 }
1183
1184 int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
1185 unsigned char byte_position, unsigned char rcv_value)
1186 {
1187 int ret;
1188 rtems_status_code status;
1189 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
1190 unsigned char messageSize;
1191
1192 ret = LFR_SUCCESSFUL;
1193
1194 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1195 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1196 TM.reserved = DEFAULT_RESERVED;
1197 TM.userApplication = CCSDS_USER_APP;
1198 // PACKET HEADER
1199 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1200 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1201 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1202 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1203 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
1204 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
1205 // DATA FIELD HEADER
1206 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1207 TM.serviceType = TM_TYPE_TC_EXE;
1208 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1209 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1210 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1211 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1212 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1213 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1214 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1215 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1216 //
1217 TM.tc_failure_code[0] = (char) (FAILURE_CODE_INCONSISTENT >> 8);
1218 TM.tc_failure_code[1] = (char) (FAILURE_CODE_INCONSISTENT );
1219 TM.telecommand_pkt_id[0] = TC->packetID[0];
1220 TM.telecommand_pkt_id[1] = TC->packetID[1];
1221 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1222 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1223 TM.tc_service = TC->serviceType; // type of the rejected TC
1224 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1225 TM.byte_position = byte_position;
1226 TM.rcv_value = rcv_value;
1227
1228 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1229
1230 // SEND DATA
1231 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1232 if (status != RTEMS_SUCCESSFUL) {
1233 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
1234 ret = LFR_DEFAULT;
1235 }
1236
1237 return LFR_SUCCESSFUL;
1238 }
1239
1240 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1241 {
1242 int ret;
1243 rtems_status_code status;
1244 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
1245 unsigned char messageSize;
1246
1247 ret = LFR_SUCCESSFUL;
1248
1249 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1250 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1251 TM.reserved = DEFAULT_RESERVED;
1252 TM.userApplication = CCSDS_USER_APP;
1253 // PACKET HEADER
1254 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1255 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1256 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1257 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1258 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
1259 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
1260 // DATA FIELD HEADER
1261 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1262 TM.serviceType = TM_TYPE_TC_EXE;
1263 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1264 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1265 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1266 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1267 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1268 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1269 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1270 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1271 //
1272 TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1273 TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_EXECUTABLE );
1274 TM.telecommand_pkt_id[0] = TC->packetID[0];
1275 TM.telecommand_pkt_id[1] = TC->packetID[1];
1276 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1277 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1278 TM.tc_service = TC->serviceType; // type of the rejected TC
1279 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1280 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
1281 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
1282
1283 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1284
1285 // SEND DATA
1286 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1287 if (status != RTEMS_SUCCESSFUL) {
1288 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
1289 ret = LFR_DEFAULT;
1290 }
1291
1292 return LFR_SUCCESSFUL;
1293 }
1294
1295 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1296 {
1297 int ret;
1298 rtems_status_code status;
1299 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
1300 unsigned char messageSize;
1301
1302 ret = LFR_SUCCESSFUL;
1303
1304 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1305 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1306 TM.reserved = DEFAULT_RESERVED;
1307 TM.userApplication = CCSDS_USER_APP;
1308 // PACKET HEADER
1309 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1310 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1311 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1312 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1313 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
1314 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
1315 // DATA FIELD HEADER
1316 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1317 TM.serviceType = TM_TYPE_TC_EXE;
1318 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1319 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1320 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1321 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1322 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1323 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1324 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1325 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1326 //
1327 TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1328 TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_IMPLEMENTED );
1329 TM.telecommand_pkt_id[0] = TC->packetID[0];
1330 TM.telecommand_pkt_id[1] = TC->packetID[1];
1331 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1332 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1333 TM.tc_service = TC->serviceType; // type of the rejected TC
1334 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1335
1336 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1337
1338 // SEND DATA
1339 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1340 if (status != RTEMS_SUCCESSFUL) {
1341 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1342 ret = LFR_DEFAULT;
1343 }
1344
1345 return LFR_SUCCESSFUL;
1346 }
1347
1348 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1349 {
1350 int ret;
1351 rtems_status_code status;
1352 Packet_TM_LFR_TC_EXE_ERROR_t TM;
1353 unsigned char messageSize;
1354
1355 ret = LFR_SUCCESSFUL;
1356
1357 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
1358 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1359 TM.reserved = DEFAULT_RESERVED;
1360 TM.userApplication = CCSDS_USER_APP;
1361 // PACKET HEADER
1362 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
1363 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
1364 TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8);
1365 TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE );
1366 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
1367 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
1368 // DATA FIELD HEADER
1369 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1370 TM.serviceType = TM_TYPE_TC_EXE;
1371 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
1372 TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id
1373 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1374 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1375 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1376 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
1377 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1378 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
1379 //
1380 TM.tc_failure_code[0] = (char) (FAILURE_CODE_ERROR >> 8);
1381 TM.tc_failure_code[1] = (char) (FAILURE_CODE_ERROR );
1382 TM.telecommand_pkt_id[0] = TC->packetID[0];
1383 TM.telecommand_pkt_id[1] = TC->packetID[1];
1384 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
1385 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
1386 TM.tc_service = TC->serviceType; // type of the rejected TC
1387 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
1388
1389 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1390
1391 // SEND DATA
1392 status = rtems_message_queue_urgent( queue_id, &TM, messageSize);
1393 if (status != RTEMS_SUCCESSFUL) {
1394 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1395 ret = LFR_DEFAULT;
1396 }
1397
1398 return LFR_SUCCESSFUL;
1399 }
1400
1401 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
1209 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
1402 {
1210 {
1403 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1211 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
@@ -1,4 +1,13
1 #include <wf_handler.h>
1 /** Functions and tasks related to waveform packet generation.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
8 */
9
10 #include "wf_handler.h"
2
11
3 // SWF
12 // SWF
4 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
@@ -642,6 +651,18 void reset_waveforms( void )
642 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
651 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
643 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
652 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
644 {
653 {
654 /** This function sends SWF CCSDS packets (F2, F1 or F0).
655 *
656 * @param waveform points to the buffer containing the data that will be send.
657 * @param sid is the source identifier of the data that will be sent.
658 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
659 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
660 * contain information to setup the transmission of the data packets.
661 *
662 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
663 *
664 */
665
645 unsigned int i;
666 unsigned int i;
646 int ret;
667 int ret;
647 rtems_status_code status;
668 rtems_status_code status;
@@ -691,6 +712,18 int send_waveform_SWF( volatile int *wav
691 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
712 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
692 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
713 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
693 {
714 {
715 /** This function sends CWF CCSDS packets (F2, F1 or F0).
716 *
717 * @param waveform points to the buffer containing the data that will be send.
718 * @param sid is the source identifier of the data that will be sent.
719 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
720 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
721 * contain information to setup the transmission of the data packets.
722 *
723 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
724 *
725 */
726
694 unsigned int i;
727 unsigned int i;
695 int ret;
728 int ret;
696 rtems_status_code status;
729 rtems_status_code status;
@@ -754,6 +787,18 int send_waveform_CWF(volatile int *wave
754
787
755 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
788 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
756 {
789 {
790 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
791 *
792 * @param waveform points to the buffer containing the data that will be send.
793 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
794 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
795 * contain information to setup the transmission of the data packets.
796 *
797 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
798 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
799 *
800 */
801
757 unsigned int i;
802 unsigned int i;
758 int ret;
803 int ret;
759 rtems_status_code status;
804 rtems_status_code status;
@@ -826,6 +871,13 int send_waveform_CWF3_light(volatile in
826 // wfp registers
871 // wfp registers
827 void set_wfp_data_shaping()
872 void set_wfp_data_shaping()
828 {
873 {
874 /** This function sets the data_shaping register of the waveform picker module.
875 *
876 * The value is read from one field of the parameter_dump_packet structure:\n
877 * bw_sp0_sp1_r0_r1
878 *
879 */
880
829 unsigned char data_shaping;
881 unsigned char data_shaping;
830
882
831 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
883 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
@@ -846,6 +898,14 void set_wfp_data_shaping()
846
898
847 char set_wfp_delta_snapshot()
899 char set_wfp_delta_snapshot()
848 {
900 {
901 /** This function sets the delta_snapshot register of the waveform picker module.
902 *
903 * The value is read from two (unsigned char) of the parameter_dump_packet structure:\n
904 * sy_lfr_n_swf_p[0] \n
905 * sy_lfr_n_swf_p[1]
906 *
907 */
908
849 char ret;
909 char ret;
850 unsigned int delta_snapshot;
910 unsigned int delta_snapshot;
851 unsigned int aux;
911 unsigned int aux;
@@ -876,6 +936,14 char set_wfp_delta_snapshot()
876
936
877 void set_wfp_burst_enable_register( unsigned char mode)
937 void set_wfp_burst_enable_register( unsigned char mode)
878 {
938 {
939 /** This function sets the waveform picker burst_enable register depending on the mode.
940 *
941 * @param mode is the LFR mode to launch.
942 *
943 * The burst bits shall be before the enable bits.
944 *
945 */
946
879 #ifdef GSA
947 #ifdef GSA
880 #else
948 #else
881 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
949 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
@@ -906,6 +974,12 void set_wfp_burst_enable_register( unsi
906
974
907 void reset_wfp_burst_enable()
975 void reset_wfp_burst_enable()
908 {
976 {
977 /** This function resets the waveform picker burst_enable register.
978 *
979 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
980 *
981 */
982
909 #ifdef GSA
983 #ifdef GSA
910 #else
984 #else
911 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
985 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
@@ -914,6 +988,12 void reset_wfp_burst_enable()
914
988
915 void reset_wfp_status()
989 void reset_wfp_status()
916 {
990 {
991 /** This function resets the waveform picker status register.
992 *
993 * All status bits are set to 0 [new_err full_err full].
994 *
995 */
996
917 #ifdef GSA
997 #ifdef GSA
918 #else
998 #else
919 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
999 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
@@ -922,6 +1002,24 void reset_wfp_status()
922
1002
923 void reset_waveform_picker_regs()
1003 void reset_waveform_picker_regs()
924 {
1004 {
1005 /** This function resets the waveform picker module registers.
1006 *
1007 * The registers affected by this function are located at the following offset addresses:
1008 * - 0x00 data_shaping
1009 * - 0x04 burst_enable
1010 * - 0x08 addr_data_f0
1011 * - 0x0C addr_data_f1
1012 * - 0x10 addr_data_f2
1013 * - 0x14 addr_data_f3
1014 * - 0x18 status
1015 * - 0x1C delta_snapshot
1016 * - 0x20 delta_f2_f1
1017 * - 0x24 delta_f2_f0
1018 * - 0x28 nb_burst
1019 * - 0x2C nb_snapshot
1020 *
1021 */
1022
925 #ifdef GSA
1023 #ifdef GSA
926 #else
1024 #else
927 set_wfp_data_shaping();
1025 set_wfp_data_shaping();
@@ -943,7 +1041,13 void reset_waveform_picker_regs()
943 // local parameters
1041 // local parameters
944 void set_local_sbm1_nb_cwf_max()
1042 void set_local_sbm1_nb_cwf_max()
945 {
1043 {
946 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1044 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1045 *
1046 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1047 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1048 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1049 *
1050 */
947 param_local.local_sbm1_nb_cwf_max = 2 *
1051 param_local.local_sbm1_nb_cwf_max = 2 *
948 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1052 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
949 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1053 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
@@ -951,23 +1055,52 void set_local_sbm1_nb_cwf_max()
951
1055
952 void set_local_sbm2_nb_cwf_max()
1056 void set_local_sbm2_nb_cwf_max()
953 {
1057 {
954 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1058 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1059 *
1060 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1061 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1062 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1063 *
1064 */
1065
955 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1066 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
956 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1067 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
957 }
1068 }
958
1069
959 void set_local_nb_interrupt_f0_MAX()
1070 void set_local_nb_interrupt_f0_MAX()
960 {
1071 {
1072 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1073 *
1074 * This parameter is used for the SM validation only.\n
1075 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1076 * module before launching a basic processing.
1077 *
1078 */
1079
961 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1080 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
962 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1081 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
963 }
1082 }
964
1083
965 void reset_local_sbm1_nb_cwf_sent()
1084 void reset_local_sbm1_nb_cwf_sent()
966 {
1085 {
1086 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1087 *
1088 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1089 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1090 *
1091 */
1092
967 param_local.local_sbm1_nb_cwf_sent = 0;
1093 param_local.local_sbm1_nb_cwf_sent = 0;
968 }
1094 }
969
1095
970 void reset_local_sbm2_nb_cwf_sent()
1096 void reset_local_sbm2_nb_cwf_sent()
971 {
1097 {
1098 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1099 *
1100 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1101 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1102 *
1103 */
1104
972 param_local.local_sbm2_nb_cwf_sent = 0;
1105 param_local.local_sbm2_nb_cwf_sent = 0;
973 }
1106 }
General Comments 0
You need to be logged in to leave comments. Login now