##// END OF EJS Templates
Sync
paul -
r115:f4c5e8b9b4cc VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 10:09:31 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 13:43:01 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
@@ -1,7 +1,7
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose
4 CONFIG += console verbose cpu_usage_report
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
@@ -11,7 +11,7 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=5 # internal
14 DEFINES += SW_VERSION_N4=6 # internal
15 15
16 16 contains( CONFIG, debug_tch ) {
17 17 DEFINES += DEBUG_TCH
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-03T08:17:16. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-03T15:58:50. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -195,17 +195,19 enum apid_destid{
195 195 #define TM_HEADER_LEN 16
196 196 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
197 197 // PACKET_LENGTH
198 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
199 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
201 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
203 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
204 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
205 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 2221 // 44 * 25 * 2 + 28 - 7
207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 2621 // 52 * 25 * 2 + 28 - 7
208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 2421 // 48 * 25 * 2 + 28 - 7
198 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
199 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
201 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
203 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
204 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
205 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 (2228 - CCSDS_TC_TM_PACKET_OFFSET) // 44 * 25 * 2 + 28 - 7
207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 25 * 2 + 28 - 7
208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 (2428 - CCSDS_TC_TM_PACKET_OFFSET) // 48 * 25 * 2 + 28 - 7
209 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27 - 7
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
209 211
210 212 #define SPARE1_PUSVERSION_SPARE2 0x10
211 213
@@ -466,7 +468,28 typedef struct {
466 468 unsigned char acquisitionTime[6];
467 469 unsigned char spare_source_data;
468 470 unsigned char pa_lfr_bp_blk_nr[2];
469 } Header_TM_LFR_SCIENCE_BP_t;
471 } Header_TM_LFR_SCIENCE_BP_NORM_t;
472
473 typedef struct {
474 unsigned char targetLogicalAddress;
475 unsigned char protocolIdentifier;
476 unsigned char reserved;
477 unsigned char userApplication;
478 unsigned char packetID[2];
479 unsigned char packetSequenceControl[2];
480 unsigned char packetLength[2];
481 // DATA FIELD HEADER
482 unsigned char spare1_pusVersion_spare2;
483 unsigned char serviceType;
484 unsigned char serviceSubType;
485 unsigned char destinationID;
486 unsigned char time[6];
487 // AUXILIARY HEADER
488 unsigned char sid;
489 unsigned char biaStatusInfo;
490 unsigned char acquisitionTime[6];
491 unsigned char pa_lfr_bp_blk_nr[2];
492 } Header_TM_LFR_SCIENCE_BP_SBM_t;
470 493
471 494 typedef struct {
472 495 //targetLogicalAddress is removed by the grspw module
@@ -28,6 +28,26 typedef struct ring_node_sm
28 28 unsigned int fineTime;
29 29 } ring_node_sm;
30 30
31 typedef struct ring_node_bp
32 {
33 struct ring_node_bp *previous;
34 struct ring_node_bp *next;
35 unsigned int status;
36 unsigned int coarseTime;
37 unsigned int fineTime;
38 Header_TM_LFR_SCIENCE_BP_SBM_t header;
39 unsigned char data[ 9 * 22 ];
40 } ring_node_bp;
41
42 typedef struct
43 {
44 unsigned int status;
45 unsigned int coarseTime;
46 unsigned int fineTime;
47 Header_TM_LFR_SCIENCE_BP_NORM_t header;
48 unsigned char data[ 9 * 22 ];
49 } ring_node_norm_bp;
50
31 51 //************************
32 52 // flight software version
33 53 // this parameters is handled by the Qt project options
@@ -142,8 +162,9 typedef struct ring_node_sm
142 162
143 163 //**********
144 164 // LPP CODES
145 #define LFR_SUCCESSFUL 0
146 #define LFR_DEFAULT 1
165 #define LFR_SUCCESSFUL 0
166 #define LFR_DEFAULT 1
167 #define LFR_EXE_ERROR 2
147 168
148 169 //******
149 170 // RTEMS
@@ -184,7 +205,8 typedef struct ring_node_sm
184 205
185 206 #define ACTION_MSG_QUEUE_COUNT 10
186 207 #define ACTION_MSG_PKTS_COUNT 50
187 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
208 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
209 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
188 210 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
189 211
190 212 #define QUEUE_RECV 0
@@ -4,13 +4,15
4 4 #define NB_BINS_PER_SM 128
5 5 #define NB_VALUES_PER_SM 25
6 6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 #define TOTAL_SIZE_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_BP1_F2 108 // 12 * 9 = 108
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
10 11 //
11 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
12 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
13 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
12 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
13 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
14 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
15 #define NB_RING_NODES_BP1_SBM1 10 // AT LEAST 3
14 16 //
15 17 #define NB_BINS_PER_ASM_F0 88
16 18 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -30,30 +32,22
30 32 #define ASM_F2_INDICE_START 7 // 96 bins
31 33 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
32 34 //
33 #define NB_BINS_COMPRESSED_SM_F0 11
34 #define NB_BINS_COMPRESSED_SM_F1 13
35 #define NB_BINS_COMPRESSED_SM_F2 12
35 #define NB_BINS_COMPRESSED_SM_F0 11
36 #define NB_BINS_COMPRESSED_SM_F1 13
37 #define NB_BINS_COMPRESSED_SM_F2 12
38 #define NB_BINS_COMPRESSED_SM_SBM1_F0 22
36 39 //
37 40 #define NB_BINS_TO_AVERAGE_ASM_F0 8
38 41 #define NB_BINS_TO_AVERAGE_ASM_F1 8
39 42 #define NB_BINS_TO_AVERAGE_ASM_F2 8
43 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
40 44 //
41 45 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
42 46 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
43 47 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
44 48 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
45 #define NB_AVERAGE_NORMAL_F0 384 // 96 * 4
46 #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second
47 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
48
49 typedef struct {
50 volatile unsigned char PE[2];
51 volatile unsigned char PB[2];
52 volatile unsigned char V0;
53 volatile unsigned char V1;
54 volatile unsigned char V2_ELLIP_DOP;
55 volatile unsigned char SZ;
56 volatile unsigned char VPHI;
57 } BP1_t;
49 #define NB_AVERAGE_NORMAL_F0 384 // 96 * 4
50 #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second
51 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
58 52
59 53 #endif // FSW_PARAMS_PROCESSING_H
@@ -38,20 +38,27 rtems_task avf0_task(rtems_task_argument
38 38 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
39 39 rtems_task matr_task(rtems_task_argument argument);
40 40
41 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
42 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
43 //
44 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
45 void matrix_reset(volatile float *averaged_spec_mat);
41 //*****************************
42 // Spectral matrices processing
43
46 44 void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
47 45 ring_node_sm *ring_node_tab[],
48 46 unsigned int firstTimeF0, unsigned int firstTimeF1 );
49 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
50 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
47 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
48 float divider );
49 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
50 float divider,
51 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
51 52 void ASM_convert(volatile float *input_matrix, char *output_matrix);
52 53 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
53 54 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
54 void fill_averaged_spectral_matrix( void );
55 void reset_spectral_matrix_regs();
55
56 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id );
57
58 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
59 void init_headers_bp_ring_sbm1();
60 void init_header_bp( Header_TM_LFR_SCIENCE_BP_SBM_t *header);
61
62 void reset_spectral_matrix_regs( void );
56 63
57 64 #endif // FSW_PROCESSING_H_INCLUDED
@@ -13,32 +13,35
13 13
14 14 //************************
15 15 // spectral matrices rings
16 ring_node_sm sm_ring_f0[NB_RING_NODES_ASM_F0];
17 ring_node_sm sm_ring_f1[NB_RING_NODES_ASM_F1];
18 ring_node_sm sm_ring_f2[NB_RING_NODES_ASM_F2];
16 ring_node_sm sm_ring_f0[ NB_RING_NODES_ASM_F0 ];
17 ring_node_sm sm_ring_f1[ NB_RING_NODES_ASM_F1 ];
18 ring_node_sm sm_ring_f2[ NB_RING_NODES_ASM_F2 ];
19 19 ring_node_sm *current_ring_node_sm_f0;
20 20 ring_node_sm *ring_node_for_averaging_sm_f0;
21 21 ring_node_sm *current_ring_node_sm_f1;
22 22 ring_node_sm *current_ring_node_sm_f2;
23 23
24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
24 //**********************
25 // basic parameter rings
26 ring_node_bp *current_node_sbm1_bp1_f0;
27 ring_node_bp bp_ring_sbm1[ NB_RING_NODES_BP1_SBM1 ];
25 28
26 29 //*****
27 30 // NORM
28 31 // F0
29 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
30 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
31 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
32 float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
32 float asm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 float asm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
34 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
35 float compressed_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
33 36
34 37 //*****
35 38 // SBM1
36 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
37 float compressed_sm_sbm1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
39 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
40 float compressed_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
38 41
39 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F0 * 2 ];
40 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F1 ];
41 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F2 ];
42 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
43 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
44 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ];
42 45
43 46 unsigned int nb_sm_f0;
44 47
@@ -120,6 +123,11 void reset_current_sm_ring_nodes( void )
120 123 ring_node_for_averaging_sm_f0 = sm_ring_f0;
121 124 }
122 125
126 void reset_current_node_sbm1_bp1_f0( void )
127 {
128 current_node_sbm1_bp1_f0 = bp_ring_sbm1;
129 }
130
123 131 //***********************************************************
124 132 // Interrupt Service Routine for spectral matrices processing
125 133 void reset_nb_sm_f0( void )
@@ -223,14 +231,14 rtems_task avf0_task(rtems_task_argument
223 231 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
224 232 }
225 233
226 // copy time information in the averaged_sm_f0 buffer
227 averaged_sm_f0[0] = ring_node_tab[7]->coarseTime;
228 averaged_sm_f0[1] = ring_node_tab[7]->fineTime;
234 // copy time information in the asm_f0 buffer
235 asm_f0[0] = ring_node_tab[7]->coarseTime;
236 asm_f0[1] = ring_node_tab[7]->fineTime;
229 237 averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime;
230 238 averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime;
231 239
232 240 // compute the average and store it in the averaged_sm_f1 buffer
233 ASM_average( averaged_sm_f0, averaged_sm_sbm1,
241 ASM_average( asm_f0, averaged_sm_sbm1,
234 242 ring_node_tab,
235 243 nb_average_norm_f0, nb_average_sbm1_f0 );
236 244
@@ -271,8 +279,10 rtems_task matr_task(rtems_task_argument
271 279 rtems_status_code status;
272 280 rtems_id queue_id;
273 281 Header_TM_LFR_SCIENCE_ASM_t headerASM;
282 ring_node_norm_bp current_node_norm_bp1_f0;
274 283
275 284 init_header_asm( &headerASM );
285 // init_header_bp( &current_node_norm_bp1_f0.header );
276 286
277 287 status = get_message_queue_id_send( &queue_id );
278 288 if (status != RTEMS_SUCCESSFUL)
@@ -282,33 +292,40 rtems_task matr_task(rtems_task_argument
282 292
283 293 BOOT_PRINTF("in MATR *** \n")
284 294
285 fill_averaged_spectral_matrix( );
286
287 295 while(1){
288 296 rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1,
289 297 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
290 298 if (event_out==RTEMS_EVENT_MODE_NORMAL)
291 299 {
292 300 // 1) compress the matrix for Basic Parameters calculation
293 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
301 ASM_compress_reorganize_and_divide( asm_f0, compressed_sm_f0,
302 NB_AVERAGE_NORMAL_F0,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
294 305 // 2) compute the BP1 set
295 306
296 307 // 3) send the BP1 set
297
298 // 4) convert the float array in a char array
299 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
300 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
301 // 5) send the spectral matrix packets
302 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
308 BP1_send( &current_node_norm_bp1_f0, SID_NORM_BP1_F0, queue_id );
309 // 4) reorganize the ASM and divide
310 ASM_reorganize_and_divide( asm_f0, asm_f0_reorganized, NB_AVERAGE_NORMAL_F0 );
311 // 5) convert the float array in a char array
312 ASM_convert( asm_f0_reorganized, asm_f0_char);
313 // 6) send the spectral matrix packets
314 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
303 315 }
304 316 else if (event_out==RTEMS_EVENT_MODE_SBM1)
305 317 {
306 318 // 1) compress the matrix for Basic Parameters calculation
307 ASM_compress( averaged_sm_sbm1, 0, compressed_sm_sbm1 );
319 ASM_compress_reorganize_and_divide( averaged_sm_sbm1, compressed_sm_sbm1,
320 NB_AVERAGE_SBM1_F0,
321 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
322 ASM_F0_INDICE_START);
308 323 // 2) compute the BP1 set
309 324
310 325 // 3) send the basic parameters set 1 packet
311
326 BP1_send( current_node_sbm1_bp1_f0, SID_SBM1_BP1_F0, queue_id );
327 // 4) update current_node_sbm1_bp1_f0
328 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
312 329 }
313 330 else
314 331 {
@@ -320,14 +337,6 rtems_task matr_task(rtems_task_argument
320 337 //*****************************
321 338 // Spectral matrices processing
322 339
323 void matrix_reset(volatile float *averaged_spec_mat)
324 {
325 int i;
326 for(i=0; i<TOTAL_SIZE_SM; i++){
327 averaged_spec_mat[i] = 0;
328 }
329 }
330
331 340 void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
332 341 ring_node_sm *ring_node_tab[],
333 342 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
@@ -368,7 +377,7 void ASM_average( float *averaged_spec_m
368 377 }
369 378 }
370 379
371 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
380 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
372 381 {
373 382 int frequencyBin;
374 383 int asmComponent;
@@ -382,12 +391,13 void ASM_reorganize( float *averaged_spe
382 391 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
383 392 {
384 393 averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] =
385 averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ];
394 averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ] / divider;
386 395 }
387 396 }
388 397 }
389 398
390 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
399 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
400 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
391 401 {
392 402 int frequencyBin;
393 403 int asmComponent;
@@ -395,40 +405,25 void ASM_compress( float *averaged_spec_
395 405 int offsetCompressed;
396 406 int k;
397 407
398 switch (fChannel){
399 case 0:
400 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
408 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
409 {
410 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
401 411 {
402 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
412 offsetCompressed = TIME_OFFSET
413 + frequencyBin * NB_VALUES_PER_SM
414 + asmComponent;
415 offsetASM = TIME_OFFSET
416 + asmComponent * NB_BINS_PER_SM
417 + ASMIndexStart
418 + frequencyBin * nbBinsToAverage;
419 compressed_spec_mat[ offsetCompressed ] = 0;
420 for ( k = 0; k < nbBinsToAverage; k++ )
403 421 {
404 offsetCompressed = TIME_OFFSET
405 + frequencyBin * NB_VALUES_PER_SM
406 + asmComponent;
407 offsetASM = TIME_OFFSET
408 + asmComponent * NB_BINS_PER_SM
409 + ASM_F0_INDICE_START
410 + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0;
411 compressed_spec_mat[ offsetCompressed ] = 0;
412 for ( k = 0; k < NB_BINS_TO_AVERAGE_ASM_F0; k++ )
413 {
414 compressed_spec_mat[offsetCompressed ] =
415 compressed_spec_mat[ offsetCompressed ]
416 + averaged_spec_mat[ offsetASM + k ];
417 }
422 compressed_spec_mat[offsetCompressed ] =
423 ( compressed_spec_mat[ offsetCompressed ]
424 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
418 425 }
419 426 }
420 break;
421
422 case 1:
423 // case fChannel = f1 to be completed later
424 break;
425
426 case 2:
427 // case fChannel = f1 to be completed later
428 break;
429
430 default:
431 break;
432 427 }
433 428 }
434 429
@@ -526,191 +521,65 void ASM_send(Header_TM_LFR_SCIENCE_ASM_
526 521 }
527 522 }
528 523
529 void BP1_send()
524 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id )
530 525 {
531
532 }
526 unsigned int length = 0;
527 rtems_status_code status;
528 unsigned char nbBytesTosend;
533 529
534 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
535 int i;
536 int j;
537 unsigned char tmp_u_char;
538 unsigned char * pt_char = NULL;
539 float PSDB, PSDE;
540 float NVEC_V0;
541 float NVEC_V1;
542 float NVEC_V2;
543 //float significand;
544 //int exponent;
545 float aux;
546 float tr_SB_SB;
547 float tmp;
548 float sx_re;
549 float sx_im;
550 float nebx_re = 0;
551 float nebx_im = 0;
552 float ny = 0;
553 float nz = 0;
554 float bx_bx_star = 0;
555 for(i=0; i<nb_bins_compressed_spec_mat; i++){
556 //==============================================
557 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
558 PSDB = compressed_spec_mat[i*30] // S11
559 + compressed_spec_mat[(i*30) + 10] // S22
560 + compressed_spec_mat[(i*30) + 18]; // S33
561 //significand = frexp(PSDB, &exponent);
562 pt_char = (unsigned char*) &PSDB;
563 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
564 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
565 //==============================================
566 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
567 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
568 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
569 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
570 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
571 pt_char = (unsigned char*) &PSDE;
572 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
573 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
574 //==============================================================================
575 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
576 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
577 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
578 tmp = sqrt(
579 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
580 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
581 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
582 );
583 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
584 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
585 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
586 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
587 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
588 pt_char = (unsigned char*) &NVEC_V2;
589 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
590 //=======================================================
591 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
592 aux = 2*tmp / PSDB; // compute the ellipticity
593 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
594 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
595 //==============================================================
596 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
597 for(j = 0; j<NB_VALUES_PER_SM;j++){
598 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
599 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
600 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
601 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
602 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
603 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
604 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
605 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
606 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
607 }
608 aux = PSDB*PSDB;
609 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
610 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
611 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
612 //=======================================================================================
613 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
614 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
615 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
616 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
617 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
618 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
619 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
620 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
621 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
622 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
623 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
624 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
625 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
626 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
627 if ( abs(sx_re) > abs(sx_im) ) {
628 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
629 }
630 else {
631 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
632 }
633 //======================================================================
634 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
635 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
636 nz = NVEC_V0;
637 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
638 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
639 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
640 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
641 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
642 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
643 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
644 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
645 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
646 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
647 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
648 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
649 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
650 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
651 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
652 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
653 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
654 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
655 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
656 tmp = nebx_re / bx_bx_star;
657 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
658 if ( abs(nebx_re) > abs(nebx_im) ) {
659 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
660 }
661 else {
662 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
663 }
530 // (1) BUILD THE DATA
531 switch(sid)
532 {
533 case SID_NORM_BP1_F0:
534 length = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0;
535 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
536 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
537 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_F0) >> 8 ); // BLK_NR MSB
538 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_F0); // BLK_NR LSB
539 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0
540 + CCSDS_TC_TM_PACKET_OFFSET
541 + CCSDS_PROTOCOLE_EXTRA_BYTES;
542 case SID_SBM1_BP1_F0:
543 length = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0;
544 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
545 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
546 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_SBM1_F0) >> 8 ); // BLK_NR MSB
547 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_SBM1_F0); // BLK_NR LSB
548 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0
549 + CCSDS_TC_TM_PACKET_OFFSET
550 + CCSDS_PROTOCOLE_EXTRA_BYTES;
551 break;
552 default:
553 nbBytesTosend = 0;
554 PRINTF1("ERR *** in BP1_send *** unexpected sid %d\n", sid)
555 break;
664 556 }
665 557
666 }
667
668 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
669 // BP2 autocorrelation
670 int i;
671 int aux = 0;
558 // (2) BUILD THE HEADER
559 ring_node_to_send->header.packetLength[0] = (unsigned char) (length>>8);
560 ring_node_to_send->header.packetLength[1] = (unsigned char) (length);
561 ring_node_to_send->header.sid = sid;
672 562
673 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
674 // S12
675 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
676 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
677 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
678 // S13
679 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
680 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
681 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
682 // S23
683 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
684 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
685 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
686 // S45
687 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
688 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
689 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
690 // S14
691 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
692 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
693 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
694 // S15
695 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
696 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
697 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
698 // S24
699 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
700 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
701 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
702 // S25
703 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
704 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
705 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
706 // S34
707 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
708 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
709 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
710 // S35
711 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
712 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
713 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
563 // (3) SET PACKET TIME
564 ring_node_to_send->header.time[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
565 ring_node_to_send->header.time[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
566 ring_node_to_send->header.time[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
567 ring_node_to_send->header.time[3] = (unsigned char) (ring_node_to_send->coarseTime);
568 ring_node_to_send->header.time[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
569 ring_node_to_send->header.time[5] = (unsigned char) (ring_node_to_send->fineTime);
570 //
571 ring_node_to_send->header.acquisitionTime[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
572 ring_node_to_send->header.acquisitionTime[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
573 ring_node_to_send->header.acquisitionTime[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
574 ring_node_to_send->header.acquisitionTime[3] = (unsigned char) (ring_node_to_send->coarseTime);
575 ring_node_to_send->header.acquisitionTime[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
576 ring_node_to_send->header.acquisitionTime[5] = (unsigned char) (ring_node_to_send->fineTime);
577
578 // (4) SEND PACKET
579 status = rtems_message_queue_send( queue_id, &ring_node_to_send->header, nbBytesTosend);
580 if (status != RTEMS_SUCCESSFUL)
581 {
582 printf("ERR *** in BP1_send *** ERR %d\n", (int) status);
714 583 }
715 584 }
716 585
@@ -746,14 +615,41 void init_header_asm( Header_TM_LFR_SCIE
746 615 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
747 616 }
748 617
749 void init_header_bp( Header_TM_LFR_SCIENCE_BP_t *header)
618 void init_bp_ring_sbm1()
619 {
620 unsigned int i;
621
622 //********
623 // F0 RING
624 bp_ring_sbm1[0].next = (ring_node_bp*) &bp_ring_sbm1[1];
625 bp_ring_sbm1[0].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1];
626
627 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].next = (ring_node_bp*) &bp_ring_sbm1[0];
628 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_ASM_F0-2];
629
630 for(i=1; i<NB_RING_NODES_BP1_SBM1-1; i++)
631 {
632 bp_ring_sbm1[i].next = (ring_node_bp*) &bp_ring_sbm1[i+1];
633 bp_ring_sbm1[i].previous = (ring_node_bp*) &bp_ring_sbm1[i-1];
634 }
635 //
636 //********
637
638 for (i=0; i<NB_RING_NODES_BP1_SBM1; i++)
639 {
640 init_header_bp( (Header_TM_LFR_SCIENCE_BP_SBM_t*) &bp_ring_sbm1[ i ] );
641 bp_ring_sbm1[ i ].status = 0;
642 }
643 }
644
645 void init_header_bp(Header_TM_LFR_SCIENCE_BP_SBM_t *header )
750 646 {
751 647 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
752 648 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
753 649 header->reserved = 0x00;
754 650 header->userApplication = CCSDS_USER_APP;
755 // header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
756 // header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
651 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
652 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
757 653 header->packetSequenceControl[0] = 0xc0;
758 654 header->packetSequenceControl[1] = 0x00;
759 655 header->packetLength[0] = 0x00;
@@ -776,86 +672,7 void init_header_bp( Header_TM_LFR_SCIEN
776 672 header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB
777 673 }
778 674
779 void fill_averaged_spectral_matrix(void)
780 {
781 /** This function fills spectral matrices related buffers with arbitrary data.
782 *
783 * This function is for testing purpose only.
784 *
785 */
786
787 float offset;
788 float coeff;
789
790 offset = 10.;
791 coeff = 100000.;
792 averaged_sm_f0[ 0 + 25 * 0 ] = 0. + offset;
793 averaged_sm_f0[ 0 + 25 * 1 ] = 1. + offset;
794 averaged_sm_f0[ 0 + 25 * 2 ] = 2. + offset;
795 averaged_sm_f0[ 0 + 25 * 3 ] = 3. + offset;
796 averaged_sm_f0[ 0 + 25 * 4 ] = 4. + offset;
797 averaged_sm_f0[ 0 + 25 * 5 ] = 5. + offset;
798 averaged_sm_f0[ 0 + 25 * 6 ] = 6. + offset;
799 averaged_sm_f0[ 0 + 25 * 7 ] = 7. + offset;
800 averaged_sm_f0[ 0 + 25 * 8 ] = 8. + offset;
801 averaged_sm_f0[ 0 + 25 * 9 ] = 9. + offset;
802 averaged_sm_f0[ 0 + 25 * 10 ] = 10. + offset;
803 averaged_sm_f0[ 0 + 25 * 11 ] = 11. + offset;
804 averaged_sm_f0[ 0 + 25 * 12 ] = 12. + offset;
805 averaged_sm_f0[ 0 + 25 * 13 ] = 13. + offset;
806 averaged_sm_f0[ 0 + 25 * 14 ] = 14. + offset;
807 averaged_sm_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
808 averaged_sm_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
809 averaged_sm_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
810 averaged_sm_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
811 averaged_sm_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
812 averaged_sm_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
813 averaged_sm_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
814 averaged_sm_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
815 averaged_sm_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
816 averaged_sm_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
817 averaged_sm_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
818 averaged_sm_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
819 averaged_sm_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
820 averaged_sm_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
821 averaged_sm_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
822
823 offset = 10000000;
824 averaged_sm_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
825 averaged_sm_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
826 averaged_sm_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
827 averaged_sm_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
828 averaged_sm_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
829 averaged_sm_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
830 averaged_sm_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
831 averaged_sm_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
832 averaged_sm_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
833 averaged_sm_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
834 averaged_sm_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
835 averaged_sm_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
836 averaged_sm_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
837 averaged_sm_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
838 averaged_sm_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
839
840 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_sm_f0[ 0 ];
841 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_sm_f0[ 1 ];
842 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_sm_f0[ 2 ];
843 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_sm_f0[ 3 ];
844 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_sm_f0[ 4 ];
845 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_sm_f0[ 5 ];
846 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_sm_f0[ 6 ];
847 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_sm_f0[ 7 ];
848 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_sm_f0[ 8 ];
849 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_sm_f0[ 9 ];
850 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_sm_f0[ 10 ];
851 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_sm_f0[ 11 ];
852 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_sm_f0[ 12 ];
853 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_sm_f0[ 13 ];
854 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_sm_f0[ 14 ];
855 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_sm_f0[ 15 ];
856 }
857
858 void reset_spectral_matrix_regs()
675 void reset_spectral_matrix_regs( void )
859 676 {
860 677 /** This function resets the spectral matrices module registers.
861 678 *
@@ -532,7 +532,7 int enter_mode( unsigned char mode, unsi
532 532 #endif
533 533 status = restart_science_tasks();
534 534 launch_waveform_picker( mode, transitionCoarseTime );
535 // launch_spectral_matrix_simu( mode );
535 launch_spectral_matrix_simu( mode );
536 536 }
537 537 else if ( mode == LFR_MODE_STANDBY )
538 538 {
@@ -842,7 +842,7 void close_action(ccsdsTelecommandPacket
842 842 updateLFRCurrentMode();
843 843 }
844 844 }
845 else
845 else if (result == LFR_EXE_ERROR)
846 846 {
847 847 send_tm_lfr_tc_exe_error( TC, queue_id );
848 848 }
General Comments 0
You need to be logged in to leave comments. Login now