LCOV - code coverage report
Current view: top level - src/processing - avf0_prc0.c (source / functions) Hit Total Coverage
Test: trace.info Lines: 120 160 75.0 %
Date: 2023-02-20 11:47:16 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*------------------------------------------------------------------------------
       2             : --  Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
       3             : --  This file is a part of the LFR FSW
       4             : --  Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS
       5             : --
       6             : --  This program is free software; you can redistribute it and/or modify
       7             : --  it under the terms of the GNU General Public License as published by
       8             : --  the Free Software Foundation; either version 2 of the License, or
       9             : --  (at your option) any later version.
      10             : --
      11             : --  This program is distributed in the hope that it will be useful,
      12             : --  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : --  GNU General Public License for more details.
      15             : --
      16             : --  You should have received a copy of the GNU General Public License
      17             : --  along with this program; if not, write to the Free Software
      18             : --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      19             : -------------------------------------------------------------------------------*/
      20             : /*--                  Author : Paul Leroy
      21             : --                   Contact : Alexis Jeandet
      22             : --                      Mail : alexis.jeandet@lpp.polytechnique.fr
      23             : ----------------------------------------------------------------------------*/
      24             : 
      25             : /** Functions related to data processing.
      26             :  *
      27             :  * @file
      28             :  * @author P. LEROY
      29             :  *
      30             :  * These function are related to data processing, i.e. spectral matrices averaging and basic
      31             :  * parameters computation.
      32             :  *
      33             :  */
      34             : #include <string.h>
      35             : 
      36             : #include "avf0_prc0.h"
      37             : #include "fsw_compile_warnings.h"
      38             : #include "fsw_debug.h"
      39             : 
      40             : typedef struct
      41             : {
      42             :     unsigned int norm_bp1;
      43             :     unsigned int norm_bp2;
      44             :     unsigned int norm_asm;
      45             :     unsigned int burst_sbm_bp1;
      46             :     unsigned int burst_sbm_bp2;
      47             :     unsigned int burst_bp1;
      48             :     unsigned int burst_bp2;
      49             :     unsigned int sbm1_bp1;
      50             :     unsigned int sbm1_bp2;
      51             :     unsigned int sbm2_bp1;
      52             :     unsigned int sbm2_bp2;
      53             : } nb_sm_before_bp_asm_f0;
      54             : 
      55             : 
      56             : DISABLE_MISSING_FIELD_INITIALIZER_WARNING
      57             : nb_sm_before_bp_asm_f0 nb_sm_before_f0 = { 0 };
      58             : //***
      59             : // F0
      60             : ring_node_asm asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0] = { { 0 } };
      61             : ring_node_asm asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0] = { { 0 } };
      62             : 
      63             : ring_node ring_to_send_asm_f0[NB_RING_NODES_ASM_F0] = { { 0 } };
      64             : ENABLE_MISSING_FIELD_INITIALIZER_WARNING
      65             : 
      66             : int buffer_asm_f0[NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM] = { 0 };
      67             : 
      68             : float asm_f0_patched_norm[TOTAL_SIZE_SM] = { 0 };
      69             : float asm_f0_patched_burst_sbm[TOTAL_SIZE_SM] = { 0 };
      70             : float asm_f0_reorganized[TOTAL_SIZE_SM] = { 0 };
      71             : 
      72             : float compressed_sm_norm_f0[TOTAL_SIZE_COMPRESSED_ASM_NORM_F0] = { 0 };
      73             : float compressed_sm_sbm_f0[TOTAL_SIZE_COMPRESSED_ASM_SBM_F0] = { 0 };
      74             : 
      75             : 
      76             : //************
      77             : // RTEMS TASKS
      78             : 
      79           4 : LFR_NO_RETURN rtems_task avf0_task(rtems_task_argument lfrRequestedMode)
      80             : {
      81             : 
      82             :     rtems_event_set event_out;
      83             :     rtems_status_code status;
      84             :     rtems_id queue_id_prc0;
      85             :     asm_msg msgForPRC;
      86             :     ring_node* nodeForAveraging;
      87             :     ring_node* ring_node_tab[NB_SM_BEFORE_AVF0_F1];
      88             :     ring_node_asm* current_ring_node_asm_burst_sbm_f0;
      89             :     ring_node_asm* current_ring_node_asm_norm_f0;
      90             : 
      91             :     unsigned int nb_norm_bp1;
      92             :     unsigned int nb_norm_bp2;
      93             :     unsigned int nb_norm_asm;
      94             :     unsigned int nb_sbm_bp1;
      95             :     unsigned int nb_sbm_bp2;
      96             : 
      97           4 :     nb_norm_bp1 = 0;
      98           4 :     nb_norm_bp2 = 0;
      99           4 :     nb_norm_asm = 0;
     100           4 :     nb_sbm_bp1 = 0;
     101           4 :     nb_sbm_bp2 = 0;
     102           4 :     event_out = EVENT_SETS_NONE_PENDING;
     103           4 :     queue_id_prc0 = RTEMS_ID_NONE;
     104             : 
     105           4 :     reset_nb_sm_f0((char)lfrRequestedMode); // reset the sm counters that drive the BP and ASM
     106             :                                             // computations / transmissions
     107           4 :     ASM_generic_init_ring(asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0);
     108           4 :     ASM_generic_init_ring(asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0);
     109           4 :     current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
     110           4 :     current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
     111             : 
     112             :     BOOT_PRINTF("in AVFO *** lfrRequestedMode = %d\n", (int)lfrRequestedMode);
     113             : 
     114           4 :     status = get_message_queue_id_prc0(&queue_id_prc0);
     115           4 :     if (status != RTEMS_SUCCESSFUL)
     116             :     {
     117             :         LFR_PRINTF("in MATR *** ERR get_message_queue_id_prc0 %d\n", status);
     118             :     }
     119             : 
     120             :     while (1)
     121             :     {
     122         111 :         status = rtems_event_receive(
     123             :             RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
     124             :         DEBUG_CHECK_STATUS(status);
     125             : 
     126             :         //****************************************
     127             :         // initialize the mesage for the MATR task
     128         107 :         msgForPRC.norm = current_ring_node_asm_norm_f0;
     129         107 :         msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f0;
     130         107 :         msgForPRC.event
     131             :             = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC0 task
     132             :         //
     133             :         //****************************************
     134             : 
     135         107 :         nodeForAveraging = getRingNodeForAveraging(0);
     136             :         DEBUG_CHECK_PTR(nodeForAveraging);
     137         963 :         for (int i = NB_SM_BEFORE_AVF0_F1 - 1; i >= 0; i--)
     138             :         {
     139         856 :             ring_node_tab[i] = nodeForAveraging;
     140         856 :             nodeForAveraging = nodeForAveraging->previous;
     141             :         }
     142             : 
     143             :         // compute the average and store it in the averaged_sm_f1 buffer
     144         107 :         SM_average(current_ring_node_asm_norm_f0->matrix,
     145             :             current_ring_node_asm_burst_sbm_f0->matrix, ring_node_tab, nb_norm_bp1, nb_sbm_bp1,
     146             :             &msgForPRC, 0, ASM_F0_INDICE_START,
     147             :             ASM_F0_KEEP_BINS); // 0 => frequency channel 0
     148             : 
     149             :         // update nb_average
     150         107 :         nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
     151         107 :         nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
     152         107 :         nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
     153         107 :         nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
     154         107 :         nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
     155             : 
     156         107 :         if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
     157             :         {
     158          15 :             nb_sbm_bp1 = 0;
     159             :             // set another ring for the ASM storage
     160          15 :             current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
     161             :             DEBUG_CHECK_PTR(current_ring_node_asm_burst_sbm_f0);
     162          15 :             if (lfrCurrentMode == LFR_MODE_BURST)
     163             :             {
     164           2 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP1_F0;
     165             :             }
     166          13 :             else if ((lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2))
     167             :             {
     168          11 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP1_F0;
     169             :             }
     170             :         }
     171             : 
     172         107 :         if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
     173             :         {
     174           2 :             nb_sbm_bp2 = 0;
     175           2 :             if (lfrCurrentMode == LFR_MODE_BURST)
     176             :             {
     177           0 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_BURST_BP2_F0;
     178             :             }
     179           2 :             else if ((lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2))
     180             :             {
     181           2 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_SBM_BP2_F0;
     182             :             }
     183             :         }
     184             : 
     185         107 :         if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
     186             :         {
     187           0 :             nb_norm_bp1 = 0;
     188             :             // set another ring for the ASM storage
     189           0 :             current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
     190             :             DEBUG_CHECK_PTR(current_ring_node_asm_norm_f0);
     191           0 :             if ((lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
     192           0 :                 || (lfrCurrentMode == LFR_MODE_SBM2))
     193             :             {
     194           0 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP1_F0;
     195             :             }
     196             :         }
     197             : 
     198         107 :         if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
     199             :         {
     200           0 :             nb_norm_bp2 = 0;
     201           0 :             if ((lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
     202           0 :                 || (lfrCurrentMode == LFR_MODE_SBM2))
     203             :             {
     204           0 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_BP2_F0;
     205             :             }
     206             :         }
     207             : 
     208         107 :         if (nb_norm_asm == nb_sm_before_f0.norm_asm)
     209             :         {
     210           0 :             nb_norm_asm = 0;
     211           0 :             if ((lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
     212           0 :                 || (lfrCurrentMode == LFR_MODE_SBM2))
     213             :             {
     214           0 :                 msgForPRC.event = msgForPRC.event | RTEMS_EVENT_NORM_ASM_F0;
     215             :             }
     216             :         }
     217             : 
     218             :         //*************************
     219             :         // send the message to PRC
     220         107 :         if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
     221             :         {
     222          13 :             status = rtems_message_queue_send(queue_id_prc0, (char*)&msgForPRC, sizeof(asm_msg));
     223             :             DEBUG_CHECK_STATUS(status);
     224             :         }
     225             : 
     226         107 :         if (status != RTEMS_SUCCESSFUL)
     227             :         {
     228             :             LFR_PRINTF("in AVF0 *** Error sending message to PRC, code %d\n", status);
     229             :         }
     230             :     }
     231             : }
     232             : 
     233           4 : LFR_NO_RETURN rtems_task prc0_task(rtems_task_argument lfrRequestedMode)
     234             : {
     235             :     char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
     236             :     size_t size; // size of the incoming TC packet
     237             :     asm_msg* incomingMsg;
     238             :     //
     239             :     rtems_id queue_id;
     240             :     rtems_id queue_id_q_p0;
     241             :     bp_packet_with_spare __attribute__((aligned(4))) packet_norm_bp1;
     242             :     bp_packet __attribute__((aligned(4))) packet_norm_bp2;
     243             :     bp_packet __attribute__((aligned(4))) packet_sbm_bp1;
     244             :     bp_packet __attribute__((aligned(4))) packet_sbm_bp2;
     245             :     ring_node* current_ring_node_to_send_asm_f0;
     246           4 :     float nbSMInASMNORM = 0;
     247           4 :     float nbSMInASMSBM = 0;
     248             : 
     249           4 :     size = 0;
     250           4 :     queue_id = RTEMS_ID_NONE;
     251           4 :     queue_id_q_p0 = RTEMS_ID_NONE;
     252           4 :     memset(&packet_norm_bp1, 0, sizeof(bp_packet_with_spare));
     253           4 :     memset(&packet_norm_bp2, 0, sizeof(bp_packet));
     254           4 :     memset(&packet_sbm_bp1, 0, sizeof(bp_packet));
     255           4 :     memset(&packet_sbm_bp2, 0, sizeof(bp_packet));
     256             : 
     257             :     // init the ring of the averaged spectral matrices which will be transmitted to the DPU
     258           4 :     init_ring(
     259             :         ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*)buffer_asm_f0, TOTAL_SIZE_SM);
     260           4 :     current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
     261             :     DEBUG_CHECK_PTR(current_ring_node_to_send_asm_f0);
     262             : 
     263             :     //*************
     264             :     // NORM headers
     265           4 :     BP_init_header_with_spare(&packet_norm_bp1, APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
     266             :         PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0);
     267           4 :     BP_init_header(&packet_norm_bp2, APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
     268             :         PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
     269             : 
     270             :     //****************************
     271             :     // BURST SBM1 and SBM2 headers
     272           4 :     if (lfrRequestedMode == LFR_MODE_BURST)
     273             :     {
     274           1 :         BP_init_header(&packet_sbm_bp1, APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
     275             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     276           1 :         BP_init_header(&packet_sbm_bp2, APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
     277             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     278             :     }
     279           3 :     else if (lfrRequestedMode == LFR_MODE_SBM1)
     280             :     {
     281           1 :         BP_init_header(&packet_sbm_bp1, APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
     282             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     283           1 :         BP_init_header(&packet_sbm_bp2, APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
     284             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     285             :     }
     286           2 :     else if (lfrRequestedMode == LFR_MODE_SBM2)
     287             :     {
     288           1 :         BP_init_header(&packet_sbm_bp1, APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
     289             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     290           1 :         BP_init_header(&packet_sbm_bp2, APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
     291             :             PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
     292             :     }
     293             :     else
     294             :     {
     295             :         LFR_PRINTF("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n",
     296             :             (unsigned int)lfrRequestedMode);
     297             :     }
     298             : 
     299           4 :     DEBUG_CHECK_STATUS(get_message_queue_id_send(&queue_id));
     300           4 :     DEBUG_CHECK_STATUS(get_message_queue_id_prc0(&queue_id_q_p0));
     301             : 
     302             :     BOOT_PRINTF("in PRC0 *** lfrRequestedMode = %d\n", (int)lfrRequestedMode);
     303             : 
     304             :     while (1)
     305             :     {
     306             :         // wait for a message coming from AVF0
     307          17 :         DEBUG_CHECK_STATUS(rtems_message_queue_receive(
     308             :             queue_id_q_p0, incomingData, &size, RTEMS_WAIT, RTEMS_NO_TIMEOUT));
     309             : 
     310          13 :         incomingMsg = (asm_msg*)incomingData;
     311             :         DEBUG_CHECK_PTR(incomingMsg);
     312             : 
     313             :         //****************
     314             :         //****************
     315             :         // BURST SBM1 SBM2
     316             :         //****************
     317             :         //****************
     318          13 :         if ((incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0)
     319             :             || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0))
     320             :         {
     321          13 :             SM_calibrate_and_reorder_f0(incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm);
     322          13 :             nbSMInASMSBM = (float)incomingMsg->numberOfSMInASMSBM;
     323             : 
     324             :             // 1)  compress the matrix for Basic Parameters calculation
     325          13 :             ASM_compress_divide_and_mask(asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
     326             :                 nbSMInASMSBM, NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
     327             :                 ASM_F0_INDICE_START, CHANNELF0);
     328             :             // 2) compute the BP1 set
     329          13 :             compute_BP1(compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data);
     330             :             // 3) send the BP1 set
     331          13 :             set_time(packet_sbm_bp1.time, (unsigned char*)&incomingMsg->coarseTimeSBM);
     332          13 :             set_time(packet_sbm_bp1.acquisitionTime, (unsigned char*)&incomingMsg->coarseTimeSBM);
     333          13 :             packet_sbm_bp1.pa_bia_status_info = pa_bia_status_info;
     334          13 :             packet_sbm_bp1.sy_lfr_common_parameters
     335          13 :                 = parameter_dump_packet.sy_lfr_common_parameters;
     336          13 :             BP_send_s1_s2((char*)&packet_sbm_bp1, queue_id,
     337             :                 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
     338             :             // 4) compute the BP2 set if needed
     339          13 :             if ((incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0)
     340             :                 || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0))
     341             :             {
     342             :                 // 1) compute the BP2 set
     343           2 :                 compute_BP2(
     344             :                     compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data);
     345             :                 // 2) send the BP2 set
     346           2 :                 set_time(packet_sbm_bp2.time, (unsigned char*)&incomingMsg->coarseTimeSBM);
     347           2 :                 set_time(
     348           2 :                     packet_sbm_bp2.acquisitionTime, (unsigned char*)&incomingMsg->coarseTimeSBM);
     349           2 :                 packet_sbm_bp2.pa_bia_status_info = pa_bia_status_info;
     350           2 :                 packet_sbm_bp2.sy_lfr_common_parameters
     351           2 :                     = parameter_dump_packet.sy_lfr_common_parameters;
     352           2 :                 BP_send_s1_s2((char*)&packet_sbm_bp2, queue_id,
     353             :                     PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
     354             :             }
     355             :         }
     356             : 
     357             :         //*****
     358             :         //*****
     359             :         // NORM
     360             :         //*****
     361             :         //*****
     362          13 :         if ((incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
     363             :             || (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0))
     364             :         {
     365           0 :             SM_calibrate_and_reorder_f0(incomingMsg->norm->matrix, asm_f0_patched_norm);
     366           0 :             nbSMInASMNORM = (float)incomingMsg->numberOfSMInASMNORM;
     367             :         }
     368             : 
     369          13 :         if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
     370             :         {
     371             :             // 1)  compress the matrix for Basic Parameters calculation
     372           0 :             ASM_compress_divide_and_mask(asm_f0_patched_norm, compressed_sm_norm_f0, nbSMInASMNORM,
     373             :                 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, ASM_F0_INDICE_START,
     374             :                 CHANNELF0);
     375             :             // 2) compute the BP1 set
     376           0 :             compute_BP1(compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data);
     377             : 
     378             :             // 3) send the BP1 set
     379           0 :             set_time(packet_norm_bp1.time, (unsigned char*)&incomingMsg->coarseTimeNORM);
     380           0 :             set_time(packet_norm_bp1.acquisitionTime, (unsigned char*)&incomingMsg->coarseTimeNORM);
     381           0 :             packet_norm_bp1.pa_bia_status_info = pa_bia_status_info;
     382           0 :             packet_norm_bp1.sy_lfr_common_parameters
     383           0 :                 = parameter_dump_packet.sy_lfr_common_parameters;
     384           0 :             BP_send((char*)&packet_norm_bp1, queue_id,
     385             :                 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
     386           0 :             if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
     387             :             {
     388             :                 // 1) compute the BP2 set using the same ASM as the one used for BP1
     389           0 :                 compute_BP2(compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data);
     390             :                 // 2) send the BP2 set
     391           0 :                 set_time(packet_norm_bp2.time, (unsigned char*)&incomingMsg->coarseTimeNORM);
     392           0 :                 set_time(
     393           0 :                     packet_norm_bp2.acquisitionTime, (unsigned char*)&incomingMsg->coarseTimeNORM);
     394           0 :                 packet_norm_bp2.pa_bia_status_info = pa_bia_status_info;
     395           0 :                 packet_norm_bp2.sy_lfr_common_parameters
     396           0 :                     = parameter_dump_packet.sy_lfr_common_parameters;
     397           0 :                 BP_send((char*)&packet_norm_bp2, queue_id,
     398             :                     PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
     399             :             }
     400             :         }
     401             : 
     402          13 :         if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
     403             :         {
     404             :             // 1) reorganize the ASM and divide
     405           0 :             ASM_divide(asm_f0_patched_norm,
     406           0 :                 (float*)current_ring_node_to_send_asm_f0->buffer_address, nbSMInASMNORM,
     407             :                 ASM_F0_INDICE_START, ASM_F0_INDICE_START + ASM_F0_KEEP_BINS);
     408           0 :             current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
     409           0 :             current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
     410           0 :             current_ring_node_to_send_asm_f0->packet_id = SID_NORM_ASM_F0;
     411             : 
     412             :             // 3) send the spectral matrix packets
     413           0 :             DEBUG_CHECK_STATUS(rtems_message_queue_send(
     414             :                 queue_id, &current_ring_node_to_send_asm_f0, sizeof(ring_node*)));
     415             : 
     416             :             // change asm ring node
     417           0 :             current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
     418             :         }
     419             : 
     420          13 :         update_queue_max_count(queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max);
     421          13 :     }
     422             : }
     423             : 
     424             : //**********
     425             : // FUNCTIONS
     426             : 
     427           4 : void reset_nb_sm_f0(unsigned char lfrMode)
     428             : {
     429           4 :     nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F0;
     430           4 :     nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F0;
     431           8 :     nb_sm_before_f0.norm_asm = ((parameter_dump_packet.sy_lfr_n_asm_p[0] * 256)
     432           4 :                                    + parameter_dump_packet.sy_lfr_n_asm_p[1])
     433             :         * NB_SM_PER_S_F0;
     434           4 :     nb_sm_before_f0.sbm1_bp1
     435           4 :         = parameter_dump_packet.sy_lfr_s1_bp_p0 * NB_SM_PER_S1_BP_P0; // 0.25 s per digit
     436           4 :     nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * NB_SM_PER_S_F0;
     437           4 :     nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F0;
     438           4 :     nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F0;
     439           4 :     nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F0;
     440           4 :     nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F0;
     441             : 
     442           4 :     if (lfrMode == LFR_MODE_SBM1)
     443             :     {
     444           1 :         nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
     445           1 :         nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
     446             :     }
     447           3 :     else if (lfrMode == LFR_MODE_SBM2)
     448             :     {
     449           1 :         nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
     450           1 :         nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
     451             :     }
     452             :     else // if (lfrMode == LFR_MODE_BURST) Don't know why default is the same than burst
     453             :     {
     454           2 :         nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
     455           2 :         nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
     456             :     }
     457           4 : }

Generated by: LCOV version 1.14