##// END OF EJS Templates
Bug 167...
paul -
r152:de079a204567 VHDLib206
parent child
Show More
@@ -1,273 +1,273
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Jun 17 07:27:34 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Jun 17 09:36:20 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=10 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/processing/fsw_processing.c \
56 56 ../src/processing/avf0_prc0.c \
57 57 ../src/processing/avf1_prc1.c \
58 58 ../src/processing/avf2_prc2.c \
59 59 ../src/lfr_cpu_usage_report.c \
60 60 ../src/LFR_basic-parameters/basic_parameters.c
61 61 OBJECTS = obj/wf_handler.o \
62 62 obj/tc_handler.o \
63 63 obj/fsw_misc.o \
64 64 obj/fsw_init.o \
65 65 obj/fsw_globals.o \
66 66 obj/fsw_spacewire.o \
67 67 obj/tc_load_dump_parameters.o \
68 68 obj/tm_lfr_tc_exe.o \
69 69 obj/tc_acceptance.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o \
74 74 obj/lfr_cpu_usage_report.o \
75 75 obj/basic_parameters.o
76 76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 88 sparc.pri \
89 89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 99 fsw-qt.pro
100 100 QMAKE_TARGET = fsw
101 101 DESTDIR = bin/
102 102 TARGET = bin/fsw
103 103
104 104 first: all
105 105 ####### Implicit rules
106 106
107 107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108 108
109 109 .cpp.o:
110 110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 111
112 112 .cc.o:
113 113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 114
115 115 .cxx.o:
116 116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 117
118 118 .C.o:
119 119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120 120
121 121 .c.o:
122 122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123 123
124 124 ####### Build rules
125 125
126 126 all: Makefile $(TARGET)
127 127
128 128 $(TARGET): $(OBJECTS)
129 129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131 131
132 132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 144 sparc.pri \
145 145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 168 sparc.pri:
169 169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 179 qmake: FORCE
180 180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181 181
182 182 dist:
183 183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185 185
186 186
187 187 clean:compiler_clean
188 188 -$(DEL_FILE) $(OBJECTS)
189 189 -$(DEL_FILE) *~ core *.core
190 190
191 191
192 192 ####### Sub-libraries
193 193
194 194 distclean: clean
195 195 -$(DEL_FILE) $(TARGET)
196 196 -$(DEL_FILE) Makefile
197 197
198 198
199 199 grmon:
200 200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201 201
202 202 check: first
203 203
204 204 compiler_rcc_make_all:
205 205 compiler_rcc_clean:
206 206 compiler_uic_make_all:
207 207 compiler_uic_clean:
208 208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 209 compiler_image_collection_clean:
210 210 -$(DEL_FILE) qmake_image_collection.cpp
211 211 compiler_yacc_decl_make_all:
212 212 compiler_yacc_decl_clean:
213 213 compiler_yacc_impl_make_all:
214 214 compiler_yacc_impl_clean:
215 215 compiler_lex_make_all:
216 216 compiler_lex_clean:
217 217 compiler_clean:
218 218
219 219 ####### Compile
220 220
221 221 obj/wf_handler.o: ../src/wf_handler.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223 223
224 224 obj/tc_handler.o: ../src/tc_handler.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226 226
227 227 obj/fsw_misc.o: ../src/fsw_misc.c
228 228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229 229
230 230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232 232
233 233 obj/fsw_globals.o: ../src/fsw_globals.c
234 234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235 235
236 236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238 238
239 239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241 241
242 242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244 244
245 245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247 247
248 248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250 250
251 251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253 253
254 254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256 256
257 257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259 259
260 260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262 262
263 263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265 265
266 266 ####### Install
267 267
268 268 install: FORCE
269 269
270 270 uninstall: FORCE
271 271
272 272 FORCE:
273 273
@@ -1,48 +1,49
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 12 extern unsigned short sequenceCounterParameterDump;
13 13
14 14 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
15 15 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
16 16 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 17 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
18 18 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
19 19 int action_dump_par(rtems_id queue_id );
20 20
21 21 // NORMAL
22 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
23 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
24 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
25 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
26 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
27 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
22 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
23 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
24 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
25 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
26 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
27 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
28 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
28 29
29 30 // BURST
30 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
31 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
31 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
32 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
32 33
33 34 // SBM1
34 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
36 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
36 37
37 38 // SBM2
38 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
39 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
39 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
40 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
40 41
41 42 // TC_LFR_UPDATE_INFO
42 43 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
43 44 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
44 45 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
45 46
46 47 void init_parameter_dump( void );
47 48
48 49 #endif // TC_LOAD_DUMP_PARAMETERS_H
This diff has been collapsed as it changes many lines, (544 lines changed) Show them Hide them
@@ -1,881 +1,775
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping( );
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43 rtems_status_code status;
44 unsigned char sy_lfr_n_bp_p0;
45 unsigned char sy_lfr_n_bp_p1;
46 unsigned int sy_lfr_n_asm_p;
47 float aux;
48 44
49 45 flag = LFR_SUCCESSFUL;
50 46
51 47 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 48 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 49 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 50 flag = LFR_DEFAULT;
55 51 }
56 52
57 //***************
58 // sy_lfr_n_swf_l
59 if (flag == LFR_SUCCESSFUL)
60 {
61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
62 if (result != LFR_SUCCESSFUL)
63 {
64 flag = LFR_DEFAULT;
65 }
66 }
67
68 //***************
69 // sy_lfr_n_swf_p
70 if (flag == LFR_SUCCESSFUL)
71 {
72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
73 if (result != LFR_SUCCESSFUL)
74 {
75 flag = LFR_DEFAULT;
76 }
77 }
78
79 //****************************************************************
80 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
81 if (flag == LFR_SUCCESSFUL)
82 {
83 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
84 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
85 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
86 if (aux != 0)
87 {
88 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
89 flag = LFR_DEFAULT;
90 }
91 }
92
93 //***************
94 // sy_lfr_n_bp_p0
95 if (flag == LFR_SUCCESSFUL)
96 {
97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
98 if (result != LFR_SUCCESSFUL)
99 {
100 flag = LFR_DEFAULT;
101 }
102 }
103
104 //****************************************************************
105 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
53 // CHECK THE PARAMETERS SET CONSISTENCY
106 54 if (flag == LFR_SUCCESSFUL)
107 55 {
108 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
109 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
110 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
111 if (aux != 0)
112 {
113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
114 flag = LFR_DEFAULT;
115 }
56 flag = check_common_par_consistency( TC, queue_id );
116 57 }
117 58
118 //***************
119 // sy_lfr_n_bp_p1
120 if (flag == LFR_SUCCESSFUL)
121 {
122 result = set_sy_lfr_n_bp_p1( TC, queue_id );
123 if (result != LFR_SUCCESSFUL)
124 {
125 flag = LFR_DEFAULT;
126 }
127 }
128
129 //****************************************************************
130 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
59 // SET THE PARAMETERS IF THEY ARE CONSISTENT
131 60 if (flag == LFR_SUCCESSFUL)
132 61 {
133 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
134 sy_lfr_n_asm_p =
135 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
136 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
137 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
138 if (aux != 0)
139 {
140 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
141 flag = LFR_DEFAULT;
142 }
143 }
144
145 //***************
146 // sy_lfr_n_asm_p
147 if (flag == LFR_SUCCESSFUL)
148 {
149 result = set_sy_lfr_n_asm_p( TC, queue_id );
150 if (result != LFR_SUCCESSFUL)
151 {
152 flag = LFR_DEFAULT;
153 }
154 }
155
156 //*********************
157 // sy_lfr_n_cwf_long_f3
158 if (flag == LFR_SUCCESSFUL)
159 {
160 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
161 if (result != LFR_SUCCESSFUL)
162 {
163 flag = LFR_DEFAULT;
164 }
62 result = set_sy_lfr_n_swf_l( TC );
63 result = set_sy_lfr_n_swf_p( TC );
64 result = set_sy_lfr_n_bp_p0( TC );
65 result = set_sy_lfr_n_bp_p1( TC );
66 result = set_sy_lfr_n_asm_p( TC );
67 result = set_sy_lfr_n_cwf_long_f3( TC );
165 68 }
166 69
167 70 return flag;
168 71 }
169 72
170 73 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
171 74 {
172 75 /** This function updates the LFR registers with the incoming burst parameters.
173 76 *
174 77 * @param TC points to the TeleCommand packet that is being processed
175 78 * @param queue_id is the id of the queue which handles TM related to this execution step
176 79 *
177 80 */
178 81
179 82 int result;
180 83 int flag;
181 84 rtems_status_code status;
182 85 unsigned char sy_lfr_b_bp_p0;
183 86 unsigned char sy_lfr_b_bp_p1;
184 87 float aux;
185 88
186 89 flag = LFR_SUCCESSFUL;
187 90
188 91 if ( lfrCurrentMode == LFR_MODE_BURST ) {
189 92 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 93 result = LFR_DEFAULT;
191 94 }
192 95
96 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
97 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
98
99 // sy_lfr_b_bp_p0
100 if (flag == LFR_SUCCESSFUL)
101 {
102 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
103 {
104 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
105 flag = WRONG_APP_DATA;
106 }
107 }
108 // sy_lfr_b_bp_p1
109 if (flag == LFR_SUCCESSFUL)
110 {
111 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
112 {
113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
114 flag = WRONG_APP_DATA;
115 }
116 }
193 117 //****************************************************************
194 118 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
195 119 if (flag == LFR_SUCCESSFUL)
196 120 {
197 121 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
198 122 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
199 123 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
200 124 if (aux != 0)
201 125 {
202 126 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
203 127 flag = LFR_DEFAULT;
204 128 }
205 129 }
206 130
207 //***************
208 // sy_lfr_b_bp_p0
131 // SET HTE PARAMETERS
209 132 if (flag == LFR_SUCCESSFUL)
210 133 {
211 result = set_sy_lfr_b_bp_p0( TC, queue_id );
212 if (result != LFR_SUCCESSFUL)
213 {
214 flag = LFR_DEFAULT;
215 }
216 }
217
218 //***************
219 // sy_lfr_b_bp_p1
220 if (flag == LFR_SUCCESSFUL)
221 {
222 result = set_sy_lfr_b_bp_p1( TC, queue_id );
223 if (result != LFR_SUCCESSFUL)
224 {
225 flag = LFR_DEFAULT;
226 }
134 result = set_sy_lfr_b_bp_p0( TC );
135 result = set_sy_lfr_b_bp_p1( TC );
227 136 }
228 137
229 138 return flag;
230 139 }
231 140
232 141 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
233 142 {
234 143 /** This function updates the LFR registers with the incoming sbm1 parameters.
235 144 *
236 145 * @param TC points to the TeleCommand packet that is being processed
237 146 * @param queue_id is the id of the queue which handles TM related to this execution step
238 147 *
239 148 */
240 149
241 150 int result;
242 151 int flag;
243 152 rtems_status_code status;
244 153 unsigned char sy_lfr_s1_bp_p0;
245 154 unsigned char sy_lfr_s1_bp_p1;
246 155 float aux;
247 156
248 157 flag = LFR_SUCCESSFUL;
249 158
250 159 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
251 160 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
252 161 result = LFR_DEFAULT;
253 162 }
254 163
164 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
165 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
166
167 // sy_lfr_s1_bp_p0
168 if (flag == LFR_SUCCESSFUL)
169 {
170 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
171 {
172 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
173 flag = WRONG_APP_DATA;
174 }
175 }
176 // sy_lfr_s1_bp_p1
177 if (flag == LFR_SUCCESSFUL)
178 {
179 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
180 {
181 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
182 flag = WRONG_APP_DATA;
183 }
184 }
255 185 //******************************************************************
256 186 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
257 187 if (flag == LFR_SUCCESSFUL)
258 188 {
259 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
260 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
261 189 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
262 190 if (aux != 0)
263 191 {
264 192 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
265 193 flag = LFR_DEFAULT;
266 194 }
267 195 }
268 196
269 //***************
270 // sy_lfr_s1_bp_p0
197 // SET THE PARAMETERS
271 198 if (flag == LFR_SUCCESSFUL)
272 199 {
273 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
274 if (result != LFR_SUCCESSFUL)
275 {
276 flag = LFR_DEFAULT;
277 }
278 }
279
280 //***************
281 // sy_lfr_s1_bp_p1
282 if (flag == LFR_SUCCESSFUL)
283 {
284 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
285 if (result != LFR_SUCCESSFUL)
286 {
287 flag = LFR_DEFAULT;
288 }
200 result = set_sy_lfr_s1_bp_p0( TC );
201 result = set_sy_lfr_s1_bp_p1( TC );
289 202 }
290 203
291 204 return flag;
292 205 }
293 206
294 207 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 208 {
296 209 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 210 *
298 211 * @param TC points to the TeleCommand packet that is being processed
299 212 * @param queue_id is the id of the queue which handles TM related to this execution step
300 213 *
301 214 */
302 215
303 216 int result;
304 217 int flag;
305 218 rtems_status_code status;
306 219 unsigned char sy_lfr_s2_bp_p0;
307 220 unsigned char sy_lfr_s2_bp_p1;
308 221 float aux;
309 222
310 223 flag = LFR_SUCCESSFUL;
311 224
312 225 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
313 226 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
314 227 result = LFR_DEFAULT;
315 228 }
316 229
230 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
231 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
232
233 // sy_lfr_s2_bp_p0
234 if (flag == LFR_SUCCESSFUL)
235 {
236 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
237 {
238 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
239 flag = WRONG_APP_DATA;
240 }
241 }
242 // sy_lfr_s2_bp_p1
243 if (flag == LFR_SUCCESSFUL)
244 {
245 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
246 {
247 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
248 flag = WRONG_APP_DATA;
249 }
250 }
317 251 //******************************************************************
318 252 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
319 253 if (flag == LFR_SUCCESSFUL)
320 254 {
321 255 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
322 256 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
323 257 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
324 258 if (aux != 0)
325 259 {
326 260 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
327 261 flag = LFR_DEFAULT;
328 262 }
329 263 }
330 264
331 //***************
332 // sy_lfr_s2_bp_p0
265 // SET THE PARAMETERS
333 266 if (flag == LFR_SUCCESSFUL)
334 267 {
335 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
336 if (result != LFR_SUCCESSFUL)
337 {
338 flag = LFR_DEFAULT;
339 }
340 }
341
342 //***************
343 // sy_lfr_s2_bp_p1
344 if (flag == LFR_SUCCESSFUL)
345 {
346 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
347 if (result != LFR_SUCCESSFUL)
348 {
349 flag = LFR_DEFAULT;
350 }
268 result = set_sy_lfr_s2_bp_p0( TC );
269 result = set_sy_lfr_s2_bp_p1( TC );
351 270 }
352 271
353 272 return flag;
354 273 }
355 274
356 275 int action_dump_par( rtems_id queue_id )
357 276 {
358 277 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
359 278 *
360 279 * @param queue_id is the id of the queue which handles TM related to this execution step.
361 280 *
362 281 * @return RTEMS directive status codes:
363 282 * - RTEMS_SUCCESSFUL - message sent successfully
364 283 * - RTEMS_INVALID_ID - invalid queue id
365 284 * - RTEMS_INVALID_SIZE - invalid message size
366 285 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 286 * - RTEMS_UNSATISFIED - out of message buffers
368 287 * - RTEMS_TOO_MANY - queue s limit has been reached
369 288 *
370 289 */
371 290
372 291 int status;
373 292
374 293 // UPDATE TIME
375 294 parameter_dump_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterParameterDump >> 8;
376 295 parameter_dump_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterParameterDump;
377 296 increment_seq_counter( &sequenceCounterParameterDump );
378 297
379 298 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
380 299 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
381 300 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
382 301 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
383 302 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
384 303 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
385 304 // SEND DATA
386 305 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
387 306 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
388 307 if (status != RTEMS_SUCCESSFUL) {
389 308 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
390 309 }
391 310
392 311 return status;
393 312 }
394 313
395 314 //***********************
396 315 // NORMAL MODE PARAMETERS
397 316
398 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
317 int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
318 {
319 unsigned char msb;
320 unsigned char lsb;
321 int flag;
322 float aux;
323 rtems_status_code status;
324
325 unsigned int sy_lfr_n_swf_l;
326 unsigned int sy_lfr_n_swf_p;
327 unsigned int sy_lfr_n_asm_p;
328 unsigned char sy_lfr_n_bp_p0;
329 unsigned char sy_lfr_n_bp_p1;
330 unsigned char sy_lfr_n_cwf_long_f3;
331
332 flag = LFR_SUCCESSFUL;
333
334 //***************
335 // get parameters
336 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
337 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
338 sy_lfr_n_swf_l = msb * 256 + lsb;
339
340 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
341 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
342 sy_lfr_n_swf_p = msb * 256 + lsb;
343
344 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
345 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
346 sy_lfr_n_asm_p = msb * 256 + lsb;
347
348 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
349
350 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
351
352 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
353
354 //******************
355 // check consistency
356 // sy_lfr_n_swf_l
357 if (sy_lfr_n_swf_l != 2048)
358 {
359 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
360 flag = WRONG_APP_DATA;
361 }
362 // sy_lfr_n_swf_p
363 if (flag == LFR_SUCCESSFUL)
364 {
365 if ( sy_lfr_n_swf_p < 16 )
366 {
367 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
368 flag = WRONG_APP_DATA;
369 }
370 }
371 // sy_lfr_n_bp_p0
372 if (flag == LFR_SUCCESSFUL)
373 {
374 if (sy_lfr_n_bp_p0 < SY_LFR_N_BP_P0)
375 {
376 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
377 flag = WRONG_APP_DATA;
378 }
379 }
380 // sy_lfr_n_asm_p
381 if (flag == LFR_SUCCESSFUL)
382 {
383 if (sy_lfr_n_asm_p == 0)
384 {
385 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
386 flag = WRONG_APP_DATA;
387 }
388 }
389 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
390 if (flag == LFR_SUCCESSFUL)
391 {
392 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
393 if (aux != 0)
394 {
395 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
396 flag = WRONG_APP_DATA;
397 }
398 }
399 // sy_lfr_n_bp_p1
400 if (flag == LFR_SUCCESSFUL)
401 {
402 if (sy_lfr_n_bp_p1 < SY_LFR_N_BP_P1)
403 {
404 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
405 flag = WRONG_APP_DATA;
406 }
407 }
408 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
409 if (flag == LFR_SUCCESSFUL)
410 {
411 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
412 if (aux != 0)
413 {
414 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
415 flag = LFR_DEFAULT;
416 }
417 }
418 // sy_lfr_n_cwf_long_f3
419
420 return flag;
421 }
422
423 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
399 424 {
400 425 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
401 426 *
402 427 * @param TC points to the TeleCommand packet that is being processed
403 428 * @param queue_id is the id of the queue which handles TM related to this execution step
404 429 *
405 430 */
406 431
407 unsigned int tmp;
408 432 int result;
409 unsigned char msb;
410 unsigned char lsb;
411 rtems_status_code status;
412
413 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
414 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
415
416 tmp = ( unsigned int ) floor(
417 ( ( msb*256 ) + lsb ) / 16
418 ) * 16;
419 433
420 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
421 { // 2048 is the maximum limit due to the size of the buffers
422 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
423 result = WRONG_APP_DATA;
424 }
425 else if (tmp != 2048)
426 {
427 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
428 result = FUNCT_NOT_IMPL;
429 }
430 else
431 {
432 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
433 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
434 result = LFR_SUCCESSFUL;
435 }
434 result = LFR_SUCCESSFUL;
435
436 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
437 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
436 438
437 439 return result;
438 440 }
439 441
440 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
442 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
441 443 {
442 444 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
443 445 *
444 446 * @param TC points to the TeleCommand packet that is being processed
445 447 * @param queue_id is the id of the queue which handles TM related to this execution step
446 448 *
447 449 */
448 450
449 unsigned int tmp;
450 451 int result;
451 unsigned char msb;
452 unsigned char lsb;
453 rtems_status_code status;
454
455 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
456 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
457
458 tmp = msb * 256 + lsb;
459 452
460 if ( tmp < 16 )
461 {
462 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
463 result = WRONG_APP_DATA;
464 }
465 else
466 {
467 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
468 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
469 result = LFR_SUCCESSFUL;
470 }
453 result = LFR_SUCCESSFUL;
454
455 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
456 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
471 457
472 458 return result;
473 459 }
474 460
475 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
461 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
476 462 {
477 463 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
478 464 *
479 465 * @param TC points to the TeleCommand packet that is being processed
480 466 * @param queue_id is the id of the queue which handles TM related to this execution step
481 467 *
482 468 */
483 469
484 470 int result;
485 unsigned char msb;
486 unsigned char lsb;
471
472 result = LFR_SUCCESSFUL;
487 473
488 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
489 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
490
491 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
492 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
493 result = LFR_SUCCESSFUL;
474 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
475 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
494 476
495 477 return result;
496 478 }
497 479
498 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
480 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
499 481 {
500 482 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
501 483 *
502 484 * @param TC points to the TeleCommand packet that is being processed
503 485 * @param queue_id is the id of the queue which handles TM related to this execution step
504 486 *
505 487 */
506 488
507 489 int status;
508 unsigned char val;
509 490
510 491 status = LFR_SUCCESSFUL;
511 492
512 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
513
514 if (val < SY_LFR_N_BP_P0)
515 {
516 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, val );
517 status = WRONG_APP_DATA;
518 }
519 else
520 {
521 parameter_dump_packet.sy_lfr_n_bp_p0 = val;
522 }
493 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
523 494
524 495 return status;
525 496 }
526 497
527 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
498 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
528 499 {
529 500 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
530 501 *
531 502 * @param TC points to the TeleCommand packet that is being processed
532 503 * @param queue_id is the id of the queue which handles TM related to this execution step
533 504 *
534 505 */
535 506
536 507 int status;
537 unsigned char val;
538 508
539 509 status = LFR_SUCCESSFUL;
540 510
541 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
542
543 if (val < SY_LFR_N_BP_P1)
544 {
545 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, val );
546 status = WRONG_APP_DATA;
547 }
548 else
549 {
550 parameter_dump_packet.sy_lfr_n_bp_p1 = val;
551 }
511 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
552 512
553 513 return status;
554 514 }
555 515
556 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
516 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
557 517 {
558 518 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
559 519 *
560 520 * @param TC points to the TeleCommand packet that is being processed
561 521 * @param queue_id is the id of the queue which handles TM related to this execution step
562 522 *
563 523 */
564 524
565 525 int status;
566 526
567 527 status = LFR_SUCCESSFUL;
568 528
569 529 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
570 530
571 531 return status;
572 532 }
573 533
574 534 //**********************
575 535 // BURST MODE PARAMETERS
576 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
536 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
577 537 {
578 538 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
579 539 *
580 540 * @param TC points to the TeleCommand packet that is being processed
581 541 * @param queue_id is the id of the queue which handles TM related to this execution step
582 542 *
583 543 */
584 544
585 545 int status;
586 unsigned char val;
587 546
588 547 status = LFR_SUCCESSFUL;
589 548
590 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
591
592 if (val < DEFAULT_SY_LFR_B_BP_P0 )
593 {
594 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, val );
595 status = WRONG_APP_DATA;
596 }
597 else
598 {
599 parameter_dump_packet.sy_lfr_b_bp_p0 = val;
600 }
549 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
601 550
602 551 return status;
603 552 }
604 553
605 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
554 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
606 555 {
607 556 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
608 557 *
609 558 * @param TC points to the TeleCommand packet that is being processed
610 559 * @param queue_id is the id of the queue which handles TM related to this execution step
611 560 *
612 561 */
613 562
614 563 int status;
615 unsigned char val;
616 564
617 565 status = LFR_SUCCESSFUL;
618 566
619 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
620
621 if (val < DEFAULT_SY_LFR_B_BP_P1 )
622 {
623 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, val );
624 status = WRONG_APP_DATA;
625 }
626 else
627 {
628 parameter_dump_packet.sy_lfr_b_bp_p1 = val;
629 }
567 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
630 568
631 569 return status;
632 570 }
633 571
634 572 //*********************
635 573 // SBM1 MODE PARAMETERS
636 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
574 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
637 575 {
638 576 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
639 577 *
640 578 * @param TC points to the TeleCommand packet that is being processed
641 579 * @param queue_id is the id of the queue which handles TM related to this execution step
642 580 *
643 581 */
644 582
645 583 int status;
646 unsigned char val;
647 584
648 585 status = LFR_SUCCESSFUL;
649 586
650 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
651
652 if (val < DEFAULT_SY_LFR_S1_BP_P0 )
653 {
654 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, val );
655 status = WRONG_APP_DATA;
656 }
657 else
658 {
659 parameter_dump_packet.sy_lfr_s1_bp_p0 = val;
660 }
587 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
661 588
662 589 return status;
663 590 }
664 591
665 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
592 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
666 593 {
667 594 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
668 595 *
669 596 * @param TC points to the TeleCommand packet that is being processed
670 597 * @param queue_id is the id of the queue which handles TM related to this execution step
671 598 *
672 599 */
673 600
674 601 int status;
675 unsigned char val;
676 602
677 603 status = LFR_SUCCESSFUL;
678 604
679 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
680
681 if (val < DEFAULT_SY_LFR_S1_BP_P1 )
682 {
683 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, val );
684 status = WRONG_APP_DATA;
685 }
686 else
687 {
688 parameter_dump_packet.sy_lfr_s1_bp_p1 = val;
689 }
605 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
690 606
691 607 return status;
692 608 }
693 609
694 610 //*********************
695 611 // SBM2 MODE PARAMETERS
696 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
612 int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC)
697 613 {
698 614 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
699 615 *
700 616 * @param TC points to the TeleCommand packet that is being processed
701 617 * @param queue_id is the id of the queue which handles TM related to this execution step
702 618 *
703 619 */
704 620
705 621 int status;
706 unsigned char val;
707 622
708 623 status = LFR_SUCCESSFUL;
709 624
710 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
711
712 if (val < DEFAULT_SY_LFR_S2_BP_P0 )
713 {
714 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, val );
715 status = WRONG_APP_DATA;
716 }
717 else
718 {
719 parameter_dump_packet.sy_lfr_s2_bp_p0 = val;
720 }
625 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
721 626
722 627 return status;
723 628 }
724 629
725 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
630 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
726 631 {
727 632 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
728 633 *
729 634 * @param TC points to the TeleCommand packet that is being processed
730 635 * @param queue_id is the id of the queue which handles TM related to this execution step
731 636 *
732 637 */
733 638
734 639 int status;
735 unsigned char val;
736 640
737 641 status = LFR_SUCCESSFUL;
738 642
739 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
740
741 if (val < DEFAULT_SY_LFR_S2_BP_P1 )
742 {
743 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, val );
744 status = WRONG_APP_DATA;
745 }
746 else
747 {
748 parameter_dump_packet.sy_lfr_s2_bp_p1 = val;
749 }
643 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
750 644
751 645 return status;
752 646 }
753 647
754 648
755 649 //*******************
756 650 // TC_LFR_UPDATE_INFO
757 651 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
758 652 {
759 653 unsigned int status;
760 654
761 655 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
762 656 || (mode == LFR_MODE_BURST)
763 657 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
764 658 {
765 659 status = LFR_SUCCESSFUL;
766 660 }
767 661 else
768 662 {
769 663 status = LFR_DEFAULT;
770 664 }
771 665
772 666 return status;
773 667 }
774 668
775 669 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
776 670 {
777 671 unsigned int status;
778 672
779 673 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
780 674 || (mode == TDS_MODE_BURST)
781 675 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
782 676 || (mode == TDS_MODE_LFM))
783 677 {
784 678 status = LFR_SUCCESSFUL;
785 679 }
786 680 else
787 681 {
788 682 status = LFR_DEFAULT;
789 683 }
790 684
791 685 return status;
792 686 }
793 687
794 688 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
795 689 {
796 690 unsigned int status;
797 691
798 692 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
799 693 || (mode == THR_MODE_BURST))
800 694 {
801 695 status = LFR_SUCCESSFUL;
802 696 }
803 697 else
804 698 {
805 699 status = LFR_DEFAULT;
806 700 }
807 701
808 702 return status;
809 703 }
810 704
811 705 //**********
812 706 // init dump
813 707
814 708 void init_parameter_dump( void )
815 709 {
816 710 /** This function initialize the parameter_dump_packet global variable with default values.
817 711 *
818 712 */
819 713
820 714 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
821 715 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
822 716 parameter_dump_packet.reserved = CCSDS_RESERVED;
823 717 parameter_dump_packet.userApplication = CCSDS_USER_APP;
824 718 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
825 719 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
826 720 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
827 721 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
828 722 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
829 723 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
830 724 // DATA FIELD HEADER
831 725 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
832 726 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
833 727 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
834 728 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
835 729 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
836 730 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
837 731 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
838 732 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
839 733 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
840 734 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
841 735 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
842 736
843 737 //******************
844 738 // COMMON PARAMETERS
845 739 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
846 740 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
847 741
848 742 //******************
849 743 // NORMAL PARAMETERS
850 744 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
851 745 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
852 746 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
853 747 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
854 748 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
855 749 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
856 750 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
857 751 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
858 752 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
859 753
860 754 //*****************
861 755 // BURST PARAMETERS
862 756 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
863 757 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
864 758
865 759 //****************
866 760 // SBM1 PARAMETERS
867 761 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
868 762 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
869 763
870 764 //****************
871 765 // SBM2 PARAMETERS
872 766 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
873 767 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
874 768 }
875 769
876 770
877 771
878 772
879 773
880 774
881 775
@@ -1,510 +1,510
1 1 /** Functions to send TM packets related to TC parsing and execution.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to send appropriate TM packets after parsing and execution:
7 7 * - TM_LFR_TC_EXE_SUCCESS
8 8 * - TM_LFR_TC_EXE_INCONSISTENT
9 9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
10 10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
11 11 * - TM_LFR_TC_EXE_ERROR
12 12 * - TM_LFR_TC_EXE_CORRUPTED
13 13 *
14 14 */
15 15
16 16 #include "tm_lfr_tc_exe.h"
17 17
18 18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
19 19 {
20 20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
21 21 *
22 22 * @param TC points to the TeleCommand packet that is being processed
23 23 * @param queue_id is the id of the queue which handles TM
24 24 *
25 25 * @return RTEMS directive status code:
26 26 * - RTEMS_SUCCESSFUL - message sent successfully
27 27 * - RTEMS_INVALID_ID - invalid queue id
28 28 * - RTEMS_INVALID_SIZE - invalid message size
29 29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
30 30 * - RTEMS_UNSATISFIED - out of message buffers
31 31 * - RTEMS_TOO_MANY - queue s limit has been reached
32 32 *
33 33 */
34 34
35 35 rtems_status_code status;
36 36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
37 37 unsigned char messageSize;
38 38
39 39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
40 40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
45 45 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 49 // DATA FIELD HEADER
50 50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 51 TM.serviceType = TM_TYPE_TC_EXE;
52 52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 53 TM.destinationID = TC->sourceID;
54 54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
55 55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
56 56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
57 57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
58 58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
59 59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
60 60 //
61 61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 62 TM.telecommand_pkt_id[1] = TC->packetID[1];
63 63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
64 64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
65 65
66 66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
67 67
68 68 // SEND DATA
69 69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
70 70 if (status != RTEMS_SUCCESSFUL) {
71 71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
72 72 }
73 73
74 74 // UPDATE HK FIELDS
75 75 update_last_TC_exe( TC, TM.time );
76 76
77 77 return status;
78 78 }
79 79
80 80 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
81 81 unsigned char byte_position, unsigned char rcv_value )
82 82 {
83 83 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
84 84 *
85 85 * @param TC points to the TeleCommand packet that is being processed
86 86 * @param queue_id is the id of the queue which handles TM
87 87 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
88 88 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
89 89 *
90 90 * @return RTEMS directive status code:
91 91 * - RTEMS_SUCCESSFUL - message sent successfully
92 92 * - RTEMS_INVALID_ID - invalid queue id
93 93 * - RTEMS_INVALID_SIZE - invalid message size
94 94 * - RTEMS_INVALID_ADDRESS - buffer is NULL
95 95 * - RTEMS_UNSATISFIED - out of message buffers
96 96 * - RTEMS_TOO_MANY - queue s limit has been reached
97 97 *
98 98 */
99 99
100 100 rtems_status_code status;
101 101 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
102 102 unsigned char messageSize;
103 103
104 104 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
105 105 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
106 106 TM.reserved = DEFAULT_RESERVED;
107 107 TM.userApplication = CCSDS_USER_APP;
108 108 // PACKET HEADER
109 109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
110 110 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
111 111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
112 112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
113 113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
114 114 // DATA FIELD HEADER
115 115 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
116 116 TM.serviceType = TM_TYPE_TC_EXE;
117 117 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
118 118 TM.destinationID = TC->sourceID;
119 119 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
120 120 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
121 121 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
122 122 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
123 123 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
124 124 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
125 125 //
126 126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
127 127 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
128 128 TM.telecommand_pkt_id[0] = TC->packetID[0];
129 129 TM.telecommand_pkt_id[1] = TC->packetID[1];
130 130 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
131 131 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
132 132 TM.tc_service = TC->serviceType; // type of the rejected TC
133 133 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
134 134 TM.byte_position = byte_position;
135 TM.rcv_value = rcv_value;
135 TM.rcv_value = (unsigned char) rcv_value;
136 136
137 137 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
138 138
139 139 // SEND DATA
140 140 status = rtems_message_queue_send( queue_id, &TM, messageSize);
141 141 if (status != RTEMS_SUCCESSFUL) {
142 142 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
143 143 }
144 144
145 145 // UPDATE HK FIELDS
146 146 update_last_TC_rej( TC, TM.time );
147 147
148 148 return status;
149 149 }
150 150
151 151 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 152 {
153 153 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
154 154 *
155 155 * @param TC points to the TeleCommand packet that is being processed
156 156 * @param queue_id is the id of the queue which handles TM
157 157 *
158 158 * @return RTEMS directive status code:
159 159 * - RTEMS_SUCCESSFUL - message sent successfully
160 160 * - RTEMS_INVALID_ID - invalid queue id
161 161 * - RTEMS_INVALID_SIZE - invalid message size
162 162 * - RTEMS_INVALID_ADDRESS - buffer is NULL
163 163 * - RTEMS_UNSATISFIED - out of message buffers
164 164 * - RTEMS_TOO_MANY - queue s limit has been reached
165 165 *
166 166 */
167 167
168 168 rtems_status_code status;
169 169 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
170 170 unsigned char messageSize;
171 171
172 172 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
173 173 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
174 174 TM.reserved = DEFAULT_RESERVED;
175 175 TM.userApplication = CCSDS_USER_APP;
176 176 // PACKET HEADER
177 177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
178 178 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
179 179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
180 180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
181 181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
182 182 // DATA FIELD HEADER
183 183 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
184 184 TM.serviceType = TM_TYPE_TC_EXE;
185 185 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
186 186 TM.destinationID = TC->sourceID; // default destination id
187 187 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
188 188 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
189 189 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
190 190 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
191 191 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
192 192 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
193 193 //
194 194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
195 195 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
196 196 TM.telecommand_pkt_id[0] = TC->packetID[0];
197 197 TM.telecommand_pkt_id[1] = TC->packetID[1];
198 198 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
199 199 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
200 200 TM.tc_service = TC->serviceType; // type of the rejected TC
201 201 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
202 202 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
203 203 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
204 204
205 205 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
206 206
207 207 // SEND DATA
208 208 status = rtems_message_queue_send( queue_id, &TM, messageSize);
209 209 if (status != RTEMS_SUCCESSFUL) {
210 210 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
211 211 }
212 212
213 213 // UPDATE HK FIELDS
214 214 update_last_TC_rej( TC, TM.time );
215 215
216 216 return status;
217 217 }
218 218
219 219 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
220 220 {
221 221 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
222 222 *
223 223 * @param TC points to the TeleCommand packet that is being processed
224 224 * @param queue_id is the id of the queue which handles TM
225 225 *
226 226 * @return RTEMS directive status code:
227 227 * - RTEMS_SUCCESSFUL - message sent successfully
228 228 * - RTEMS_INVALID_ID - invalid queue id
229 229 * - RTEMS_INVALID_SIZE - invalid message size
230 230 * - RTEMS_INVALID_ADDRESS - buffer is NULL
231 231 * - RTEMS_UNSATISFIED - out of message buffers
232 232 * - RTEMS_TOO_MANY - queue s limit has been reached
233 233 *
234 234 */
235 235
236 236 rtems_status_code status;
237 237 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
238 238 unsigned char messageSize;
239 239
240 240 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
241 241 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
242 242 TM.reserved = DEFAULT_RESERVED;
243 243 TM.userApplication = CCSDS_USER_APP;
244 244 // PACKET HEADER
245 245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
246 246 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
247 247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
248 248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
249 249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
250 250 // DATA FIELD HEADER
251 251 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
252 252 TM.serviceType = TM_TYPE_TC_EXE;
253 253 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
254 254 TM.destinationID = TC->sourceID; // default destination id
255 255 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
256 256 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
257 257 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
258 258 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
259 259 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
260 260 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
261 261 //
262 262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
263 263 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
264 264 TM.telecommand_pkt_id[0] = TC->packetID[0];
265 265 TM.telecommand_pkt_id[1] = TC->packetID[1];
266 266 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
267 267 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
268 268 TM.tc_service = TC->serviceType; // type of the rejected TC
269 269 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
270 270
271 271 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
272 272
273 273 // SEND DATA
274 274 status = rtems_message_queue_send( queue_id, &TM, messageSize);
275 275 if (status != RTEMS_SUCCESSFUL) {
276 276 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
277 277 }
278 278
279 279 // UPDATE HK FIELDS
280 280 update_last_TC_rej( TC, TM.time );
281 281
282 282 return status;
283 283 }
284 284
285 285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
286 286 {
287 287 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
288 288 *
289 289 * @param TC points to the TeleCommand packet that is being processed
290 290 * @param queue_id is the id of the queue which handles TM
291 291 *
292 292 * @return RTEMS directive status code:
293 293 * - RTEMS_SUCCESSFUL - message sent successfully
294 294 * - RTEMS_INVALID_ID - invalid queue id
295 295 * - RTEMS_INVALID_SIZE - invalid message size
296 296 * - RTEMS_INVALID_ADDRESS - buffer is NULL
297 297 * - RTEMS_UNSATISFIED - out of message buffers
298 298 * - RTEMS_TOO_MANY - queue s limit has been reached
299 299 *
300 300 */
301 301
302 302 rtems_status_code status;
303 303 Packet_TM_LFR_TC_EXE_ERROR_t TM;
304 304 unsigned char messageSize;
305 305
306 306 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
307 307 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
308 308 TM.reserved = DEFAULT_RESERVED;
309 309 TM.userApplication = CCSDS_USER_APP;
310 310 // PACKET HEADER
311 311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
312 312 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
313 313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
314 314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
315 315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
316 316 // DATA FIELD HEADER
317 317 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
318 318 TM.serviceType = TM_TYPE_TC_EXE;
319 319 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
320 320 TM.destinationID = TC->sourceID; // default destination id
321 321 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
322 322 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
323 323 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
324 324 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
325 325 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
326 326 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
327 327 //
328 328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
329 329 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
330 330 TM.telecommand_pkt_id[0] = TC->packetID[0];
331 331 TM.telecommand_pkt_id[1] = TC->packetID[1];
332 332 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
333 333 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
334 334 TM.tc_service = TC->serviceType; // type of the rejected TC
335 335 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
336 336
337 337 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
338 338
339 339 // SEND DATA
340 340 status = rtems_message_queue_send( queue_id, &TM, messageSize);
341 341 if (status != RTEMS_SUCCESSFUL) {
342 342 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
343 343 }
344 344
345 345 // UPDATE HK FIELDS
346 346 update_last_TC_rej( TC, TM.time );
347 347
348 348 return status;
349 349 }
350 350
351 351 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
352 352 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
353 353 unsigned char destinationID )
354 354 {
355 355 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
356 356 *
357 357 * @param TC points to the TeleCommand packet that is being processed
358 358 * @param queue_id is the id of the queue which handles TM
359 359 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
360 360 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
361 361 *
362 362 * @return RTEMS directive status code:
363 363 * - RTEMS_SUCCESSFUL - message sent successfully
364 364 * - RTEMS_INVALID_ID - invalid queue id
365 365 * - RTEMS_INVALID_SIZE - invalid message size
366 366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 367 * - RTEMS_UNSATISFIED - out of message buffers
368 368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 369 *
370 370 */
371 371
372 372 rtems_status_code status;
373 373 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
374 374 unsigned char messageSize;
375 375 unsigned int packetLength;
376 376 unsigned char *packetDataField;
377 377
378 378 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
379 379 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
380 380
381 381 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
382 382 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
383 383 TM.reserved = DEFAULT_RESERVED;
384 384 TM.userApplication = CCSDS_USER_APP;
385 385 // PACKET HEADER
386 386 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
387 387 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
388 388 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
389 389 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
390 390 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
391 391 // DATA FIELD HEADER
392 392 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
393 393 TM.serviceType = TM_TYPE_TC_EXE;
394 394 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
395 395 TM.destinationID = destinationID;
396 396 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
397 397 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
398 398 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
399 399 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
400 400 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
401 401 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
402 402 //
403 403 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
404 404 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
405 405 TM.telecommand_pkt_id[0] = TC->packetID[0];
406 406 TM.telecommand_pkt_id[1] = TC->packetID[1];
407 407 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
408 408 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
409 409 TM.tc_service = TC->serviceType; // type of the rejected TC
410 410 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
411 411 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
412 412 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
413 413 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
414 414 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
415 415 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
416 416 TM.rcv_crc[1] = packetDataField[ packetLength ];
417 417 TM.computed_crc[0] = computed_CRC[0];
418 418 TM.computed_crc[1] = computed_CRC[1];
419 419
420 420 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
421 421
422 422 // SEND DATA
423 423 status = rtems_message_queue_send( queue_id, &TM, messageSize);
424 424 if (status != RTEMS_SUCCESSFUL) {
425 425 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
426 426 }
427 427
428 428 // UPDATE HK FIELDS
429 429 update_last_TC_rej( TC, TM.time );
430 430
431 431 return status;
432 432 }
433 433
434 434 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
435 435 {
436 436 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
437 437 *
438 438 * @param packet_sequence_control points to the packet sequence control which will be incremented
439 439 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
440 440 *
441 441 * If the destination ID is not known, a dedicated counter is incremented.
442 442 *
443 443 */
444 444
445 445 unsigned short sequence_cnt;
446 446 unsigned short segmentation_grouping_flag;
447 447 unsigned short new_packet_sequence_control;
448 448 unsigned char i;
449 449
450 450 switch (destination_id)
451 451 {
452 452 case SID_TC_GROUND:
453 453 i = GROUND;
454 454 break;
455 455 case SID_TC_MISSION_TIMELINE:
456 456 i = MISSION_TIMELINE;
457 457 break;
458 458 case SID_TC_TC_SEQUENCES:
459 459 i = TC_SEQUENCES;
460 460 break;
461 461 case SID_TC_RECOVERY_ACTION_CMD:
462 462 i = RECOVERY_ACTION_CMD;
463 463 break;
464 464 case SID_TC_BACKUP_MISSION_TIMELINE:
465 465 i = BACKUP_MISSION_TIMELINE;
466 466 break;
467 467 case SID_TC_DIRECT_CMD:
468 468 i = DIRECT_CMD;
469 469 break;
470 470 case SID_TC_SPARE_GRD_SRC1:
471 471 i = SPARE_GRD_SRC1;
472 472 break;
473 473 case SID_TC_SPARE_GRD_SRC2:
474 474 i = SPARE_GRD_SRC2;
475 475 break;
476 476 case SID_TC_OBCP:
477 477 i = OBCP;
478 478 break;
479 479 case SID_TC_SYSTEM_CONTROL:
480 480 i = SYSTEM_CONTROL;
481 481 break;
482 482 case SID_TC_AOCS:
483 483 i = AOCS;
484 484 break;
485 485 case SID_TC_RPW_INTERNAL:
486 486 i = RPW_INTERNAL;
487 487 break;
488 488 default:
489 489 i = GROUND;
490 490 break;
491 491 }
492 492
493 493 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
494 494 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
495 495
496 496 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
497 497
498 498 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
499 499 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
500 500
501 501 // increment the sequence counter
502 502 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX )
503 503 {
504 504 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
505 505 }
506 506 else
507 507 {
508 508 sequenceCounters_TC_EXE[ i ] = 0;
509 509 }
510 510 }
General Comments 0
You need to be logged in to leave comments. Login now