diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters -ff85ce82cd9845f180cb578272717bcb76b62cb5 header/lfr_common_headers +ce0c2f17257170a8529605f68687c18f23973087 header/lfr_common_headers diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h --- a/header/processing/fsw_processing.h +++ b/header/processing/fsw_processing.h @@ -115,14 +115,17 @@ void ASM_generic_init_ring(ring_node_asm void BP_reset_current_ring_nodes( void ); void BP_init_header(bp_packet *packet, - unsigned int apid, unsigned char sid, - unsigned int packetLength , unsigned char blkNr); + unsigned int apid, unsigned char sid, + unsigned int packetLength , unsigned char blkNr); void BP_init_header_with_spare(bp_packet_with_spare *packet, - unsigned int apid, unsigned char sid, - unsigned int packetLength, unsigned char blkNr ); + unsigned int apid, unsigned char sid, + unsigned int packetLength, unsigned char blkNr ); void BP_send( char *data, - rtems_id queue_id , + rtems_id queue_id, unsigned int nbBytesToSend , unsigned int sid ); +void BP_send_s1_s2(char *data, + rtems_id queue_id, + unsigned int nbBytesToSend, unsigned int sid ); //****************** // general functions @@ -143,20 +146,20 @@ static inline void SM_average(float *ave asm_msg *msgForMATR ); static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, - ring_node *ring_node_tab[], - unsigned int nbAverageNORM, unsigned int nbAverageSBM, - asm_msg *msgForMATR ); + ring_node *ring_node_tab[], + unsigned int nbAverageNORM, unsigned int nbAverageSBM, + asm_msg *msgForMATR ); void ASM_patch( float *inputASM, float *outputASM ); void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, - float divider ); + float divider ); static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, - float divider, - unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); + float divider, + unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); @@ -206,15 +209,15 @@ void SM_average( float *averaged_spec_ma averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; -// PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) + // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) } } } void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, - ring_node *ring_node_tab[], - unsigned int nbAverageNORM, unsigned int nbAverageSBM, - asm_msg *msgForMATR ) + ring_node *ring_node_tab[], + unsigned int nbAverageNORM, unsigned int nbAverageSBM, + asm_msg *msgForMATR ) { float sum; unsigned int i; @@ -256,7 +259,7 @@ void ASM_reorganize_and_divide( float *a } void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, - unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) + unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) { int frequencyBin; int asmComponent; @@ -281,7 +284,7 @@ void ASM_compress_reorganize_and_divide( { compressed_spec_mat[offsetCompressed ] = ( compressed_spec_mat[ offsetCompressed ] - + averaged_spec_mat[ offsetASM + k ] ); + + averaged_spec_mat[ offsetASM + k ] ); } compressed_spec_mat[ offsetCompressed ] = compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); @@ -317,8 +320,8 @@ void ASM_convert( volatile float *input_ } void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, - float divider, - unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); + float divider, + unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); int getFBinMask(int k, unsigned char channel); diff --git a/header/tc_handler.h b/header/tc_handler.h --- a/header/tc_handler.h +++ b/header/tc_handler.h @@ -12,7 +12,8 @@ #include "lfr_cpu_usage_report.h" -extern unsigned int lastValidTransitionDate; +extern unsigned int lastValidEnterModeTime; +extern enum lfr_transition_type_t lfrTransitionType; //**** // ISR diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -58,7 +58,8 @@ spectral_matrix_regs_t *spectra // MODE PARAMETERS Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; struct param_local_str param_local; -unsigned int lastValidTransitionDate; +unsigned int lastValidEnterModeTime; +enum lfr_transition_type_t lfrTransitionType; // HK PACKETS Packet_TM_LFR_HK_t housekeeping_packet; diff --git a/src/processing/avf0_prc0.c b/src/processing/avf0_prc0.c --- a/src/processing/avf0_prc0.c +++ b/src/processing/avf0_prc0.c @@ -285,7 +285,7 @@ rtems_task prc0_task( rtems_task_argumen set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); packet_sbm_bp1.biaStatusInfo = pa_bia_status_info; packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; - BP_send( (char *) &packet_sbm_bp1, queue_id, + BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id, PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, sid); // 4) compute the BP2 set if needed @@ -298,7 +298,7 @@ rtems_task prc0_task( rtems_task_argumen set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); packet_sbm_bp2.biaStatusInfo = pa_bia_status_info; packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; - BP_send( (char *) &packet_sbm_bp2, queue_id, + BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id, PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, sid); } diff --git a/src/processing/avf1_prc1.c b/src/processing/avf1_prc1.c --- a/src/processing/avf1_prc1.c +++ b/src/processing/avf1_prc1.c @@ -280,7 +280,7 @@ rtems_task prc1_task( rtems_task_argumen set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); packet_sbm_bp1.biaStatusInfo = pa_bia_status_info; packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; - BP_send( (char *) &packet_sbm_bp1, queue_id_send, + BP_send_s1_s2( (char *) &packet_sbm_bp1, queue_id_send, PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, sid ); // 4) compute the BP2 set if needed @@ -293,7 +293,7 @@ rtems_task prc1_task( rtems_task_argumen set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); packet_sbm_bp2.biaStatusInfo = pa_bia_status_info; packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; - BP_send( (char *) &packet_sbm_bp2, queue_id_send, + BP_send_s1_s2( (char *) &packet_sbm_bp2, queue_id_send, PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, sid ); } diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c --- a/src/processing/fsw_processing.c +++ b/src/processing/fsw_processing.c @@ -386,6 +386,34 @@ void BP_send(char *data, rtems_id queue_ } } +void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) +{ + /** This function is used to send the BP paquets when needed. + * + * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE + * + * @return void + * + * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition. + * BURST paquets are sent everytime. + * + */ + + rtems_status_code status; + + // SEND PACKET + // before lastValidTransitionDate, the data are drops even if they are ready + // this guarantees that no SBM packets will be received before the requestion enter mode time + if ( time_management_regs->coarse_time >= lastValidEnterModeTime) + { + status = rtems_message_queue_send( queue_id, data, nbBytesToSend); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) + } + } +} + //****************** // general functions diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -206,7 +206,7 @@ int action_enter_mode(ccsdsTelecommandPa { PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); - + update_last_valid_transition_date( transitionCoarseTime ); switch(requestedMode) { @@ -446,7 +446,7 @@ int check_mode_transition( unsigned char void update_last_valid_transition_date(unsigned int transitionCoarseTime) { - lastValidTransitionDate = transitionCoarseTime; + lastValidEnterModeTime = transitionCoarseTime; } int check_transition_date( unsigned int transitionCoarseTime ) @@ -607,6 +607,7 @@ int enter_mode_standby() int status; status = stop_current_mode(); // STOP THE CURRENT MODE + lfrTransitionType = TRANSITION_NOT_SPECIFIC; #ifdef PRINT_TASK_STATISTICS rtems_cpu_usage_report(); @@ -648,6 +649,7 @@ int enter_mode_normal( unsigned int tran switch( lfrCurrentMode ) { case LFR_MODE_STANDBY: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules { @@ -656,6 +658,7 @@ int enter_mode_normal( unsigned int tran } break; case LFR_MODE_BURST: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = stop_current_mode(); // stop the current mode status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules @@ -665,10 +668,12 @@ int enter_mode_normal( unsigned int tran } break; case LFR_MODE_SBM1: + lfrTransitionType = TRANSITION_S1_TO_NORM; restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action break; case LFR_MODE_SBM2: + lfrTransitionType = TRANSITION_S2_TO_NORM; restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action break; @@ -708,6 +713,7 @@ int enter_mode_burst( unsigned int trans rtems_cpu_usage_reset(); #endif + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = stop_current_mode(); // stop the current mode status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules @@ -754,6 +760,7 @@ int enter_mode_sbm1( unsigned int transi switch( lfrCurrentMode ) { case LFR_MODE_STANDBY: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules { @@ -762,10 +769,12 @@ int enter_mode_sbm1( unsigned int transi } break; case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action + lfrTransitionType = TRANSITION_NORM_TO_S1; restart_asm_activities( LFR_MODE_SBM1 ); status = LFR_SUCCESSFUL; break; case LFR_MODE_BURST: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = stop_current_mode(); // stop the current mode status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules @@ -775,6 +784,7 @@ int enter_mode_sbm1( unsigned int transi } break; case LFR_MODE_SBM2: + lfrTransitionType = TRANSITION_S2_TO_S1; restart_asm_activities( LFR_MODE_SBM1 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action break; @@ -820,6 +830,7 @@ int enter_mode_sbm2( unsigned int transi switch( lfrCurrentMode ) { case LFR_MODE_STANDBY: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules { @@ -828,10 +839,12 @@ int enter_mode_sbm2( unsigned int transi } break; case LFR_MODE_NORMAL: + lfrTransitionType = TRANSITION_NORM_TO_S2; restart_asm_activities( LFR_MODE_SBM2 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action break; case LFR_MODE_BURST: + lfrTransitionType = TRANSITION_NOT_SPECIFIC; status = stop_current_mode(); // stop the current mode status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules @@ -841,6 +854,7 @@ int enter_mode_sbm2( unsigned int transi } break; case LFR_MODE_SBM1: + lfrTransitionType = TRANSITION_S1_TO_S2; restart_asm_activities( LFR_MODE_SBM2 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action break;