##// END OF EJS Templates
Minor changes in .h inclusion
paul -
r45:c48d02b72186 default
parent child
Show More
@@ -0,0 +1,24
1 #ifndef TC_ACCEPTANCE_H_INCLUDED
2 #define TC_ACCEPTANCE_H_INCLUDED
3
4 //#include "tm_lfr_tc_exe.h"
5 #include "fsw_params.h"
6
7 //**********************
8 // GENERAL USE FUNCTIONS
9 unsigned int Crc_opt( unsigned char D, unsigned int Chk);
10 void initLookUpTableForCRC( void );
11 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
12
13 //*********************
14 // ACCEPTANCE FUNCTIONS
15 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC);
16 int tc_check_type( unsigned char packetType );
17 int tc_check_subtype( unsigned char packetType );
18 int tc_check_length( unsigned char packetType, unsigned int length );
19 int tc_check_crc(ccsdsTelecommandPacket_t * TCPacket, unsigned int length , unsigned char *computed_CRC);
20
21 #endif // TC_ACCEPTANCE_H_INCLUDED
22
23
24
@@ -0,0 +1,374
1 /** Functions related to TeleCommand acceptance.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle TeleCommands parsing.\n
7 *
8 */
9
10 #include "tc_acceptance.h"
11
12 unsigned int lookUpTableForCRC[256];
13
14 //**********************
15 // GENERAL USE FUNCTIONS
16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
17 {
18 /** This function generate the CRC for one byte and returns the value of the new syndrome.
19 *
20 * @param D is the current byte of data.
21 * @param Chk is the current syndrom value.
22 * @return the value of the new syndrome on two bytes.
23 *
24 */
25
26 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
27 }
28
29 void initLookUpTableForCRC( void )
30 {
31 /** This function is used to initiates the look-up table for fast CRC computation.
32 *
33 * The global table lookUpTableForCRC[256] is initiated.
34 *
35 */
36
37 unsigned int i;
38 unsigned int tmp;
39
40 for (i=0; i<256; i++)
41 {
42 tmp = 0;
43 if((i & 1) != 0) {
44 tmp = tmp ^ 0x1021;
45 }
46 if((i & 2) != 0) {
47 tmp = tmp ^ 0x2042;
48 }
49 if((i & 4) != 0) {
50 tmp = tmp ^ 0x4084;
51 }
52 if((i & 8) != 0) {
53 tmp = tmp ^ 0x8108;
54 }
55 if((i & 16) != 0) {
56 tmp = tmp ^ 0x1231;
57 }
58 if((i & 32) != 0) {
59 tmp = tmp ^ 0x2462;
60 }
61 if((i & 64) != 0) {
62 tmp = tmp ^ 0x48c4;
63 }
64 if((i & 128) != 0) {
65 tmp = tmp ^ 0x9188;
66 }
67 lookUpTableForCRC[i] = tmp;
68 }
69 }
70
71 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
72 {
73 /** This function calculates a two bytes Cyclic Redundancy Code.
74 *
75 * @param data points to a buffer containing the data on which to compute the CRC.
76 * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored.
77 * @param sizeOfData is the number of bytes of *data* used to compute the CRC.
78 *
79 * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A.
80 *
81 */
82
83 unsigned int Chk;
84 int j;
85 Chk = 0xffff; // reset the syndrom to all ones
86 for (j=0; j<sizeOfData; j++) {
87 Chk = Crc_opt(data[j], Chk);
88 }
89 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
90 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
91 }
92
93 //*********************
94 // ACCEPTANCE FUNCTIONS
95 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC)
96 {
97 /** This function parses TeleCommands.
98 *
99 * @param TC points to the TeleCommand that will be parsed.
100 * @param TC_LEN_RCV is the received packet length.
101 * @return Status code of the parsing.
102 *
103 * The parsing checks:
104 * - process id
105 * - category
106 * - length: a global check is performed and a per subtype check also
107 * - type
108 * - subtype
109 * - crc
110 *
111 */
112
113 int status;
114 unsigned char pid;
115 unsigned char category;
116 unsigned int length;
117 unsigned char packetType;
118 unsigned char packetSubtype;
119
120 status = CCSDS_TM_VALID;
121
122 // APID check *** APID on 2 bytes
123 pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
124 category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
125 length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1];
126 packetType = TCPacket->serviceType;
127 packetSubtype = TCPacket->serviceSubType;
128
129 if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID
130 {
131 status = ILLEGAL_APID;
132 }
133 if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY
134 {
135 if ( category != CCSDS_PACKET_CATEGORY )
136 {
137 status = ILLEGAL_APID;
138 }
139 }
140 if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE
141 {
142 if (length != TC_LEN_RCV ) {
143 status = WRONG_LEN_PACKET;
144 }
145 }
146 if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE
147 {
148 if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
149 status = WRONG_LEN_PACKET;
150 }
151 }
152 if (status == CCSDS_TM_VALID) // CHECK THE TYPE
153 {
154 status = tc_check_type( packetType );
155 }
156 if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE
157 {
158 status = tc_check_subtype( packetSubtype );
159 }
160 if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE
161 {
162 status = tc_check_length( packetSubtype, length );
163 }
164 if (status == CCSDS_TM_VALID ) // CHECK CRC
165 {
166 status = tc_check_crc( TCPacket, length, computed_CRC );
167 }
168
169 return status;
170 }
171
172 int tc_check_type( unsigned char packetType )
173 {
174 /** This function checks that the type of a TeleCommand is valid.
175 *
176 * @param packetType is the type to check.
177 * @return Status code CCSDS_TM_VALID or ILL_TYPE.
178 *
179 */
180
181 int status;
182
183 if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME))
184 {
185 status = CCSDS_TM_VALID;
186 }
187 else
188 {
189 status = ILL_TYPE;
190 }
191
192 return status;
193 }
194
195 int tc_check_subtype( unsigned char packetSubType )
196 {
197 /** This function checks that the subtype of a TeleCommand is valid.
198 *
199 * @param packetSubType is the subtype to check.
200 * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE.
201 *
202 */
203
204 int status;
205
206 if ( (packetSubType == TC_SUBTYPE_RESET)
207 || (packetSubType == TC_SUBTYPE_LOAD_COMM)
208 || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST)
209 || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2)
210 || (packetSubType == TC_SUBTYPE_DUMP)
211 || (packetSubType == TC_SUBTYPE_ENTER)
212 || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME)
213 || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) )
214 {
215 status = CCSDS_TM_VALID;
216 }
217 else
218 {
219 status = ILL_TYPE;
220 }
221
222 return status;
223 }
224
225 int tc_check_length( unsigned char packetSubType, unsigned int length )
226 {
227 /** This function checks that the subtype and the length are compliant.
228 *
229 * @param packetSubType is the subtype to check.
230 * @param length is the length to check.
231 * @return Status code CCSDS_TM_VALID or ILL_TYPE.
232 *
233 */
234
235 int status;
236
237 status = LFR_SUCCESSFUL;
238
239 switch(packetSubType)
240 {
241 case TC_SUBTYPE_RESET:
242 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
243 status = WRONG_LEN_PACKET;
244 }
245 else {
246 status = CCSDS_TM_VALID;
247 }
248 break;
249 case TC_SUBTYPE_LOAD_COMM:
250 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
251 status = WRONG_LEN_PACKET;
252 }
253 else {
254 status = CCSDS_TM_VALID;
255 }
256 break;
257 case TC_SUBTYPE_LOAD_NORM:
258 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
259 status = WRONG_LEN_PACKET;
260 }
261 else {
262 status = CCSDS_TM_VALID;
263 }
264 break;
265 case TC_SUBTYPE_LOAD_BURST:
266 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
267 status = WRONG_LEN_PACKET;
268 }
269 else {
270 status = CCSDS_TM_VALID;
271 }
272 break;
273 case TC_SUBTYPE_LOAD_SBM1:
274 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
275 status = WRONG_LEN_PACKET;
276 }
277 else {
278 status = CCSDS_TM_VALID;
279 }
280 break;
281 case TC_SUBTYPE_LOAD_SBM2:
282 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
283 status = WRONG_LEN_PACKET;
284 }
285 else {
286 status = CCSDS_TM_VALID;
287 }
288 break;
289 case TC_SUBTYPE_DUMP:
290 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
291 status = WRONG_LEN_PACKET;
292 }
293 else {
294 status = CCSDS_TM_VALID;
295 }
296 break;
297 case TC_SUBTYPE_ENTER:
298 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
299 status = WRONG_LEN_PACKET;
300 }
301 else {
302 status = CCSDS_TM_VALID;
303 }
304 break;
305 case TC_SUBTYPE_UPDT_INFO:
306 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
307 status = WRONG_LEN_PACKET;
308 }
309 else {
310 status = CCSDS_TM_VALID;
311 }
312 break;
313 case TC_SUBTYPE_EN_CAL:
314 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
315 status = WRONG_LEN_PACKET;
316 }
317 else {
318 status = CCSDS_TM_VALID;
319 }
320 break;
321 case TC_SUBTYPE_DIS_CAL:
322 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
323 status = WRONG_LEN_PACKET;
324 }
325 else {
326 status = CCSDS_TM_VALID;
327 }
328 break;
329 case TC_SUBTYPE_UPDT_TIME:
330 if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
331 status = WRONG_LEN_PACKET;
332 }
333 else {
334 status = CCSDS_TM_VALID;
335 }
336 break;
337 default: // if the subtype is not a legal value, return ILL_SUBTYPE
338 status = ILL_SUBTYPE;
339 break ;
340 }
341
342 return status;
343 }
344
345 int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length, unsigned char *computed_CRC )
346 {
347 /** This function checks the CRC validity of the corresponding TeleCommand packet.
348 *
349 * @param TCPacket points to the TeleCommand packet to check.
350 * @param length is the length of the TC packet.
351 * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM.
352 *
353 */
354
355 int status;
356 unsigned char * CCSDSContent;
357
358 CCSDSContent = (unsigned char*) TCPacket->packetID;
359 GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
360 if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
361 status = INCOR_CHECKSUM;
362 }
363 else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
364 status = INCOR_CHECKSUM;
365 }
366 else {
367 status = CCSDS_TM_VALID;
368 }
369
370 return status;
371 }
372
373
374
@@ -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: Thu Oct 17 13:22:13 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 18 15:44:51 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
@@ -51,7 +51,8 SOURCES = ../src/wf_handler.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 \
53 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c
54 ../src/tm_lfr_tc_exe.c \
55 ../src/tc_acceptance.c
55 OBJECTS = obj/wf_handler.o \
56 OBJECTS = obj/wf_handler.o \
56 obj/tc_handler.o \
57 obj/tc_handler.o \
57 obj/fsw_processing.o \
58 obj/fsw_processing.o \
@@ -60,7 +61,8 OBJECTS = obj/wf_handler.o \
60 obj/fsw_globals.o \
61 obj/fsw_globals.o \
61 obj/fsw_spacewire.o \
62 obj/fsw_spacewire.o \
62 obj/tc_load_dump_parameters.o \
63 obj/tc_load_dump_parameters.o \
63 obj/tm_lfr_tc_exe.o
64 obj/tm_lfr_tc_exe.o \
65 obj/tc_acceptance.o
64 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
65 /usr/lib64/qt4/mkspecs/common/linux.conf \
67 /usr/lib64/qt4/mkspecs/common/linux.conf \
66 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
@@ -212,7 +214,7 obj/wf_handler.o: ../src/wf_handler.c
212 obj/tc_handler.o: ../src/tc_handler.c
214 obj/tc_handler.o: ../src/tc_handler.c
213 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
214
216
215 obj/fsw_processing.o: ../src/fsw_processing.c
217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
216 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
217
219
218 obj/fsw_misc.o: ../src/fsw_misc.c
220 obj/fsw_misc.o: ../src/fsw_misc.c
@@ -233,6 +235,9 obj/tc_load_dump_parameters.o: ../src/tc
233 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
235 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
236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
235
237
238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240
236 ####### Install
241 ####### Install
237
242
238 install: FORCE
243 install: FORCE
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -52,7 +52,9 SOURCES += \
52 ../src/fsw_globals.c \
52 ../src/fsw_globals.c \
53 ../src/fsw_spacewire.c \
53 ../src/fsw_spacewire.c \
54 ../src/tc_load_dump_parameters.c \
54 ../src/tc_load_dump_parameters.c \
55 ../src/tm_lfr_tc_exe.c
55 ../src/tm_lfr_tc_exe.c \
56 ../src/tc_acceptance.c
57
56
58
57 HEADERS += \
59 HEADERS += \
58 ../header/wf_handler.h \
60 ../header/wf_handler.h \
@@ -67,5 +69,6 HEADERS += \
67 ../header/fsw_spacewire.h \
69 ../header/fsw_spacewire.h \
68 ../header/tm_byte_positions.h \
70 ../header/tm_byte_positions.h \
69 ../header/tc_load_dump_parameters.h \
71 ../header/tc_load_dump_parameters.h \
70 ../header/tm_lfr_tc_exe.h
72 ../header/tm_lfr_tc_exe.h \
73 ../header/tc_acceptance.h
71
74
@@ -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-17T08:46:24. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-18T15:44:56. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -1806,7 +1806,7 CALL_GRAPH = YES
1806 # the time of a run. So in most cases it will be better to enable caller
1806 # the time of a run. So in most cases it will be better to enable caller
1807 # graphs for selected functions only using the \callergraph command.
1807 # graphs for selected functions only using the \callergraph command.
1808
1808
1809 CALLER_GRAPH = NO
1809 CALLER_GRAPH = YES
1810
1810
1811 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1811 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1812 # will generate a graphical hierarchy of all classes instead of a textual one.
1812 # will generate a graphical hierarchy of all classes instead of a textual one.
@@ -1,5 +1,5
1 #ifndef CCSDS_H_INCLUDED
1 #ifndef CCSDS_TYPES_H_INCLUDED
2 #define CCSDS_H_INCLUDED
2 #define CCSDS_TYPES_H_INCLUDED
3
3
4 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
4 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
5 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
5 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
@@ -624,4 +624,4 struct Packet_TM_LFR_PARAMETER_DUMP_str
624 typedef struct Packet_TM_LFR_PARAMETER_DUMP_str Packet_TM_LFR_PARAMETER_DUMP_t;
624 typedef struct Packet_TM_LFR_PARAMETER_DUMP_str Packet_TM_LFR_PARAMETER_DUMP_t;
625
625
626
626
627 #endif // CCSDS_H_INCLUDED
627 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,16 +1,7
1 #ifndef FSW_RTEMS_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
4 #include <errno.h>
5 #include <fcntl.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <unistd.h> // for the read call
9 #include <sys/ioctl.h> // for the ioctl call
10
3
11 #include <rtems.h>
4 #include <rtems.h>
12 #include <grspw.h>
13 #include <apbuart.h>
14 #include <leon.h>
5 #include <leon.h>
15
6
16 #include "fsw_params.h"
7 #include "fsw_params.h"
@@ -55,4 +46,4 extern void rtems_stack_checker_report_u
55 extern int sched_yield( void );
46 extern int sched_yield( void );
56 extern int errno;
47 extern int errno;
57
48
58 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
49 #endif // FSW_INIT_H_INCLUDED
@@ -1,10 +1,18
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 "fsw_init.h"
4 #include <rtems.h>
5 #include <stdio.h>
6 #include <grspw.h>
7
8 #include "fsw_params.h"
9 #include "fsw_spacewire.h"
5
10
6 rtems_name HK_name; // name of the HK rate monotonic
11 rtems_name HK_name; // name of the HK rate monotonic
7 rtems_id HK_id; // id of the HK rate monotonic period
12 rtems_id HK_id; // id of the HK rate monotonic period
13
14 extern rtems_name misc_name[5];
15 time_management_regs_t *time_management_regs;
8 extern Packet_TM_LFR_HK_t housekeeping_packet;
16 extern Packet_TM_LFR_HK_t housekeeping_packet;
9
17
10 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
@@ -12,17 +20,14 int configure_timer(gptimer_regs_t *gpti
12 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
20 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
13 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
14 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
22 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
15 void update_spacewire_statistics();
16
23
17 // SERIAL LINK
24 // SERIAL LINK
18 int send_console_outputs_on_apbuart_port( void );
25 int send_console_outputs_on_apbuart_port( void );
19 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
26 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
20
27
21 // RTEMS TASKS
28 // RTEMS TASKS
22 rtems_task stat_task(rtems_task_argument argument);
29 rtems_task stat_task( rtems_task_argument argument );
23 rtems_task hous_task(rtems_task_argument argument);
30 rtems_task hous_task( rtems_task_argument argument );
24 rtems_task send_task(rtems_task_argument argument);
31 rtems_task dumb_task( rtems_task_argument unused );
25
26 rtems_id get_pkts_queue_id( void );
27
32
28 #endif // FSW_MISC_H_INCLUDED
33 #endif // FSW_MISC_H_INCLUDED
@@ -1,5 +1,5
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_PARAMS_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
3
3
4 #include "grlib_regs.h"
4 #include "grlib_regs.h"
5 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
@@ -222,4 +222,4 struct param_local_str{
222 unsigned int local_nb_interrupt_f0_MAX;
222 unsigned int local_nb_interrupt_f0_MAX;
223 };
223 };
224
224
225 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
225 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,7 +1,14
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
3
4 #include "fsw_init.h"
4 #include <rtems.h>
5 #include <grspw.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
9
10 #include "fsw_params.h"
11
5
12
6 extern volatile int spec_mat_f0_0[ ];
13 extern volatile int spec_mat_f0_0[ ];
7 extern volatile int spec_mat_f0_1[ ];
14 extern volatile int spec_mat_f0_1[ ];
@@ -29,6 +36,9 extern struct param_local_str param_loca
29 extern time_management_regs_t *time_management_regs;
36 extern time_management_regs_t *time_management_regs;
30 extern spectral_matrix_regs_t *spectral_matrix_regs;
37 extern spectral_matrix_regs_t *spectral_matrix_regs;
31
38
39 extern rtems_name misc_name[5];
40 extern rtems_id Task_id[20]; /* array of task ids */
41
32 // ISR
42 // ISR
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
43 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
34 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
44 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
@@ -52,4 +62,4 void convert_averaged_spectral_matrix(vo
52 void fill_averaged_spectral_matrix( void );
62 void fill_averaged_spectral_matrix( void );
53 void reset_spectral_matrix_regs();
63 void reset_spectral_matrix_regs();
54
64
55 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
65 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,22 +1,36
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 "fsw_init.h"
4 #include <rtems.h>
5 #include <grspw.h>
6
7 #include <fcntl.h> // for O_RDWR
8 #include <unistd.h> // for the read call
9 #include <sys/ioctl.h> // for the ioctl call
10 #include <errno.h>
11
12 #include "fsw_params.h"
13 #include "tc_handler.h"
5
14
6 extern spw_stats spacewire_stats;
15 extern spw_stats spacewire_stats;
7 extern spw_stats spacewire_stats_backup;
16 extern spw_stats spacewire_stats_backup;
17 extern Packet_TM_LFR_HK_t housekeeping_packet;
18 extern rtems_id Task_id[20]; /* array of task ids */
8
19
9 // RTEMS TASK
20 // RTEMS TASK
10 rtems_task spiq_task(rtems_task_argument argument);
21 rtems_task spiq_task( rtems_task_argument argument );
22 rtems_task recv_task( rtems_task_argument unused );
23 rtems_task send_task( rtems_task_argument argument );
11
24
12 int spacewire_configure_link( void );
25 int spacewire_configure_link( void );
13 int spacewire_wait_for_link(void);
26 int spacewire_wait_for_link( void );
14 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
27 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
15 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
28 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
16 void spacewire_compute_stats_offsets(void);
29 void spacewire_compute_stats_offsets( void );
30 void spacewire_update_statistics( void );
17
31
18 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
32 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
19
33
20 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
34 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
21
35
22 #endif // FSW_SPACEWIRE_H_INCLUDED
36 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -1,5 +1,5
1 #ifndef GRLIBREGS_H_INCLUDED
1 #ifndef GRLIB_REGS_H_INCLUDED
2 #define GRLIBREGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
3
3
4 #define NB_GPTIMER 3
4 #define NB_GPTIMER 3
5
5
@@ -71,4 +71,4 struct spectral_matrix_regs_str{
71 };
71 };
72 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
72 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
73
73
74 #endif // GRLIBREGS_H_INCLUDED
74 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,9 +1,13
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 "fsw_init.h"
4 #include <rtems.h>
5 #include <leon.h>
6
5 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
6 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
7
11
8 // MODE PARAMETERS
12 // MODE PARAMETERS
9 extern struct param_sbm1_str param_sbm1;
13 extern struct param_sbm1_str param_sbm1;
@@ -11,33 +15,20 extern struct param_sbm2_str param_sbm2;
11 extern time_management_regs_t *time_management_regs;
15 extern time_management_regs_t *time_management_regs;
12 extern waveform_picker_regs_t *waveform_picker_regs;
16 extern waveform_picker_regs_t *waveform_picker_regs;
13 extern gptimer_regs_t *gptimer_regs;
17 extern gptimer_regs_t *gptimer_regs;
18 extern rtems_name misc_name[5];
19 extern rtems_id Task_id[20]; /* array of task ids */
20 extern unsigned char lfrCurrentMode;
21 extern unsigned int maxCount;
22
14
23
15 //****
24 //****
16 // ISR
25 // ISR
17 rtems_isr commutation_isr1( rtems_vector_number vector );
26 rtems_isr commutation_isr1( rtems_vector_number vector );
18 rtems_isr commutation_isr2( rtems_vector_number vector );
27 rtems_isr commutation_isr2( rtems_vector_number vector );
19
28
20 //**********************
21 // GENERAL USE FUNCTIONS
22 unsigned int Crc_opt( unsigned char D, unsigned int Chk);
23 void initLookUpTableForCRC( void );
24 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
25 void updateLFRCurrentMode();
26
27 //*********************
28 // ACCEPTANCE FUNCTIONS
29 int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_recv_id, rtems_id queue_send_id);
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 );
35
36 //***********
29 //***********
37 // RTEMS TASK
30 // RTEMS TASK
38 rtems_task recv_task( rtems_task_argument unused );
39 rtems_task actn_task( rtems_task_argument unused );
31 rtems_task actn_task( rtems_task_argument unused );
40 rtems_task dumb_task( rtems_task_argument unused );
41
32
42 //***********
33 //***********
43 // TC ACTIONS
34 // TC ACTIONS
@@ -61,6 +52,7 int restart_science_tasks();
61 int suspend_science_tasks();
52 int suspend_science_tasks();
62
53
63 // other functions
54 // other functions
55 void updateLFRCurrentMode();
64 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
56 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
65 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
57 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
66 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
@@ -1,7 +1,17
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
3
3
4 #include "tc_handler.h"
4 #include <rtems.h>
5 #include <stdio.h>
6
7 #include "fsw_params.h"
8 #include "wf_handler.h"
9 #include "tm_lfr_tc_exe.h"
10
11 extern int fdSPW;
12 extern unsigned char lfrCurrentMode;