##// END OF EJS Templates
Sync...
paul -
r116:4710a866a7d2 VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-03T15:58:50. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-07T06:54:09. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -4,12 +4,12
4 #include "fsw_params_processing.h"
4 #include "fsw_params_processing.h"
5
5
6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
7 #define CCSDS_TC_TM_PACKET_OFFSET 7
7 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
8 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
8 #define CCSDS_TM_PKT_MAX_SIZE 4412
9 #define CCSDS_TM_PKT_MAX_SIZE 4412
9 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
10 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
10 #define CCSDS_TC_PKT_MAX_SIZE 256
11 #define CCSDS_TC_PKT_MAX_SIZE 256
11 #define CCSDS_TC_PKT_MIN_SIZE 16
12 #define CCSDS_TC_PKT_MIN_SIZE 16
12 #define CCSDS_TC_TM_PACKET_OFFSET 7
13 #define CCSDS_PROCESS_ID 76
13 #define CCSDS_PROCESS_ID 76
14 #define CCSDS_PACKET_CATEGORY 12
14 #define CCSDS_PACKET_CATEGORY 12
15 #define CCSDS_NODE_ADDRESS 0xfe
15 #define CCSDS_NODE_ADDRESS 0xfe
@@ -20,18 +20,18
20 #define DEFAULT_HKBIA 0x1e // 0001 1110
20 #define DEFAULT_HKBIA 0x1e // 0001 1110
21
21
22 // PACKET ID
22 // PACKET ID
23 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
23 #define APID_TM_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
24 #define APID_TM_HK 0x0cc4 // PID 76 CAT 4
25 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
25 #define APID_TM_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
26 #define APID_TM_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
27 #define APID_TM_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 #define TM_PACKET_PID_DEFAULT 76
28 #define TM_PACKET_PID_DEFAULT 76
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 #define TM_PACKET_CAT_TC_EXE 1
30 #define TM_PACKET_CAT_TC_EXE 1
31 #define TM_PACKET_CAT_HK 4
31 #define TM_PACKET_CAT_HK 4
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 #define TM_PACKET_CAT_SCIENCE 12
33 #define TM_PACKET_CAT_SCIENCE 12
34 #define TC_PACKET_CAT 12
34 #define TC_PACKET_CAT 12
35
35
36 // PACKET SEQUENCE CONTROL
36 // PACKET SEQUENCE CONTROL
37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
@@ -207,7 +207,12 enum apid_destid{
207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 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
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
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_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 25 - 7
211 #define PACKET_LENGTH_TM_LFR_SCIENCE_BURST_BP2_F1 (806 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 30 + 26 - 7
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
212 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26 - 7
214
215 #define PACKET_LENGTH_DELTA 11 // 7 + 4
211
216
212 #define SPARE1_PUSVERSION_SPARE2 0x10
217 #define SPARE1_PUSVERSION_SPARE2 0x10
213
218
@@ -466,9 +471,9 typedef struct {
466 unsigned char sid;
471 unsigned char sid;
467 unsigned char biaStatusInfo;
472 unsigned char biaStatusInfo;
468 unsigned char acquisitionTime[6];
473 unsigned char acquisitionTime[6];
469 unsigned char spare_source_data;
474 unsigned char source_data_spare[2];
470 unsigned char pa_lfr_bp_blk_nr[2];
475 unsigned char pa_lfr_bp_blk_nr[2];
471 } Header_TM_LFR_SCIENCE_BP_NORM_t;
476 } Header_TM_LFR_SCIENCE_BP_with_spare_t;
472
477
473 typedef struct {
478 typedef struct {
474 unsigned char targetLogicalAddress;
479 unsigned char targetLogicalAddress;
@@ -489,7 +494,7 typedef struct {
489 unsigned char biaStatusInfo;
494 unsigned char biaStatusInfo;
490 unsigned char acquisitionTime[6];
495 unsigned char acquisitionTime[6];
491 unsigned char pa_lfr_bp_blk_nr[2];
496 unsigned char pa_lfr_bp_blk_nr[2];
492 } Header_TM_LFR_SCIENCE_BP_SBM_t;
497 } Header_TM_LFR_SCIENCE_BP_t;
493
498
494 typedef struct {
499 typedef struct {
495 //targetLogicalAddress is removed by the grspw module
500 //targetLogicalAddress is removed by the grspw module
@@ -18,36 +18,6 typedef struct ring_node
18 unsigned int status;
18 unsigned int status;
19 } ring_node;
19 } ring_node;
20
20
21 typedef struct ring_node_sm
22 {
23 struct ring_node_sm *previous;
24 int buffer_address;
25 struct ring_node_sm *next;
26 unsigned int status;
27 unsigned int coarseTime;
28 unsigned int fineTime;
29 } ring_node_sm;
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
51 //************************
21 //************************
52 // flight software version
22 // flight software version
53 // this parameters is handled by the Qt project options
23 // this parameters is handled by the Qt project options
@@ -85,15 +55,17 typedef struct
85 #define THR_MODE_NORMAL 1
55 #define THR_MODE_NORMAL 1
86 #define THR_MODE_BURST 2
56 #define THR_MODE_BURST 2
87
57
88 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
89 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
90 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
91 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
92 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
93 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
94 #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6
64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
95 #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7
65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
96 #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
67 #define RTEMS_EVENT_SBM1_BP1_F0 RTEMS_EVENT_9
68 #define RTEMS_EVENT_SBM1_BP2_F0 RTEMS_EVENT_10
97
69
98 //****************************
70 //****************************
99 // LFR DEFAULT MODE PARAMETERS
71 // LFR DEFAULT MODE PARAMETERS
@@ -203,11 +175,11 typedef struct
203 #define TASK_PRIORITY_STAT 200
175 #define TASK_PRIORITY_STAT 200
204 #define TASK_PRIORITY_DUMB 200
176 #define TASK_PRIORITY_DUMB 200
205
177
206 #define ACTION_MSG_QUEUE_COUNT 10
178 #define ACTION_MSG_QUEUE_COUNT 10
207 #define ACTION_MSG_PKTS_COUNT 50
179 #define ACTION_MSG_PKTS_COUNT 50
208 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
180 //#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)
181 #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
210 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
182 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
211
183
212 #define QUEUE_RECV 0
184 #define QUEUE_RECV 0
213 #define QUEUE_SEND 1
185 #define QUEUE_SEND 1
@@ -12,7 +12,8
12 #define NB_RING_NODES_ASM_F0 12 // 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
13 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
14 #define NB_RING_NODES_ASM_F2 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
15 #define NB_RING_NODES_SBM1_BP1 10 // AT LEAST 3
16 #define NB_RING_NODES_SBM1_BP2 5 // AT LEAST 3
16 //
17 //
17 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_PKT_ASM_F0 44
19 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -42,12 +43,15
42 #define NB_BINS_TO_AVERAGE_ASM_F2 8
43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
43 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
44 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
44 //
45 //
45 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
46 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
46 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
49 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
49 #define NB_AVERAGE_NORMAL_F0 384 // 96 * 4
50 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
50 #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second
51 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
51 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
52 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
53 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
54 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
55 #define NB_SM_BEFORE_AVF0 8
52
56
53 #endif // FSW_PARAMS_PROCESSING_H
57 #endif // FSW_PARAMS_PROCESSING_H
@@ -11,6 +11,38
11 #include "fsw_params.h"
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
12 #include "fsw_spacewire.h"
13
13
14 typedef struct ring_node_sm
15 {
16 struct ring_node_sm *previous;
17 int buffer_address;
18 struct ring_node_sm *next;
19 unsigned int status;
20 unsigned int coarseTime;
21 unsigned int fineTime;
22 } ring_node_sm;
23
24 typedef struct ring_node_bp
25 {
26 struct ring_node_bp *previous;
27 struct ring_node_bp *next;
28 unsigned int status;
29 unsigned int coarseTime;
30 unsigned int fineTime;
31 Header_TM_LFR_SCIENCE_BP_t header;
32 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 TM_LFR_SCIENCE_BURST_BP2_F1
33 } ring_node_bp;
34
35 typedef struct ring_node_bp_with_spare
36 {
37 struct ring_node_bp_with_spare *previous;
38 struct ring_node_bp_with_spare *next;
39 unsigned int status;
40 unsigned int coarseTime;
41 unsigned int fineTime;
42 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
43 unsigned char data[ 9 * 22 ];
44 } ring_node_bp_with_spare;
45
14 extern volatile int sm_f0[ ];
46 extern volatile int sm_f0[ ];
15 extern volatile int sm_f1[ ];
47 extern volatile int sm_f1[ ];
16 extern volatile int sm_f2[ ];
48 extern volatile int sm_f2[ ];
@@ -27,6 +59,7 extern rtems_id Task_id[20];
27
59
28 void init_sm_rings( void );
60 void init_sm_rings( void );
29 void reset_current_sm_ring_nodes( void );
61 void reset_current_sm_ring_nodes( void );
62 void reset_current_bp_ring_nodes( void );
30
63
31 // ISR
64 // ISR
32 void reset_nb_sm_f0( void );
65 void reset_nb_sm_f0( void );
@@ -41,7 +74,7 rtems_task matr_task(rtems_task_argument
41 //*****************************
74 //*****************************
42 // Spectral matrices processing
75 // Spectral matrices processing
43
76
44 void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
45 ring_node_sm *ring_node_tab[],
78 ring_node_sm *ring_node_tab[],
46 unsigned int firstTimeF0, unsigned int firstTimeF1 );
79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
47 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
@@ -53,12 +86,23 void ASM_convert(volatile float *input_m
53 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
54 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
55
88
56 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id );
89 void BP_send(char *data,
90 rtems_id queue_id ,
91 unsigned int nbBytesToSend );
57
92
58 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
93 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
59 void init_headers_bp_ring_sbm1();
94 void init_bp_ring_sbm1_bp1( void );
60 void init_header_bp( Header_TM_LFR_SCIENCE_BP_SBM_t *header);
95 void init_bp_ring_sbm1_bp2( void );
96 void init_headers_bp_ring_sbm1_bp1();
97 void init_header_bp(Header_TM_LFR_SCIENCE_BP_t *header,
98 unsigned int apid, unsigned char sid,
99 unsigned int packetLength , unsigned char blkNr);
100 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
101 unsigned int apid, unsigned char sid,
102 unsigned int packetLength, unsigned char blkNr );
61
103
62 void reset_spectral_matrix_regs( void );
104 void reset_spectral_matrix_regs( void );
63
105
106 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime );
107
64 #endif // FSW_PROCESSING_H_INCLUDED
108 #endif // FSW_PROCESSING_H_INCLUDED
@@ -96,8 +96,10 rtems_task Init( rtems_task_argument ign
96 init_local_mode_parameters();
96 init_local_mode_parameters();
97 init_housekeeping_parameters();
97 init_housekeeping_parameters();
98
98
99 init_waveform_rings(); // initialize the waveform rings
99 init_waveform_rings(); // initialize the waveform rings
100 init_sm_rings(); // initialize spectral matrices rings
100 init_sm_rings(); // initialize spectral matrices rings
101 init_bp_ring_sbm1_bp1(); // initialize basic parameter ring for SBM1 BP1 set
102 init_bp_ring_sbm1_bp2(); // initialize basic parameter ring for SBM1 BP2 set
101
103
102 reset_wfp_burst_enable();
104 reset_wfp_burst_enable();
103 reset_wfp_status();
105 reset_wfp_status();
@@ -164,8 +164,8 rtems_task hous_task(rtems_task_argument
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
@@ -374,8 +374,8 void send_dumb_hk( void )
374 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
374 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
375 dummy_hk_packet.reserved = DEFAULT_RESERVED;
375 dummy_hk_packet.reserved = DEFAULT_RESERVED;
376 dummy_hk_packet.userApplication = CCSDS_USER_APP;
376 dummy_hk_packet.userApplication = CCSDS_USER_APP;
377 dummy_hk_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
377 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
378 dummy_hk_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
378 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
379 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
379 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
380 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
380 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
381 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
381 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
@@ -24,20 +24,22 ring_node_sm *current_ring_node_sm_f2;
24 //**********************
24 //**********************
25 // basic parameter rings
25 // basic parameter rings
26 ring_node_bp *current_node_sbm1_bp1_f0;
26 ring_node_bp *current_node_sbm1_bp1_f0;
27 ring_node_bp bp_ring_sbm1[ NB_RING_NODES_BP1_SBM1 ];
27 ring_node_bp *current_node_sbm1_bp2_f0;
28 ring_node_bp bp_ring_sbm1_bp1[ NB_RING_NODES_SBM1_BP1 ];
29 ring_node_bp bp_ring_sbm1_bp2[ NB_RING_NODES_SBM1_BP2 ];
28
30
29 //*****
31 //*****
30 // NORM
32 // NORM
31 // F0
33 // F0
32 float asm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
34 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 float asm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
35 float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ];
34 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
36 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
35 float compressed_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
37 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
36
38
37 //*****
39 //*****
38 // SBM1
40 // SBM1
39 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
41 float asm_sbm1_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
40 float compressed_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
42 float compressed_sm_sbm1[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
41
43
42 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
44 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 ];
45 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
@@ -123,9 +125,10 void reset_current_sm_ring_nodes( void )
123 ring_node_for_averaging_sm_f0 = sm_ring_f0;
125 ring_node_for_averaging_sm_f0 = sm_ring_f0;
124 }
126 }
125
127
126 void reset_current_node_sbm1_bp1_f0( void )
128 void reset_current_bp_ring_nodes( void )
127 {
129 {
128 current_node_sbm1_bp1_f0 = bp_ring_sbm1;
130 current_node_sbm1_bp1_f0 = bp_ring_sbm1_bp1;
131 current_node_sbm1_bp2_f0 = bp_ring_sbm1_bp2;
129 }
132 }
130
133
131 //***********************************************************
134 //***********************************************************
@@ -162,7 +165,7 rtems_isr spectral_matrices_isr( rtems_v
162
165
163 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
166 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
164
167
165 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
168 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
166 {
169 {
167 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
170 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
168 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
171 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -179,7 +182,7 rtems_isr spectral_matrices_isr( rtems_v
179
182
180 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
183 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
181 {
184 {
182 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
185 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
183 {
186 {
184 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
187 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
185 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
188 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -211,64 +214,103 rtems_task smiq_task(rtems_task_argument
211 rtems_task avf0_task(rtems_task_argument argument)
214 rtems_task avf0_task(rtems_task_argument argument)
212 {
215 {
213 int i;
216 int i;
214 static unsigned int nb_average_norm_f0;
217 static unsigned int nb_sm_norm_bp1_f0;
215 static unsigned int nb_average_sbm1_f0;
218 static unsigned int nb_sm_norm_bp2_f0;
219 static unsigned int nb_sm_norm_asm_f0;
220 static unsigned int nb_sm_sbm1_bp1_f0;
221 static unsigned int nb_sm_sbm1_bp2_f0;
216 rtems_event_set event_out;
222 rtems_event_set event_out;
223 rtems_event_set event_for_matr;
217 rtems_status_code status;
224 rtems_status_code status;
218 ring_node_sm *ring_node_tab[8];
225 ring_node_sm *ring_node_tab[8];
219
226
220 nb_average_norm_f0 = 0;
227 nb_sm_norm_bp1_f0 = 0;
221 nb_average_sbm1_f0 = 0;
228 nb_sm_norm_bp2_f0 = 0;
229 nb_sm_norm_asm_f0 = 0;
230 nb_sm_sbm1_bp1_f0 = 0;
231 nb_sm_sbm1_bp2_f0 = 0;
222
232
223 BOOT_PRINTF("in AVFO *** \n")
233 BOOT_PRINTF("in AVFO *** \n")
224
234
225 while(1){
235 while(1){
226 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
236 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
227 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
237 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
228 for ( i = 2; i < (NB_SM_TO_RECEIVE_BEFORE_AVF0+1); i++ )
238 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
229 {
239 {
230 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
240 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
231 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
241 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
232 }
242 }
233
243
234 // copy time information in the asm_f0 buffer
244 // copy time information in the asm_f0 buffer
235 asm_f0[0] = ring_node_tab[7]->coarseTime;
245 asm_norm_f0[0] = ring_node_tab[7]->coarseTime;
236 asm_f0[1] = ring_node_tab[7]->fineTime;
246 asm_norm_f0[1] = ring_node_tab[7]->fineTime;
237 averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime;
247 asm_sbm1_f0[0] = ring_node_tab[7]->coarseTime;
238 averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime;
248 asm_sbm1_f0[1] = ring_node_tab[7]->fineTime;
239
249
240 // compute the average and store it in the averaged_sm_f1 buffer
250 // compute the average and store it in the averaged_sm_f1 buffer
241 ASM_average( asm_f0, averaged_sm_sbm1,
251 SM_average( asm_norm_f0, asm_sbm1_f0,
242 ring_node_tab,
252 ring_node_tab,
243 nb_average_norm_f0, nb_average_sbm1_f0 );
253 nb_sm_norm_bp1_f0, nb_sm_sbm1_bp1_f0 );
244
245
254
246 // update nb_average
255 // update nb_average
247 nb_average_norm_f0 = nb_average_norm_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
256 nb_sm_norm_bp1_f0 = nb_sm_norm_bp1_f0 + NB_SM_BEFORE_AVF0;
248 nb_average_sbm1_f0 = nb_average_sbm1_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
257 nb_sm_norm_bp2_f0 = nb_sm_norm_bp2_f0 + NB_SM_BEFORE_AVF0;
258 nb_sm_norm_asm_f0 = nb_sm_norm_asm_f0 + NB_SM_BEFORE_AVF0;
259 nb_sm_sbm1_bp1_f0 = nb_sm_sbm1_bp1_f0 + NB_SM_BEFORE_AVF0;
260 nb_sm_sbm1_bp2_f0 = nb_sm_sbm1_bp2_f0 + NB_SM_BEFORE_AVF0;
249
261
250 // launch actions depending on the current mode
262 //***********************************************************
263 // build a composite event that will be sent to the MATR task
264 event_for_matr = 0x00;
251
265
252 if (nb_average_sbm1_f0 == NB_AVERAGE_SBM1_F0)
266 if (nb_sm_sbm1_bp1_f0 == NB_SM_BEFORE_SBM1_BP1_F0)
253 {
267 {
254 nb_average_sbm1_f0 = 0;
268 nb_sm_sbm1_bp1_f0 = 0;
255 if (lfrCurrentMode == LFR_MODE_SBM1)
269 if (lfrCurrentMode == LFR_MODE_SBM1)
256 {
270 {
257 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_SBM1 ); // sending an event to the task 7, BPF0
271 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP1_F0;
258 if (status != RTEMS_SUCCESSFUL)
259 {
260 printf("in AVF0 *** Error sending RTEMS_EVENT_MODE_SBM1, code %d\n", status);
261 }
262 }
272 }
263 }
273 }
264
274
265 if (nb_average_norm_f0 == NB_AVERAGE_NORMAL_F0) {
275 if (nb_sm_sbm1_bp2_f0 == NB_SM_BEFORE_SBM1_BP2_F0)
266 nb_average_norm_f0 = 0;
276 {
267 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_NORMAL ); // sending an event to the task 7, BPF0
277 nb_sm_sbm1_bp2_f0 = 0;
268 if (status != RTEMS_SUCCESSFUL) {
278 if (lfrCurrentMode == LFR_MODE_SBM1)
269 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
279 {
280 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP2_F0;
281 }
282 }
283
284 if (nb_sm_norm_bp1_f0 == NB_SM_BEFORE_NORM_BP1_F0) {
285 nb_sm_norm_bp1_f0 = 0;
286 if (lfrCurrentMode == LFR_MODE_NORMAL)
287 {
288 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
270 }
289 }
271 }
290 }
291
292 if (nb_sm_norm_bp2_f0 == NB_SM_BEFORE_NORM_BP2_F0) {
293 nb_sm_norm_bp2_f0 = 0;
294 if (lfrCurrentMode == LFR_MODE_NORMAL)
295 {
296 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
297 }
298 }
299
300 if (nb_sm_norm_asm_f0 == NB_SM_BEFORE_NORM_ASM_F0) {
301 nb_sm_norm_asm_f0 = 0;
302 if (lfrCurrentMode == LFR_MODE_NORMAL)
303 {
304 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
305 }
306 }
307
308 //*********************************
309 // send the composite event to MATR
310 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
311 if (status != RTEMS_SUCCESSFUL) {
312 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
313 }
272 }
314 }
273 }
315 }
274
316
@@ -279,10 +321,16 rtems_task matr_task(rtems_task_argument
279 rtems_status_code status;
321 rtems_status_code status;
280 rtems_id queue_id;
322 rtems_id queue_id;
281 Header_TM_LFR_SCIENCE_ASM_t headerASM;
323 Header_TM_LFR_SCIENCE_ASM_t headerASM;
282 ring_node_norm_bp current_node_norm_bp1_f0;
324 ring_node_bp_with_spare current_node_norm_bp1_f0;
325 ring_node_bp current_node_norm_bp2_f0;
283
326
284 init_header_asm( &headerASM );
327 init_header_asm( &headerASM );
285 // init_header_bp( &current_node_norm_bp1_f0.header );
328 init_header_bp_with_spare( &current_node_norm_bp1_f0.header,
329 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
331 init_header_bp( &current_node_norm_bp2_f0.header,
332 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
333 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
286
334
287 status = get_message_queue_id_send( &queue_id );
335 status = get_message_queue_id_send( &queue_id );
288 if (status != RTEMS_SUCCESSFUL)
336 if (status != RTEMS_SUCCESSFUL)
@@ -293,51 +341,98 rtems_task matr_task(rtems_task_argument
293 BOOT_PRINTF("in MATR *** \n")
341 BOOT_PRINTF("in MATR *** \n")
294
342
295 while(1){
343 while(1){
296 rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1,
344 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
345 | RTEMS_EVENT_SBM1_BP1_F0 | RTEMS_EVENT_SBM1_BP2_F0,
297 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
298 if (event_out==RTEMS_EVENT_MODE_NORMAL)
347 //*****
348 //*****
349 // SBM1
350 //*****
351 //*****
352 if (event_out & RTEMS_EVENT_SBM1_BP1_F0)
299 {
353 {
300 // 1) compress the matrix for Basic Parameters calculation
354 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( asm_f0, compressed_sm_f0,
355 ASM_compress_reorganize_and_divide( asm_sbm1_f0, compressed_sm_sbm1,
302 NB_AVERAGE_NORMAL_F0,
356 NB_SM_BEFORE_SBM1_BP1_F0,
357 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
358 ASM_F0_INDICE_START);
359 // 2) compute the BP1 set
360
361 // 3) send the BP1 set
362 set_time( current_node_sbm1_bp1_f0->header.time,
363 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
364 set_time( current_node_sbm1_bp1_f0->header.acquisitionTime,
365 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
366 BP_send( (char *) &current_node_sbm1_bp1_f0->header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
368 // 4) update current_node_sbm1_bp1_f0
369 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
370 if (event_out & RTEMS_EVENT_SBM1_BP2_F0)
371 {
372 // 1) compute the BP2 set
373
374 // 2) send the BP2 set
375 set_time( current_node_sbm1_bp2_f0->header.time,
376 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
377 set_time( current_node_sbm1_bp2_f0->header.acquisitionTime,
378 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
379 BP_send( (char *) &current_node_sbm1_bp2_f0->header, queue_id,
380 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
381 }
382 }
383
384 //*****
385 //*****
386 // NORM
387 //*****
388 //*****
389 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
390 {
391 // 1) compress the matrix for Basic Parameters calculation
392 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
393 NB_SM_BEFORE_NORM_BP1_F0,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
394 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
395 ASM_F0_INDICE_START );
305 // 2) compute the BP1 set
396 // 2) compute the BP1 set
306
397
307 // 3) send the BP1 set
398 // 3) send the BP1 set
308 BP1_send( &current_node_norm_bp1_f0, SID_NORM_BP1_F0, queue_id );
399 set_time( current_node_norm_bp1_f0.header.time,
309 // 4) reorganize the ASM and divide
400 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
310 ASM_reorganize_and_divide( asm_f0, asm_f0_reorganized, NB_AVERAGE_NORMAL_F0 );
401 set_time( current_node_norm_bp1_f0.header.acquisitionTime,
311 // 5) convert the float array in a char array
402 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
403 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
404 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
405 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
406 {
407 // 1) compute the BP2 set
408
409 // 2) send the BP2 set
410 set_time( current_node_norm_bp2_f0.header.time,
411 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
412 set_time( current_node_norm_bp2_f0.header.acquisitionTime,
413 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
414 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
415 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
416 }
417 }
418
419 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
420 {
421 // 1) reorganize the ASM and divide
422 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
423 // 2) convert the float array in a char array
312 ASM_convert( asm_f0_reorganized, asm_f0_char);
424 ASM_convert( asm_f0_reorganized, asm_f0_char);
313 // 6) send the spectral matrix packets
425 // 3) send the spectral matrix packets
314 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
426 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
315 }
427 }
316 else if (event_out==RTEMS_EVENT_MODE_SBM1)
317 {
318 // 1) compress the matrix for Basic Parameters calculation
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);
323 // 2) compute the BP1 set
324
428
325 // 3) send the basic parameters set 1 packet
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;
329 }
330 else
331 {
332 PRINTF1("ERR *** in MATR *** unexect event = %x\n", (unsigned int) event_out)
333 }
334 }
429 }
335 }
430 }
336
431
337 //*****************************
432 //*****************************
338 // Spectral matrices processing
433 // Spectral matrices processing
339
434
340 void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
435 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
341 ring_node_sm *ring_node_tab[],
436 ring_node_sm *ring_node_tab[],
342 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
437 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
343 {
438 {
@@ -372,7 +467,7 void ASM_average( float *averaged_spec_m
372 }
467 }
373 else
468 else
374 {
469 {
375 PRINTF2("ERR *** in ASM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
470 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
376 }
471 }
377 }
472 }
378 }
473 }
@@ -521,65 +616,15 void ASM_send(Header_TM_LFR_SCIENCE_ASM_
521 }
616 }
522 }
617 }
523
618
524 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id )
619 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
525 {
620 {
526 unsigned int length = 0;
527 rtems_status_code status;
621 rtems_status_code status;
528 unsigned char nbBytesTosend;
529
622
530 // (1) BUILD THE DATA
623 // SEND PACKET
531 switch(sid)
624 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
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;
556 }
557
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;
562
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)
625 if (status != RTEMS_SUCCESSFUL)
581 {
626 {
582 printf("ERR *** in BP1_send *** ERR %d\n", (int) status);
627 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
583 }
628 }
584 }
629 }
585
630
@@ -589,8 +634,8 void init_header_asm( Header_TM_LFR_SCIE
589 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
634 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
590 header->reserved = 0x00;
635 header->reserved = 0x00;
591 header->userApplication = CCSDS_USER_APP;
636 header->userApplication = CCSDS_USER_APP;
592 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
637 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
593 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
638 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
594 header->packetSequenceControl[0] = 0xc0;
639 header->packetSequenceControl[0] = 0xc0;
595 header->packetSequenceControl[1] = 0x00;
640 header->packetSequenceControl[1] = 0x00;
596 header->packetLength[0] = 0x00;
641 header->packetLength[0] = 0x00;
@@ -615,52 +660,87 void init_header_asm( Header_TM_LFR_SCIE
615 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
660 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
616 }
661 }
617
662
618 void init_bp_ring_sbm1()
663 void init_bp_ring_sbm1_bp1( void )
664 {
665 unsigned int i;
666
667 //********
668 // F0 RING
669 bp_ring_sbm1_bp1[0].next = (ring_node_bp*) &bp_ring_sbm1_bp1[1];
670 bp_ring_sbm1_bp1[0].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1];
671
672 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].next = (ring_node_bp*) &bp_ring_sbm1_bp1[0];
673 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-2];
674