##// END OF EJS Templates
Integration of basic parameters functions in the flight software...
paul -
r179:f0fdfd2b8c4c VHDL_0_1_28
parent child
Show More
@@ -0,0 +1,191
1 # This file was generated by an application wizard of Qt Creator.
2 # The code below handles deployment to Android and Maemo, aswell as copying
3 # of the application data to shadow build directories on desktop.
4 # It is recommended not to modify this file, since newer versions of Qt Creator
5 # may offer an updated version of it.
6
7 defineTest(qtcAddDeployment) {
8 for(deploymentfolder, DEPLOYMENTFOLDERS) {
9 item = item$${deploymentfolder}
10 greaterThan(QT_MAJOR_VERSION, 4) {
11 itemsources = $${item}.files
12 } else {
13 itemsources = $${item}.sources
14 }
15 $$itemsources = $$eval($${deploymentfolder}.source)
16 itempath = $${item}.path
17 $$itempath= $$eval($${deploymentfolder}.target)
18 export($$itemsources)
19 export($$itempath)
20 DEPLOYMENT += $$item
21 }
22
23 MAINPROFILEPWD = $$PWD
24
25 android-no-sdk {
26 for(deploymentfolder, DEPLOYMENTFOLDERS) {
27 item = item$${deploymentfolder}
28 itemfiles = $${item}.files
29 $$itemfiles = $$eval($${deploymentfolder}.source)
30 itempath = $${item}.path
31 $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
32 export($$itemfiles)
33 export($$itempath)
34 INSTALLS += $$item
35 }
36
37 target.path = /data/user/qt
38
39 export(target.path)
40 INSTALLS += target
41 } else:android {
42 for(deploymentfolder, DEPLOYMENTFOLDERS) {
43 item = item$${deploymentfolder}
44 itemfiles = $${item}.files
45 $$itemfiles = $$eval($${deploymentfolder}.source)
46 itempath = $${item}.path
47 $$itempath = /assets/$$eval($${deploymentfolder}.target)
48 export($$itemfiles)
49 export($$itempath)
50 INSTALLS += $$item
51 }
52
53 x86 {
54 target.path = /libs/x86
55 } else: armeabi-v7a {
56 target.path = /libs/armeabi-v7a
57 } else {
58 target.path = /libs/armeabi
59 }
60
61 export(target.path)
62 INSTALLS += target
63 } else:win32 {
64 copyCommand =
65 for(deploymentfolder, DEPLOYMENTFOLDERS) {
66 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
67 source = $$replace(source, /, \\)
68 sourcePathSegments = $$split(source, \\)
69 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
70 target = $$replace(target, /, \\)
71 target ~= s,\\\\\\.?\\\\,\\,
72 !isEqual(source,$$target) {
73 !isEmpty(copyCommand):copyCommand += &&
74 isEqual(QMAKE_DIR_SEP, \\) {
75 copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
76 } else {
77 source = $$replace(source, \\\\, /)
78 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
79 target = $$replace(target, \\\\, /)
80 copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
81 }
82 }
83 }
84 !isEmpty(copyCommand) {
85 copyCommand = @echo Copying application data... && $$copyCommand
86 copydeploymentfolders.commands = $$copyCommand
87 first.depends = $(first) copydeploymentfolders
88 export(first.depends)
89 export(copydeploymentfolders.commands)
90 QMAKE_EXTRA_TARGETS += first copydeploymentfolders
91 }
92 } else:ios {
93 copyCommand =
94 for(deploymentfolder, DEPLOYMENTFOLDERS) {
95 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
96 source = $$replace(source, \\\\, /)
97 target = $CODESIGNING_FOLDER_PATH/$$eval($${deploymentfolder}.target)
98 target = $$replace(target, \\\\, /)
99 sourcePathSegments = $$split(source, /)
100 targetFullPath = $$target/$$last(sourcePathSegments)
101 targetFullPath ~= s,/\\.?/,/,
102 !isEqual(source,$$targetFullPath) {
103 !isEmpty(copyCommand):copyCommand += &&
104 copyCommand += mkdir -p \"$$target\"
105 copyCommand += && cp -r \"$$source\" \"$$target\"
106 }
107 }
108 !isEmpty(copyCommand) {
109 copyCommand = echo Copying application data... && $$copyCommand
110 !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
111 QMAKE_POST_LINK += "$$copyCommand"
112 export(QMAKE_POST_LINK)
113 }
114 } else:unix {
115 maemo5 {
116 desktopfile.files = $${TARGET}.desktop
117 desktopfile.path = /usr/share/applications/hildon
118 icon.files = $${TARGET}64.png
119 icon.path = /usr/share/icons/hicolor/64x64/apps
120 } else:!isEmpty(MEEGO_VERSION_MAJOR) {
121 desktopfile.files = $${TARGET}_harmattan.desktop
122 desktopfile.path = /usr/share/applications
123 icon.files = $${TARGET}80.png
124 icon.path = /usr/share/icons/hicolor/80x80/apps
125 } else { # Assumed to be a Desktop Unix
126 copyCommand =
127 for(deploymentfolder, DEPLOYMENTFOLDERS) {
128 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
129 source = $$replace(source, \\\\, /)
130 macx {
131 target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
132 } else {
133 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
134 }
135 target = $$replace(target, \\\\, /)
136 sourcePathSegments = $$split(source, /)
137 targetFullPath = $$target/$$last(sourcePathSegments)
138 targetFullPath ~= s,/\\.?/,/,
139 !isEqual(source,$$targetFullPath) {
140 !isEmpty(copyCommand):copyCommand += &&
141 copyCommand += $(MKDIR) \"$$target\"
142 copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
143 }
144 }
145 !isEmpty(copyCommand) {
146 copyCommand = @echo Copying application data... && $$copyCommand
147 copydeploymentfolders.commands = $$copyCommand
148 first.depends = $(first) copydeploymentfolders
149 export(first.depends)
150 export(copydeploymentfolders.commands)
151 QMAKE_EXTRA_TARGETS += first copydeploymentfolders
152 }
153 }
154 !isEmpty(target.path) {
155 installPrefix = $${target.path}
156 } else {
157 installPrefix = /opt/$${TARGET}
158 }
159 for(deploymentfolder, DEPLOYMENTFOLDERS) {
160 item = item$${deploymentfolder}
161 itemfiles = $${item}.files
162 $$itemfiles = $$eval($${deploymentfolder}.source)
163 itempath = $${item}.path
164 $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
165 export($$itemfiles)
166 export($$itempath)
167 INSTALLS += $$item
168 }
169
170 !isEmpty(desktopfile.path) {
171 export(icon.files)
172 export(icon.path)
173 export(desktopfile.files)
174 export(desktopfile.path)
175 INSTALLS += icon desktopfile
176 }
177
178 isEmpty(target.path) {
179 target.path = $${installPrefix}/bin
180 export(target.path)
181 }
182 INSTALLS += target
183 }
184
185 export (ICON)
186 export (INSTALLS)
187 export (DEPLOYMENT)
188 export (LIBS)
189 export (QMAKE_EXTRA_TARGETS)
190 }
191
@@ -0,0 +1,13
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 SOURCES += main.c
7
8 include(deployment.pri)
9 qtcAddDeployment()
10
11 HEADERS += \
12 functions.h
13
@@ -0,0 +1,65
1 #define NB_VALUES_PER_SM 25
2 #define NB_BINS_PER_SM 128
3
4 #define NB_BINS_COMPRESSED_SM_F0 11
5 #define ASM_F0_INDICE_START 17 // 88 bins
6 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
7 #define NB_BINS_TO_AVERAGE_ASM_F0 8
8
9 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
10 {
11 int frequencyBin;
12 int asmComponent;
13 unsigned int offsetASM;
14 unsigned int offsetASMReorganized;
15
16 // BUILD DATA
17 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
18 {
19 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
20 {
21 offsetASMReorganized =
22 frequencyBin * NB_VALUES_PER_SM
23 + asmComponent;
24 offsetASM =
25 asmComponent * NB_BINS_PER_SM
26 + frequencyBin;
27 averaged_spec_mat_reorganized[offsetASMReorganized ] =
28 averaged_spec_mat[ offsetASM ] / divider;
29 }
30 }
31 }
32
33 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
34 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
35 {
36 int frequencyBin;
37 int asmComponent;
38 int offsetASM;
39 int offsetCompressed;
40 int k;
41
42 // BUILD DATA
43 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
44 {
45 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
46 {
47 offsetCompressed = // NO TIME OFFSET
48 frequencyBin * NB_VALUES_PER_SM
49 + asmComponent;
50 offsetASM = // NO TIME OFFSET
51 asmComponent * NB_BINS_PER_SM
52 + ASMIndexStart
53 + frequencyBin * nbBinsToAverage;
54 compressed_spec_mat[ offsetCompressed ] = 0;
55 for ( k = 0; k < nbBinsToAverage; k++ )
56 {
57 compressed_spec_mat[offsetCompressed ] =
58 ( compressed_spec_mat[ offsetCompressed ]
59 + averaged_spec_mat[ offsetASM + k ] );
60 }
61 compressed_spec_mat[ offsetCompressed ] =
62 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
63 }
64 }
65 }
@@ -0,0 +1,64
1 #include <stdio.h>
2
3 #include "functions.h"
4
5 int main(void)
6 {
7 printf("Hello World!\n");
8
9 unsigned int asmComponent;
10 unsigned int frequencyBin;
11 unsigned int offset_input_ASM;
12
13 float input_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
14 float output_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
15 float output_ASM_compressed [ NB_VALUES_PER_SM * NB_BINS_COMPRESSED_SM_F0 ];
16
17 //*******
18 // TEST 1
19
20 offset_input_ASM = 0;
21
22 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
23 {
24 for (frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++)
25 {
26 offset_input_ASM = asmComponent * NB_BINS_PER_SM + frequencyBin;
27 input_ASM[ offset_input_ASM ] = asmComponent;
28 }
29 }
30
31 ASM_reorganize_and_divide( input_ASM, output_ASM,
32 1 ); // divider
33
34 ASM_compress_reorganize_and_divide( input_ASM, output_ASM_compressed,
35 1, // divider
36 NB_BINS_COMPRESSED_SM_F0,
37 NB_BINS_TO_AVERAGE_ASM_F0,
38 ASM_F0_INDICE_START);
39
40 //*******
41 // TEST 2
42 offset_input_ASM = 0;
43
44 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
45 {
46 for (frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++)
47 {
48 offset_input_ASM = asmComponent * NB_BINS_PER_SM + frequencyBin;
49 input_ASM[ offset_input_ASM ] = asmComponent * NB_BINS_PER_SM + frequencyBin;
50 }
51 }
52
53 ASM_reorganize_and_divide( input_ASM, output_ASM,
54 1 ); // divider
55
56 ASM_compress_reorganize_and_divide( input_ASM, output_ASM_compressed,
57 10, // divider
58 NB_BINS_COMPRESSED_SM_F0,
59 NB_BINS_TO_AVERAGE_ASM_F0,
60 ASM_F0_INDICE_START);
61
62 return 0;
63 }
64
@@ -1,2 +1,2
1 19349b3a5e90c2bacc9d369aa948c68aa9e8d5f0 LFR_basic-parameters
2 da5613aff4446e5c98b3c56bc32ce7008b3e2340 header/lfr_common_headers
1 a309a930a482e851061936696121f4a1cf7005de LFR_basic-parameters
2 2b5dc338fb623046072d6eb98c26ad884e17f95e header/lfr_common_headers
@@ -12,7 +12,7 SWVERSION=-1-0
12 12 DEFINES += SW_VERSION_N1=2 # major
13 13 DEFINES += SW_VERSION_N2=0 # minor
14 14 DEFINES += SW_VERSION_N3=2 # patch
15 DEFINES += SW_VERSION_N4=0 # internal
15 DEFINES += SW_VERSION_N4=1 # internal
16 16
17 17 # <GCOV>
18 18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
@@ -28,6 +28,7 contains( CONFIG, lpp_dpu_destid ) {
28 28 contains( CONFIG, debug_tch ) {
29 29 DEFINES += DEBUG_TCH
30 30 }
31 DEFINES += LSB_FIRST_TCH
31 32
32 33 contains( CONFIG, vhdl_dev ) {
33 34 DEFINES += VHDL_DEV
@@ -64,7 +65,7 INCLUDEPATH += \
64 65 $${PWD}/../header \
65 66 $${PWD}/../header/lfr_common_headers \
66 67 $${PWD}/../header/processing \
67 $${PWD}/../src/LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
68 69
69 70 SOURCES += \
70 71 ../src/wf_handler.c \
@@ -81,7 +82,7 SOURCES += \
81 82 ../src/processing/avf1_prc1.c \
82 83 ../src/processing/avf2_prc2.c \
83 84 ../src/lfr_cpu_usage_report.c \
84 ../src/LFR_basic-parameters/basic_parameters.c
85 ../LFR_basic-parameters/basic_parameters.c
85 86
86 87 HEADERS += \
87 88 ../header/wf_handler.h \
@@ -99,12 +100,12 HEADERS += \
99 100 ../header/processing/avf2_prc2.h \
100 101 ../header/fsw_params_wf_handler.h \
101 102 ../header/lfr_cpu_usage_report.h \
102 ../src/LFR_basic-parameters/basic_parameters.h \
103 ../src/LFR_basic-parameters/basic_parameters_params.h \
104 103 ../header/lfr_common_headers/ccsds_types.h \
105 104 ../header/lfr_common_headers/fsw_params.h \
106 105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
107 106 ../header/lfr_common_headers/fsw_params_processing.h \
108 107 ../header/lfr_common_headers/TC_types.h \
109 ../header/lfr_common_headers/tm_byte_positions.h
108 ../header/lfr_common_headers/tm_byte_positions.h \
109 ../LFR_basic-parameters/basic_parameters.h \
110 ../LFR_basic-parameters/basic_parameters_params.h
110 111
@@ -90,6 +90,10 typedef struct{
90 90 volatile unsigned int f3_1_fine_time; // 0x88
91 91 //
92 92 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
93 //
94 volatile unsigned int v; // 0x90
95 volatile unsigned int e1; // 0x94
96 volatile unsigned int e2; // 0x98
93 97 } waveform_picker_regs_0_1_18_t;
94 98
95 99 typedef struct {
@@ -111,7 +115,7 typedef struct {
111 115 volatile unsigned int f1_0_coarse_time; // 0x30
112 116 volatile unsigned int f1_0_fine_time; // 0x34
113 117 volatile unsigned int f1_1_coarse_time; // 0x38
114 volatile unsigned int f1_1_time_time; // 0x3C
118 volatile unsigned int f1_1_fine_time; // 0x3C
115 119 //
116 120 volatile unsigned int f2_0_coarse_time; // 0x40
117 121 volatile unsigned int f2_0_fine_time; // 0x44
@@ -27,10 +27,11 rtems_task prc0_task( rtems_task_argumen
27 27 // FUNCTIONS
28 28
29 29 void reset_nb_sm_f0( unsigned char lfrMode );
30 void init_k_coefficients_f0( void );
31 void test_TCH( void );
30 32
31 33 //*******
32 34 // EXTERN
33 extern ring_node *ring_node_for_averaging_sm_f0;
34 35 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35 36
36 37 #endif // AVF0_PRC0_H_INCLUDED
@@ -2,6 +2,7
2 2 #define AVF1_PRC1_H
3 3
4 4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 6
6 7 typedef struct {
7 8 unsigned int norm_bp1;
@@ -24,10 +25,10 rtems_task prc1_task( rtems_task_argumen
24 25 // FUNCTIONS
25 26
26 27 void reset_nb_sm_f1( unsigned char lfrMode );
28 void init_k_coefficients_f1( void );
27 29
28 30 //*******
29 31 // EXTERN
30 extern struct ring_node *ring_node_for_averaging_sm_f1;
31 32 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
32 33
33 34 #endif // AVF1_PRC1_H
@@ -2,6 +2,7
2 2 #define AVF2_PRC2_H
3 3
4 4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 6
6 7 typedef struct {
7 8 unsigned int norm_bp1;
@@ -18,11 +19,11 rtems_task prc2_task( rtems_task_argumen
18 19 // FUNCTIONS
19 20
20 21 void reset_nb_sm_f2( void );
21 void SM_average_f2(float *averaged_spec_mat_f2, ring_node *ring_node, unsigned int nbAverageNormF2 );
22 void SM_average_f2(float *averaged_spec_mat_f2, ring_node *ring_node, unsigned int nbAverageNormF2 , asm_msg *msgForMATR);
23 void init_k_coefficients_f2( void );
22 24
23 25 //*******
24 26 // EXTERN
25 extern struct ring_node *ring_node_for_averaging_sm_f2;
26 27 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
27 28
28 29 #endif // AVF2_PRC2_H
@@ -21,7 +21,25 typedef struct ring_node_asm
21 21
22 22 typedef struct
23 23 {
24 Header_TM_LFR_SCIENCE_BP_t header;
24 unsigned char targetLogicalAddress;
25 unsigned char protocolIdentifier;
26 unsigned char reserved;
27 unsigned char userApplication;
28 unsigned char packetID[2];
29 unsigned char packetSequenceControl[2];
30 unsigned char packetLength[2];
31 // DATA FIELD HEADER
32 unsigned char spare1_pusVersion_spare2;
33 unsigned char serviceType;
34 unsigned char serviceSubType;
35 unsigned char destinationID;
36 unsigned char time[6];
37 // AUXILIARY HEADER
38 unsigned char sid;
39 unsigned char biaStatusInfo;
40 unsigned char acquisitionTime[6];
41 unsigned char pa_lfr_bp_blk_nr[2];
42 // SOURCE DATA
25 43 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
26 44 } bp_packet;
27 45
@@ -36,8 +54,10 typedef struct
36 54 ring_node_asm *norm;
37 55 ring_node_asm *burst_sbm;
38 56 rtems_event_set event;
39 unsigned int coarseTime;
40 unsigned int fineTime;
57 unsigned int coarseTimeNORM;
58 unsigned int fineTimeNORM;
59 unsigned int coarseTimeSBM;
60 unsigned int fineTimeSBM;
41 61 } asm_msg;
42 62
43 63 extern volatile int sm_f0[ ];
@@ -49,11 +69,13 extern struct param_local_str param_loca
49 69
50 70 // registers
51 71 extern time_management_regs_t *time_management_regs;
52 extern spectral_matrix_regs_t *spectral_matrix_regs;
72 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
53 73
54 74 extern rtems_name misc_name[5];
55 75 extern rtems_id Task_id[20]; /* array of task ids */
56 76
77 //
78 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
57 79 // ISR
58 80 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
59 81 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
@@ -71,7 +93,7 void ASM_generic_init_ring(ring_node_asm
71 93 // Basic Parameters
72 94
73 95 void BP_reset_current_ring_nodes( void );
74 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
96 void BP_init_header(bp_packet *header,
75 97 unsigned int apid, unsigned char sid,
76 98 unsigned int packetLength , unsigned char blkNr);
77 99 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
@@ -87,8 +109,6 void reset_sm_status( void );
87 109 void reset_spectral_matrix_regs( void );
88 110 void set_time(unsigned char *time, unsigned char *timeInBuffer );
89 111 unsigned long long int get_acquisition_time( unsigned char *timePtr );
90 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
91 ring_node *node_for_averaging, ring_node *ringNode, unsigned long long int time );
92 112 unsigned char getSID( rtems_event_set event );
93 113
94 114 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
@@ -97,11 +117,12 extern rtems_status_code get_message_que
97 117 //***************************************
98 118 // DEFINITIONS OF STATIC INLINE FUNCTIONS
99 119 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
100 ring_node *ring_node_tab[],
101 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
120 ring_node *ring_node_tab[],
121 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
122 asm_msg *msgForMATR );
102 123 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
103 ring_node *ring_node_tab[],
104 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
124 ring_node *ring_node_tab[],
125 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
105 126 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
106 127 float divider );
107 128 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
@@ -110,8 +131,9 static inline void ASM_compress_reorgani
110 131 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
111 132
112 133 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
113 ring_node *ring_node_tab[],
114 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
134 ring_node *ring_node_tab[],
135 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
136 asm_msg *msgForMATR )
115 137 {
116 138 float sum;
117 139 unsigned int i;
@@ -131,6 +153,10 void SM_average( float *averaged_spec_ma
131 153 {
132 154 averaged_spec_mat_NORM[ i ] = sum;
133 155 averaged_spec_mat_SBM[ i ] = sum;
156 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
157 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
158 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
159 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
134 160 }
135 161 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
136 162 {
@@ -141,6 +167,8 void SM_average( float *averaged_spec_ma
141 167 {
142 168 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
143 169 averaged_spec_mat_SBM[ i ] = sum;
170 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
171 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
144 172 }
145 173 else
146 174 {
@@ -186,21 +214,22 void ASM_reorganize_and_divide( float *a
186 214 {
187 215 int frequencyBin;
188 216 int asmComponent;
189 unsigned int offsetAveragedSpecMatReorganized;
190 unsigned int offsetAveragedSpecMat;
217 unsigned int offsetASM;
218 unsigned int offsetASMReorganized;
191 219
220 // BUILD DATA
192 221 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
193 222 {
194 223 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
195 224 {
196 offsetAveragedSpecMatReorganized =
225 offsetASMReorganized =
197 226 frequencyBin * NB_VALUES_PER_SM
198 227 + asmComponent;
199 offsetAveragedSpecMat =
228 offsetASM =
200 229 asmComponent * NB_BINS_PER_SM
201 230 + frequencyBin;
202 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
203 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
231 averaged_spec_mat_reorganized[offsetASMReorganized ] =
232 averaged_spec_mat[ offsetASM ] / divider;
204 233 }
205 234 }
206 235 }
@@ -214,7 +243,7 void ASM_compress_reorganize_and_divide(
214 243 int offsetCompressed;
215 244 int k;
216 245
217 // build data
246 // BUILD DATA
218 247 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
219 248 {
220 249 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
@@ -231,8 +260,10 void ASM_compress_reorganize_and_divide(
231 260 {
232 261 compressed_spec_mat[offsetCompressed ] =
233 262 ( compressed_spec_mat[ offsetCompressed ]
234 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
263 + averaged_spec_mat[ offsetASM + k ] );
235 264 }
265 compressed_spec_mat[ offsetCompressed ] =
266 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
236 267 }
237 268 }
238 269 }
@@ -108,6 +108,9 rtems_task Init( rtems_task_argument ign
108 108 init_parameter_dump();
109 109 init_local_mode_parameters();
110 110 init_housekeeping_parameters();
111 init_k_coefficients_f0();
112 init_k_coefficients_f1();
113 init_k_coefficients_f2();
111 114
112 115 // waveform picker initialization
113 116 WFP_init_rings(); // initialize the waveform rings
@@ -215,6 +218,8 rtems_task Init( rtems_task_argument ign
215 218
216 219 BOOT_PRINTF("delete INIT\n")
217 220
221 // test_TCH();
222
218 223 status = rtems_task_delete(RTEMS_SELF);
219 224
220 225 }
@@ -225,7 +225,7 rtems_task hous_task(rtems_task_argument
225 225
226 226 spacewire_update_statistics();
227 227
228 // get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
229 229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230 230
231 231 // SEND PACKET
@@ -443,107 +443,20 void send_dumb_hk( void )
443 443
444 444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 445 {
446 unsigned long long int localTime_asLong;
447 unsigned long long int f3_0_AcquisitionTime_asLong;
448 unsigned long long int f3_1_AcquisitionTime_asLong;
449 unsigned long long int deltaT;
450 unsigned long long int deltaT_f3_0;
451 unsigned long long int deltaT_f3_1;
452 unsigned char *bufferPtr;
453
454 unsigned int offset_in_samples;
455 unsigned int offset_in_bytes;
456 unsigned char f3;
457
458 bufferPtr = NULL;
459 deltaT = 0;
460 deltaT_f3_0 = 0xffffffff;
461 deltaT_f3_1 = 0xffffffff;
462 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
463
464 if (lfrCurrentMode == LFR_MODE_STANDBY)
465 {
466 spacecraft_potential[0] = 0x00;
467 spacecraft_potential[1] = 0x00;
468 spacecraft_potential[2] = 0x00;
469 spacecraft_potential[3] = 0x00;
470 spacecraft_potential[4] = 0x00;
471 spacecraft_potential[5] = 0x00;
472 }
473 else
474 {
475 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
476 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
477 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
478 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
479 localTime_asLong,
480 f3_0_AcquisitionTime_asLong,
481 f3_1_AcquisitionTime_asLong);
482
483 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
484 {
485 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
486 }
487
488 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
489 {
490 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
491 }
446 unsigned char* v_ptr;
447 unsigned char* e1_ptr;
448 unsigned char* e2_ptr;
492 449
493 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
494 {
495 if ( deltaT_f3_0 > deltaT_f3_1 )
496 {
497 deltaT = deltaT_f3_1;
498 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
499 }
500 else
501 {
502 deltaT = deltaT_f3_0;
503 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
504 }
505 }
506 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
507 {
508 deltaT = deltaT_f3_1;
509 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
510 }
511 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
512 {
513 deltaT = deltaT_f3_0;
514 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
515 }
516 else
517 {
518 deltaT = 0xffffffff;
519 }
450 v_ptr = (unsigned char *) &waveform_picker_regs->v;
451 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
452 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
520 453
521 if ( deltaT == 0xffffffff )
522 {
523 spacecraft_potential[0] = 0x00;
524 spacecraft_potential[1] = 0x00;
525 spacecraft_potential[2] = 0x00;
526 spacecraft_potential[3] = 0x00;
527 spacecraft_potential[4] = 0x00;
528 spacecraft_potential[5] = 0x00;
529 }
530 else
531 {
532 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
533 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
534 {
535 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
536 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
537 }
538 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
539 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
540 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
541 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
542 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
543 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
544 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
545 }
546 }
454 spacecraft_potential[0] = v_ptr[2];
455 spacecraft_potential[1] = v_ptr[3];
456 spacecraft_potential[2] = e1_ptr[2];
457 spacecraft_potential[3] = e1_ptr[3];
458 spacecraft_potential[4] = e2_ptr[2];
459 spacecraft_potential[5] = e2_ptr[3];
547 460 }
548 461
549 462 void get_cpu_load( unsigned char *resource_statistics )
@@ -690,8 +690,8 void init_header_cwf( Header_TM_LFR_SCIE
690 690 header->userApplication = CCSDS_USER_APP;
691 691 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
692 692 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
693 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
694 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
693 header->packetLength[0] = 0x00;
694 header->packetLength[1] = 0x00;
695 695 // DATA FIELD HEADER
696 696 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
697 697 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
@@ -706,8 +706,8 void init_header_cwf( Header_TM_LFR_SCIE
706 706 // AUXILIARY DATA HEADER
707 707 header->sid = 0x00;
708 708 header->hkBIA = DEFAULT_HKBIA;
709 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
710 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
709 header->blkNr[0] = 0x00;
710 header->blkNr[1] = 0x00;
711 711 }
712 712
713 713 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header )
@@ -808,6 +808,11 int spw_send_waveform_CWF( ring_node *ri
808 808 fineTime = ring_node_to_send->fineTime;
809 809 dataPtr = (int*) ring_node_to_send->buffer_address;
810 810
811 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
812 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
813 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
814 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
815
811 816 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
812 817 {
813 818 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
@@ -974,6 +979,11 int spw_send_waveform_CWF3_light( ring_n
974 979 fineTime = ring_node_to_send->fineTime;
975 980 dataPtr = (char*) ring_node_to_send->buffer_address;
976 981
982 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
983 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
984 header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
985 header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
986
977 987 //*********************
978 988 // SEND CWF3_light DATA
979 989 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
@@ -24,8 +24,9 float asm_f0_reorganized [ TOTAL_SIZE_
24 24 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
25 25 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
26 26 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
27 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
28 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
27
28 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352
29 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704
29 30
30 31 //************
31 32 // RTEMS TASKS
@@ -38,6 +39,7 rtems_task avf0_task( rtems_task_argumen
38 39 rtems_status_code status;
39 40 rtems_id queue_id_prc0;
40 41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
41 43 ring_node *ring_node_tab[8];
42 44 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
43 45 ring_node_asm *current_ring_node_asm_norm_f0;
@@ -76,23 +78,24 rtems_task avf0_task( rtems_task_argumen
76 78 msgForMATR.norm = current_ring_node_asm_norm_f0;
77 79 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
78 80 msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task
79 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
80 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
81 81 //
82 82 //****************************************
83 83
84 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
84 nodeForAveraging = getRingNodeForAveraging( 0 );
85
86 ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging;
85 87 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
86 88 {
87 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
88 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
89 nodeForAveraging = nodeForAveraging->previous;
90 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
89 91 }
90 92
91 93 // compute the average and store it in the averaged_sm_f1 buffer
92 94 SM_average( current_ring_node_asm_norm_f0->matrix,
93 95 current_ring_node_asm_burst_sbm_f0->matrix,
94 96 ring_node_tab,
95 nb_norm_bp1, nb_sbm_bp1 );
97 nb_norm_bp1, nb_sbm_bp1,
98 &msgForMATR );
96 99
97 100 // update nb_average
98 101 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
@@ -157,7 +160,6 rtems_task avf0_task( rtems_task_argumen
157 160 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 161 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 162 {
160 // PRINTF1("%lld\n", localTime)
161 163 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
162 164 }
163 165 }
@@ -185,10 +187,10 rtems_task prc0_task( rtems_task_argumen
185 187 rtems_status_code status;
186 188 rtems_id queue_id;
187 189 rtems_id queue_id_q_p0;
188 bp_packet_with_spare packet_norm_bp1_f0;
189 bp_packet packet_norm_bp2_f0;
190 bp_packet packet_sbm_bp1_f0;
191 bp_packet packet_sbm_bp2_f0;
190 bp_packet_with_spare packet_norm_bp1;
191 bp_packet packet_norm_bp2;
192 bp_packet packet_sbm_bp1;
193 bp_packet packet_sbm_bp2;
192 194 ring_node *current_ring_node_to_send_asm_f0;
193 195
194 196 unsigned long long int localTime;
@@ -199,10 +201,10 rtems_task prc0_task( rtems_task_argumen
199 201
200 202 //*************
201 203 // NORM headers
202 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
204 BP_init_header_with_spare( &packet_norm_bp1.header,
203 205 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
204 206 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
205 BP_init_header( &packet_norm_bp2_f0.header,
207 BP_init_header( &packet_norm_bp2,
206 208 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
207 209 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
208 210
@@ -210,28 +212,28 rtems_task prc0_task( rtems_task_argumen
210 212 // BURST SBM1 and SBM2 headers
211 213 if ( lfrRequestedMode == LFR_MODE_BURST )
212 214 {
213 BP_init_header( &packet_sbm_bp1_f0.header,
215 BP_init_header( &packet_sbm_bp1,
214 216 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
215 217 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 BP_init_header( &packet_sbm_bp2_f0.header,
218 BP_init_header( &packet_sbm_bp2,
217 219 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
218 220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 221 }
220 222 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
221 223 {
222 BP_init_header( &packet_sbm_bp1_f0.header,
224 BP_init_header( &packet_sbm_bp1,
223 225 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
224 226 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 BP_init_header( &packet_sbm_bp2_f0.header,
227 BP_init_header( &packet_sbm_bp2,
226 228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
227 229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 230 }
229 231 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
230 232 {
231 BP_init_header( &packet_sbm_bp1_f0.header,
233 BP_init_header( &packet_sbm_bp1,
232 234 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
233 235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
234 BP_init_header( &packet_sbm_bp2_f0.header,
236 BP_init_header( &packet_sbm_bp2,
235 237 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
236 238 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
237 239 }
@@ -275,22 +277,22 rtems_task prc0_task( rtems_task_argumen
275 277 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
276 278 ASM_F0_INDICE_START);
277 279 // 2) compute the BP1 set
278 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
280 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
279 281 // 3) send the BP1 set
280 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
281 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
282 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
282 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
283 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
284 BP_send( (char *) &packet_sbm_bp1, queue_id,
283 285 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
284 286 sid);
285 287 // 4) compute the BP2 set if needed
286 288 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
287 289 {
288 290 // 1) compute the BP2 set
289
291 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
290 292 // 2) send the BP2 set
291 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
292 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
293 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
293 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );