##// END OF EJS Templates
Several bugs corrected on the TC handler (related TMs are now compliant)...
paul@pc-solar1.lab-lpp.local -
r3:a7739b90c971 default
parent child
Show More
@@ -12,6 +12,7
12 <Option type="1" />
12 <Option type="1" />
13 <Option compiler="sparc_rtems_gcc_compiler" />
13 <Option compiler="sparc_rtems_gcc_compiler" />
14 <Compiler>
14 <Compiler>
15 <Add option="-fexpensive-optimizations" />
15 <Add option="-O3" />
16 <Add option="-O3" />
16 <Add option="-g" />
17 <Add option="-g" />
17 <Add directory="../header" />
18 <Add directory="../header" />
@@ -34,9 +35,14
34 <Compiler>
35 <Compiler>
35 <Add option="-Wall" />
36 <Add option="-Wall" />
36 </Compiler>
37 </Compiler>
38 <Unit filename="../header/FSW-config.h" />
37 <Unit filename="../header/FSW-rtems-processing.h" />
39 <Unit filename="../header/FSW-rtems-processing.h" />
38 <Unit filename="../header/TC_handler.h" />
40 <Unit filename="../header/TC_handler.h" />
39 <Unit filename="../header/ccsds_types.h" />
41 <Unit filename="../header/ccsds_types.h" />
42 <Unit filename="../header/grlibregs.h" />
43 <Unit filename="../src/FSW-config.c">
44 <Option compilerVar="CC" />
45 </Unit>
40 <Unit filename="../src/FSW-rtems-processing.c">
46 <Unit filename="../src/FSW-rtems-processing.c">
41 <Option compilerVar="CC" />
47 <Option compilerVar="CC" />
42 </Unit>
48 </Unit>
@@ -41,16 +41,18 1354190602 source:e:\missions\solo\dev_p
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
42 <rtems.h>
42 <rtems.h>
43
43
44 1358144203 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
44 1359358276 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
45 <FSW-rtems-processing.h>
45 <FSW-rtems-processing.h>
46 <math.h>
46 <math.h>
47 <stdio.h>
47 <stdio.h>
48 <leon.h>
48 <leon.h>
49
49
50 1358144202 /opt/DEV_PLE/header/FSW-rtems-processing.h
50 1359358276 /opt/DEV_PLE/header/FSW-rtems-processing.h
51 <rtems.h>
51 <rtems.h>
52 <grlibregs.h>
53 <FSW-config.h>
52
54
53 1358441917 source:/opt/DEV_PLE/src/FSW-rtems.c
55 1359382800 source:/opt/DEV_PLE/src/FSW-rtems.c
54 <rtems.h>
56 <rtems.h>
55 <bsp.h>
57 <bsp.h>
56 <rtems/confdefs.h>
58 <rtems/confdefs.h>
@@ -60,20 +62,30 1358441917 source:/opt/DEV_PLE/src/FSW-r
60 <fcntl.h>
62 <fcntl.h>
61 <stdio.h>
63 <stdio.h>
62 <stdlib.h>
64 <stdlib.h>
63 <FSW-config.c>
64 <grspw.h>
65 <grspw.h>
65 <apbuart.h>
66 <apbuart.h>
67 <FSW-config.h>
66 <TC_handler.h>
68 <TC_handler.h>
67 <FSW-rtems-processing.h>
69 <FSW-rtems-processing.h>
70 <grlibregs.h>
68
71
69 1358144203 /opt/DEV_PLE/src/FSW-config.c
72 1358847387 /opt/DEV_PLE/src/FSW-config.c
70 <drvmgr/ambapp_bus.h>
73 <drvmgr/ambapp_bus.h>
71
74
72 1358441070 source:/opt/DEV_PLE/src/TC_handler.c
75 1359379052 source:/opt/DEV_PLE/src/TC_handler.c
73 <TC_handler.h>
76 <TC_handler.h>
77 <FSW-config.h>
74
78
75 1358435124 /opt/DEV_PLE/header/TC_handler.h
79 1359377846 /opt/DEV_PLE/header/TC_handler.h
80 <stdio.h>
76 <ccsds_types.h>
81 <ccsds_types.h>
77
82
78 1358440633 /opt/DEV_PLE/header/ccsds_types.h
83 1359372295 /opt/DEV_PLE/header/ccsds_types.h
84
85 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
86 <drvmgr/ambapp_bus.h>
79
87
88 1359371402 /opt/DEV_PLE/header/FSW-config.h
89
90 1358858576 /opt/DEV_PLE/header/grlibregs.h
91
@@ -1,22 +1,31
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_layout_file>
2 <CodeBlocks_layout_file>
3 <ActiveTarget name="Debug" />
3 <ActiveTarget name="Debug" />
4 <File name="../header/FSW-rtems-processing.h" open="0" top="0" tabpos="3">
4 <File name="../header/FSW-config.h" open="0" top="0" tabpos="0">
5 <Cursor position="82" topLine="0" />
5 <Cursor position="408" topLine="0" />
6 </File>
7 <File name="../header/FSW-rtems-processing.h" open="0" top="0" tabpos="4">
8 <Cursor position="230" topLine="0" />
9 </File>
10 <File name="../header/TC_handler.h" open="1" top="0" tabpos="5">
11 <Cursor position="107" topLine="0" />
6 </File>
12 </File>
7 <File name="../header/TC_handler.h" open="1" top="0" tabpos="2">
13 <File name="../header/ccsds_types.h" open="1" top="0" tabpos="4">
8 <Cursor position="352" topLine="0" />
14 <Cursor position="1571" topLine="40" />
9 </File>
15 </File>
10 <File name="../header/ccsds_types.h" open="1" top="0" tabpos="3">
16 <File name="../header/grlibregs.h" open="0" top="0" tabpos="6">
11 <Cursor position="1263" topLine="31" />
17 <Cursor position="262" topLine="1" />
18 </File>
19 <File name="../src/FSW-config.c" open="1" top="0" tabpos="3">
20 <Cursor position="274" topLine="0" />
12 </File>
21 </File>
13 <File name="../src/FSW-rtems-processing.c" open="0" top="0" tabpos="2">
22 <File name="../src/FSW-rtems-processing.c" open="0" top="0" tabpos="2">
14 <Cursor position="18" topLine="0" />
23 <Cursor position="18000" topLine="340" />
15 </File>
24 </File>
16 <File name="../src/FSW-rtems.c" open="1" top="1" tabpos="1">
25 <File name="../src/FSW-rtems.c" open="1" top="0" tabpos="1">
17 <Cursor position="91" topLine="0" />
26 <Cursor position="8119" topLine="99" />
18 </File>
27 </File>
19 <File name="../src/TC_handler.c" open="1" top="0" tabpos="4">
28 <File name="../src/TC_handler.c" open="1" top="1" tabpos="2">
20 <Cursor position="7237" topLine="36" />
29 <Cursor position="7593" topLine="53" />
21 </File>
30 </File>
22 </CodeBlocks_layout_file>
31 </CodeBlocks_layout_file>
@@ -1,13 +1,9
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5
5 #include <grlibregs.h>
6 #define ADDRESS_APB_SPECTRAL_MATRICES 0x80000700
6 #include <FSW-config.h>
7 #define LPP_SPECTRAL_MATRIX_CTRL 0x80000700
8 #define LPP_SPECTRAL_MATRIX_1 0x80000704
9 #define LPP_SPECTRAL_MATRIX_2 0x80000708
10 #define IRQ_SPECTRAL_MATRICES 12
11
7
12 #define NB_BINS_SPECTRAL_MATRIX 128
8 #define NB_BINS_SPECTRAL_MATRIX 128
13 #define NB_VALUES_PER_SPECTRAL_MATRIX 25
9 #define NB_VALUES_PER_SPECTRAL_MATRIX 25
@@ -16,12 +12,29
16 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f1 13
12 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f1 13
17 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f2 12
13 #define SIZE_COMPRESSED_SPECTRAL_MATRIX_f2 12
18 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX
14 #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX
19 #define NB_AVERAGE_NORMAL_f0 96*4
15 #define NB_AVERAGE_NORMAL_f0 96*4
20
16 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
21 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
17
18
19 struct BP1_str{
20 volatile unsigned char PE[2];
21 volatile unsigned char PB[2];
22 volatile unsigned char V0;
23 volatile unsigned char V1;
24 volatile unsigned char V2_ELLIP_DOP;
25 volatile unsigned char SZ;
26 volatile unsigned char VPHI;
27 };
28 typedef struct BP1_str BP1_t;
29
30 // ISR
31 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
32 // RTEMS TASKS
22 rtems_task spw_bppr_task(rtems_task_argument argument);
33 rtems_task spw_bppr_task(rtems_task_argument argument);
23 rtems_task spw_avf0_task(rtems_task_argument argument);
34 rtems_task spw_avf0_task(rtems_task_argument argument);
24 rtems_task spw_bpf0_task(rtems_task_argument argument);
35 rtems_task spw_bpf0_task(rtems_task_argument argument);
36 rtems_task spw_smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
37 //
25 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
38 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
26 void matrix_average(volatile int *spectral_matrix, float *averaged_spectral_matrix);
39 void matrix_average(volatile int *spectral_matrix, float *averaged_spectral_matrix);
27 void matrix_compression(float *averaged_spectral_matrix, unsigned char fChannel, float *compressed_spectral_matrix);
40 void matrix_compression(float *averaged_spectral_matrix, unsigned char fChannel, float *compressed_spectral_matrix);
@@ -1,22 +1,25
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 <ccsds_types.h>
4 #include <stdio.h>
5 #include <ccsds_types.h>
5
6
6 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
7 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
7 unsigned char currentTC_COMPUTED_CRC[2];
8 unsigned char currentTC_COMPUTED_CRC[2];
8 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
9 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
9 unsigned int currentTM_length;
10 unsigned int currentTM_length;
10 ccsdsTelemetryPacket_t currentTM;
11 ccsdsTelecommandPacket_t currentTC;
12 unsigned char currentTC_processedFlag;
11 unsigned char currentTC_processedFlag;
13
12
14 unsigned int lookUpTableForCRC[256];
13 unsigned int lookUpTableForCRC[256];
15 void InitLookUpTableForCRC();
14 void InitLookUpTableForCRC();
16 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
15 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
17
16
18 unsigned char TM_checker(ccsdsTelecommandPacket_t * TMPacket);
17 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
19 unsigned char TM_acceptance_generator(ccsdsTelecommandPacket_t * TCPacket, unsigned int code, ccsdsTelemetryPacket_t * TMPacket);
18
20 unsigned char TM_not_implemented_generator(ccsdsTelecommandPacket_t * TCPacket, ccsdsTelemetryPacket_t * TMPacket);
19 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
20 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
21 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
22 unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV,
23 TMHeader_t *TM_Header, unsigned int *hlen, char *data);
21
24
22 #endif // TC_HANDLER_H_INCLUDED
25 #endif // TC_HANDLER_H_INCLUDED
@@ -9,6 +9,8
9 #define CCSDS_PROCESS_ID 76
9 #define CCSDS_PROCESS_ID 76
10 #define CCSDS_PACKET_CATEGORY 12
10 #define CCSDS_PACKET_CATEGORY 12
11 #define CCSDS_DESTINATION_ID 0x21
11 #define CCSDS_DESTINATION_ID 0x21
12 #define CCSDS_PROTOCOLE_ID 0x02
13 #define CCSDS_USER_APP 0x00
12
14
13 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
15 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
14 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
16 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
@@ -28,11 +30,51
28 #define FAIL_DETECTED 40003
30 #define FAIL_DETECTED 40003
29 #define NOT_ALLOWED 40004
31 #define NOT_ALLOWED 40004
30 #define CORRUPTED 40005
32 #define CORRUPTED 40005
31 //
33 //
32 #define CCSDS_ERR_SRC 8
34 #define SID_TC_RESET 3
33 #define CCSDS_ERR_CAT 9
35 #define SID_TC_LOAD_COMM 20
34
36 #define SID_TC_LOAD_NORM 21
35 struct ccsdsTelemetryPacket_str
37 #define SID_TC_LOAD_BURST 24
38 #define SID_TC_LOAD_SBM1 27
39 #define SID_TC_LOAD_SBM2 28
40 #define SID_TC_DUMP 30
41 #define SID_TC_ENTER 40
42 #define SID_TC_UPDT_INFO 50
43 #define SID_TC_EN_CAL 60
44 #define SID_TC_DIS_CAL 61
45 #define SID_TC_UPDT_TIME 129
46
47 #define SID_DEFAULT 0
48 #define SID_EXE_INC 5
49 #define SID_NOT_EXE 40000
50 #define SID_NOT_IMP 40002
51 #define SID_EXE_ERR 40003
52 #define SID_EXE_CORR 40005
53
54 #define SID_NORM_SWF_F0 3
55 #define SID_NORM_SWF_F1 4
56 #define SID_NORM_SWF_F2 5
57 #define SID_NORM_CWF_F3 1
58
59 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
60 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
61 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
62 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
63 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
64 #define TM_HEADER_LEN 16
65 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
66 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
67
68 enum TM_TYPE{
69 TM_LFR_TC_EXE_OK,
70 TM_LFR_TC_EXE_ERR,
71 TM_LFR_HK,
72 TM_LFR_SCI,
73 TM_LFR_SCI_SBM,
74 TM_LFR_PAR_DUMP
75 };
76
77 struct TMHeader_str
36 {
78 {
37 volatile unsigned char targetLogicalAddress;
79 volatile unsigned char targetLogicalAddress;
38 volatile unsigned char protocolIdentifier;
80 volatile unsigned char protocolIdentifier;
@@ -41,14 +83,27 struct ccsdsTelemetryPacket_str
41 volatile unsigned char packetID[2];
83 volatile unsigned char packetID[2];
42 volatile unsigned char packetSequenceControl[2];
84 volatile unsigned char packetSequenceControl[2];
43 volatile unsigned char packetLength[2];
85 volatile unsigned char packetLength[2];
86 volatile unsigned char dataFieldHeader[10];
87 };
88 typedef struct TMHeader_str TMHeader_t;
89
90 struct ExtendedTMHeader_str
91 {
92 volatile unsigned char targetLogicalAddress;
93 volatile unsigned char protocolIdentifier;
94 volatile unsigned char reserved;
95 volatile unsigned char userApplication;
96 volatile unsigned char packetID[2];
97 volatile unsigned char packetSequenceControl[2];
98 volatile unsigned char packetLength[2];
44 volatile unsigned char dataFieldHeader[10];
99 volatile unsigned char dataFieldHeader[10];
45 volatile unsigned char data[CCSDS_TM_PKT_MAX_SIZE-16];
100 volatile unsigned char auxiliaryHeader[6];
46 };
101 };
47 typedef struct ccsdsTelemetryPacket_str ccsdsTelemetryPacket_t;
102 typedef struct ExtendedTMHeader_str ExtendedTMHeader_t;
48
103
49 struct ccsdsTelecommandPacket_str
104 struct ccsdsTelecommandPacket_str
50 {
105 {
51 //unsigned char targetLogicalAddress;
106 //unsigned char targetLogicalAddress; // removed by the grspw module
52 volatile unsigned char protocolIdentifier;
107 volatile unsigned char protocolIdentifier;
53 volatile unsigned char reserved;
108 volatile unsigned char reserved;
54 volatile unsigned char userApplication;
109 volatile unsigned char userApplication;
@@ -4,8 +4,8
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)48+4}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)10}},
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+6}}, // 6 is for the auxiliary header, when needed
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 KEY_EMPTY
10 KEY_EMPTY
11 };
11 };
@@ -41,23 +41,39 volatile int spectral_matrix_f0_g[TOTAL_
41 volatile int spectral_matrix_f0_h[TOTAL_SIZE_SPECTRAL_MATRIX];
41 volatile int spectral_matrix_f0_h[TOTAL_SIZE_SPECTRAL_MATRIX];
42 float averaged_spectral_matrix_f0[TOTAL_SIZE_SPECTRAL_MATRIX];
42 float averaged_spectral_matrix_f0[TOTAL_SIZE_SPECTRAL_MATRIX];
43 float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0];
43 float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0];
44 unsigned char LFR_BP1_F0[NB_BINS_COMPRESSED_MATRIX_f0*9];
44 unsigned char LFR_BP1_F0[NB_BINS_COMPRESSED_MATRIX_f0*9];
45
46 BP1_t data_BP1[NB_BINS_COMPRESSED_MATRIX_f0];
45
47
46 extern rtems_id Task_id[]; /* array of task ids */
48 extern rtems_id Task_id[]; /* array of task ids */
47
49
48 struct spectral_matrices_regs_str{
50 spectral_matrices_regs_t *spectral_matrices_regs;
49 volatile int ctrl;
50 volatile int address0;
51 volatile int address1;
52 };
53 struct spectral_matrices_regs_str *spectral_matrices_regs;
54
51
55 // Interrupt Service Routine for spectral matrices processing
52 // Interrupt Service Routine for spectral matrices processing
56 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
53 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
57 {
54 {
58 if (rtems_event_send( Task_id[4], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
55 if (rtems_event_send( Task_id[4], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
59 printf("In spectral_matrices_isr *** Error sending event to BPPR\n");
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
60 }
57 }
58
59 rtems_task spw_smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
60 {
61 rtems_event_set event_out;
62 gptimer_regs_t *gptimer_regs;
63 gptimer_regs = (gptimer_regs_t *) REGS_ADDRESS_GPTIMER;
64 unsigned char nb_interrupt_f0 = 0;
65
66 while(1){
67 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
71 printf("In spw_smiq_task *** Error sending event to AVF0\n");
72 nb_interrupt_f0 = 0;
73 }
74 gptimer_regs->timer2_ctrl = gptimer_regs->timer2_ctrl | 0x00000010;
75 }
76 }
61
77
62 rtems_task spw_bppr_task(rtems_task_argument argument)
78 rtems_task spw_bppr_task(rtems_task_argument argument)
63 {
79 {
@@ -69,7 +85,7 rtems_task spw_bppr_task(rtems_task_argu
69
85
70 while(1)
86 while(1)
71
87
72 spectral_matrices_regs = (struct spectral_matrices_regs_str *) ADDRESS_APB_SPECTRAL_MATRICES;
88 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDRESS_SPECTRAL_MATRICES;
73 spectral_matrices_regs->address0 = (volatile int) spectral_matrix_f0_a;
89 spectral_matrices_regs->address0 = (volatile int) spectral_matrix_f0_a;
74 spectral_matrices_regs->address1 = (volatile int) spectral_matrix_f0_b;
90 spectral_matrices_regs->address1 = (volatile int) spectral_matrix_f0_b;
75
91
@@ -313,8 +329,57 void BP2_set(float * compressed_spectral
313 }
329 }
314 }
330 }
315
331
332 rtems_task spw_avf0_task(rtems_task_argument argument){
333 int i;
334 static int nb_average;
335 rtems_event_set event_out;
336 rtems_status_code status;
337
338 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDRESS_SPECTRAL_MATRICES;
339 spectral_matrices_regs->address0 = (volatile int) spectral_matrix_f0_a;
340 spectral_matrices_regs->address1 = (volatile int) spectral_matrix_f0_b;
341
342 nb_average = 0;
343
344 PRINTF("In AVFO *** \n")
345
346 while(1){
347 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
348 for(i=0; i<TOTAL_SIZE_SPECTRAL_MATRIX; i++){
349 averaged_spectral_matrix_f0[i] = averaged_spectral_matrix_f0[i] + spectral_matrix_f0_a[i]
350 + spectral_matrix_f0_b[i]
351 + spectral_matrix_f0_c[i]
352 + spectral_matrix_f0_d[i]
353 + spectral_matrix_f0_e[i]
354 + spectral_matrix_f0_f[i]
355 + spectral_matrix_f0_g[i]
356 + spectral_matrix_f0_h[i];
357 }
358 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
359 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
360 if (nb_average == NB_AVERAGE_NORMAL_f0) {
361 nb_average = 0;
362 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
363 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
364 }
365 }
366 }
367
368 rtems_task spw_bpf0_task(rtems_task_argument argument){
369 rtems_event_set event_out;
370
371 while(1){
372 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
373 matrix_compression(averaged_spectral_matrix_f0, 0, compressed_spectral_matrix_f0);
374 BP1_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
375 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
376 }
377 }
378
379 //*******
380 // UNUSED
316 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
381 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
317 {
382 {/*
318 rtems_status_code status;
383 rtems_status_code status;
319 //static int nb_average_f1 = 0;
384 //static int nb_average_f1 = 0;
320 //static int nb_average_f2 = 0;
385 //static int nb_average_f2 = 0;
@@ -328,7 +393,7 rtems_task spw_bppr_task_rate_monotonic(
328 //exit( 1 );
393 //exit( 1 );
329 }
394 }
330
395
331 spectral_matrices_regs = (struct spectral_matrices_regs_str *) ADDRESS_APB_SPECTRAL_MATRICES;
396 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDRESS_SPECTRAL_MATRICES;
332 spectral_matrices_regs->address0 = (volatile int) spectral_matrix_f0_a;
397 spectral_matrices_regs->address0 = (volatile int) spectral_matrix_f0_a;
333 spectral_matrices_regs->address1 = (volatile int) spectral_matrix_f0_b;
398 spectral_matrices_regs->address1 = (volatile int) spectral_matrix_f0_b;
334
399
@@ -348,50 +413,11 rtems_task spw_bppr_task_rate_monotonic(
348 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
413 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
349 //exit( 1 );
414 //exit( 1 );
350 }
415 }
351 status = rtems_task_delete( RTEMS_SELF ); /* should not return */
416 status = rtems_task_delete( RTEMS_SELF ); // should not return
352 printf( "rtems_task_delete returned with status of %d.\n", status );
417 printf( "rtems_task_delete returned with status of %d.\n", status );
353 //exit( 1 );
418 //exit( 1 );*/
354 }
419 }
355
420
356 rtems_task spw_avf0_task(rtems_task_argument argument){
421
357 int i;
422
358 static int nb_average;
359 rtems_event_set event_out;
360 rtems_status_code status;
361
362 nb_average = 0;
363
423
364 while(1){
365 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
366 for(i=0; i<TOTAL_SIZE_SPECTRAL_MATRIX; i++){
367 averaged_spectral_matrix_f0[i] = averaged_spectral_matrix_f0[i] + spectral_matrix_f0_a[i]
368 + spectral_matrix_f0_b[i]
369 + spectral_matrix_f0_c[i]
370 + spectral_matrix_f0_d[i]
371 + spectral_matrix_f0_e[i]
372 + spectral_matrix_f0_f[i]
373 + spectral_matrix_f0_g[i]
374 + spectral_matrix_f0_h[i];
375 }
376 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
377 nb_average = nb_average + 8;
378 if (nb_average == NB_AVERAGE_NORMAL_f0) {
379 nb_average = 0;
380 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
381 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
382 }
383 }
384 }
385
386 rtems_task spw_bpf0_task(rtems_task_argument argument){
387 rtems_event_set event_out;
388
389 while(1){
390 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
391 matrix_compression(averaged_spectral_matrix_f0, 0, compressed_spectral_matrix_f0);
392 BP1_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
393 printf("IN TASK BPF0 *** Matrix compressed, parameters calculated\n");
394 }
395 }
396
397
This diff has been collapsed as it changes many lines, (579 lines changed) Show them Hide them
@@ -2,17 +2,6
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 //#define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
6 #ifdef PRINT_MESSAGES_ON_CONSOLE
7 #define PRINTF(x) printf(x);
8 #define PRINTF1(x,y) printf(x,y);
9 #define PRINTF2(x,y,z) printf(x,y,z);
10 #else
11 #define PRINTF(x) ;
12 #define PRINTF1(x,y) ;
13 #define PRINTF2(x,y,z) ;
14 #endif
15
16 #define OFFSET_COARSE_TIME 4+10-1 // -1 => the receiver suppresses the target logical address
5 #define OFFSET_COARSE_TIME 4+10-1 // -1 => the receiver suppresses the target logical address
17 #define OFFSET_FINE_TIME OFFSET_COARSE_TIME+4
6 #define OFFSET_FINE_TIME OFFSET_COARSE_TIME+4
18 #define TC_FIFO_SIZE 5
7 #define TC_FIFO_SIZE 5
@@ -67,32 +56,33
67 #include <stdio.h>
56 #include <stdio.h>
68 #include <stdlib.h>
57 #include <stdlib.h>
69
58
70 #include <FSW-config.c>
59 //#include <FSW-config.c>
71 #include <grspw.h>
60 #include <grspw.h>
72 #include <apbuart.h>
61 #include <apbuart.h>
62 #include <FSW-config.h>
73 #include <TC_handler.h>
63 #include <TC_handler.h>
74 #include <FSW-rtems-processing.h>
64 #include <FSW-rtems-processing.h>
65 #include <grlibregs.h>
75
66
76 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
67 /*char *tmGeneratorMsg[2] = { "NOTHING_TO_DO",
77 "WRONG_LEN_PACKET 1",
68 "TM_GENERATED"
78 "INCOR_CHECKSUM 2",
69 };*/
79 "ILL_TYPE 3",
80 "ILL_SUBTYPE 4",
81 "WRONG_APP_DATA 5",
82 "WRONG_CMD_CODE 6",
83 "CCSDS_TM_VALID 7"
84 };
85
70
86 char *tmGeneratorMsg[2] = { "NOTHING_TO_DO",
71 // RTEMS TASKS
87 "TM_GENERATED"
88 };
89
90 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
72 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
91 rtems_task spw_recv_task(rtems_task_argument argument);
73 rtems_task spw_recv_task(rtems_task_argument argument);
92 rtems_task spw_tcck_task(rtems_task_argument argument);
93 rtems_task spw_spiq_task(rtems_task_argument argument);
74 rtems_task spw_spiq_task(rtems_task_argument argument);
94 rtems_task spw_stat_task(rtems_task_argument argument);
75 rtems_task spw_stat_task(rtems_task_argument argument);
95 int configure_spw_link();
76 rtems_task spw_wfrm_task(rtems_task_argument argument);
77 // ISR
78 rtems_isr waveforms_isr( rtems_vector_number vector );
79
80 int send_console_outputs_on_serial_port();
81 int create_all_tasks();
82 int start_all_tasks();
83 int configure_spw_link();
84 int configure_timer_for_sm_simulation();
85 int configure_timer_for_wf_simulation();
96 extern int rtems_cpu_usage_report();
86 extern int rtems_cpu_usage_report();
97 extern int rtems_cpu_usage_reset();
87 extern int rtems_cpu_usage_reset();
98
88
@@ -109,45 +99,224 char *lstates[6] = {"Error-reset",
109 "Run"
99 "Run"
110 };
100 };
111
101
112 struct tc_fifo_str{
113 struct tc_fifo_str *next;
114 unsigned char *tc_pkt;
115 unsigned int tc_pktlength;
116 unsigned char ready;
117 };
118 struct tc_fifo_str tc_fifo[TC_FIFO_SIZE];
119 struct tc_fifo_str *tc_being_processed;
120 struct tc_fifo_str *tc_pending_reception;
121
122 struct apbuart_regs_str{
123 volatile unsigned int data;
124 volatile unsigned int status;
125 volatile unsigned int ctrl;
126 volatile unsigned int scaler;
127 volatile unsigned int fifoDebug;
128 };
129
130 int fdSPW;
102 int fdSPW;
131 int fdUART;
103 int fdUART;
132
104
133 rtems_id Task_id[10]; /* array of task ids */
105 rtems_id Task_id[10]; /* array of task ids */
134 rtems_name Task_name[10]; /* array of task names */
106 rtems_name Task_name[10]; /* array of task names */
135 rtems_name sem_tc_fifo_name;
136 rtems_id sem_tc_fifo_id;
137
107
138 rtems_task Init( rtems_task_argument ignored ) {
108 rtems_task Init( rtems_task_argument ignored ) {
139 rtems_status_code status;
109 rtems_status_code status;
140 //struct apbuart_regs_str *apbuart_regs;
110
141 rtems_isr_entry old_isr_handler;
111 send_console_outputs_on_serial_port();
112
113 create_all_tasks();
114 start_all_tasks();
115
116 configure_spw_link();
117 configure_timer_for_sm_simulation();
118 configure_timer_for_wf_simulation();
119
120 InitLookUpTableForCRC(); // in TC_handler.h
121
122 status = rtems_task_delete(RTEMS_SELF);
123 }
124
125 rtems_task spw_recv_task( rtems_task_argument unused ) {
126 rtems_status_code status;
127 int len = 0;
128 unsigned int i = 0;
129 unsigned int data_length = 0;
130 ccsdsTelecommandPacket_t currentTC;
131 spw_ioctl_pkt_send spw_ioctl_send;
132 TMHeader_t TM_header;
133 char data[100];
134
135 for(i=0; i<100; i++) data[i] = 0;
136
137 PRINTF("In RECV *** \n")
138
139 while(1){
140 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
141 if (len == -1){ // error during the read call
142 PRINTF("In RECV *** last read call returned -1\n")
143 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
144 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
145 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
146 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
147 }
148 else {
149 //PRINTF1("In RECV *** Got Message of length %d\n", len)
150 currentTC_LEN_RCV[0] = 0x00;
151 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
152 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
153 // CHECK THE TC AND BUILD THE APPROPRIATE TM
154 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt,
155 &TM_header, &spw_ioctl_send.hlen, data);
156 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
157 spw_ioctl_send.hdr = (char*) &TM_header;
158 spw_ioctl_send.dlen = data_length;
159 spw_ioctl_send.data = data;
160 //printf("hlen %d, dlen %d\n", spw_ioctl_send.hlen, spw_ioctl_send.dlen);
161 // SEND PACKET
162 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
163 if (status!=RTEMS_SUCCESSFUL) printf("In TC_checker *** Error SPACEWIRE_IOCTRL_SEND\n");
164 //PRINTF1("In TC_checker *** packet of size %d sent\n", spw_ioctl_send.sent)
165 }
166 }
167
168 close(fdSPW);
169 }
170
171 rtems_task spw_spiq_task(rtems_task_argument unused){
172 rtems_event_set event_out;
173 struct grspw_regs_str *grspw_regs;
174 grspw_regs = (struct grspw_regs_str *) ADDRESS_GRSPW_REGISTERS;
175
176 while(1){
177 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
178 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
179
180 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
181 PRINTF("In SPIQ *** Error suspending RECV Task\n")
182
183 configure_spw_link();
142
184
185 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
186 PRINTF("In SPIQ *** Error resume RECV Task\n")
187 }
188 }
189
190 rtems_isr waveforms_isr( rtems_vector_number vector )
191 {
192 if (rtems_event_send( Task_id[8], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
193 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
194 }
195
196 rtems_task spw_wfrm_task(rtems_task_argument argument)
197 {
198 unsigned int length;
199 unsigned int i = 0;
200 rtems_status_code status;
201 spw_ioctl_pkt_send spw_ioctl_send;
202 rtems_event_set event_out;
203 gptimer_regs_t *gptimer_regs;
204 gptimer_regs = (gptimer_regs_t *) REGS_ADDRESS_GPTIMER;
205 ExtendedTMHeader_t header;
206
207 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
208 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
209 header.reserved = 0x00;
210 header.userApplication = CCSDS_USER_APP;
211 header.packetID[0] = 0x0c;
212 header.packetID[1] = 0xcc;
213 header.packetSequenceControl[0] = 0x00;
214 header.packetSequenceControl[1] = 0x00;
215 header.packetLength[0] = 0x00;
216 header.packetLength[1] = 0x00;
217 header.dataFieldHeader[0] = 0x10;
218 header.dataFieldHeader[1] = 0x15; // service type
219 header.dataFieldHeader[2] = 0x03; // service subtype
220 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
221 header.dataFieldHeader[4] = 0xaa;
222 header.dataFieldHeader[5] = 0xbb;
223 header.dataFieldHeader[6] = 0xcc;
224 header.dataFieldHeader[7] = 0xdd;
225 header.dataFieldHeader[8] = 0xee;
226 header.dataFieldHeader[9] = 0xff;
227
228 header.auxiliaryHeader[0] = 0x00;
229 header.auxiliaryHeader[1] = 0x1f;
230 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
231 header.auxiliaryHeader[3] = 0x00; // PKT_NR
232 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
233 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
234
235 // BUILD THE PACKET HEADER
236 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
237 spw_ioctl_send.hdr = (char*) &header;
238
239 while(1){
240 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
241 for (i=0; i<7; i++) // send F0
242 {
243 // BUILD THE DATA
244 if (i==6) {
245 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
246 length = TM_LEN_SCI_NORM_SWF_340;
247 }
248 else {
249 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
250 length = TM_LEN_SCI_NORM_SWF_8;
251 }
252 spw_ioctl_send.data = (char*) &waveform_snapshot_f0[i * 340 * NB_BYTES_SWF_BLK];
253 // BUILD THE HEADER
254 header.packetLength[0] = (unsigned char) (length>>8);
255 header.packetLength[1] = (unsigned char) (length);
256 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
257 // SEND PACKET
258 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
259 if (status!=RTEMS_SUCCESSFUL) printf("In WFRM *** Error SPACEWIRE_IOCTRL_SEND\n");
260 //sched_yield();
261 }
262 for (i=0; i<7; i++) // send F1
263 {
264 // BUILD THE DATA
265 if (i==6) {
266 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
267 length = TM_LEN_SCI_NORM_SWF_340;
268 }
269 else {
270 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
271 length = TM_LEN_SCI_NORM_SWF_8;
272 }
273 spw_ioctl_send.data = (char*) &waveform_snapshot_f1[i * 340 * NB_BYTES_SWF_BLK];
274 // BUILD THE HEADER
275 header.packetLength[0] = (unsigned char) (length>>8);