diff --git a/FSW-qt/fsw-qt.pro b/FSW-qt/fsw-qt.pro --- a/FSW-qt/fsw-qt.pro +++ b/FSW-qt/fsw-qt.pro @@ -20,7 +20,7 @@ SWVERSION=-1-0 DEFINES += SW_VERSION_N1=3 # major DEFINES += SW_VERSION_N2=0 # minor DEFINES += SW_VERSION_N3=0 # patch -DEFINES += SW_VERSION_N4=18 # internal +DEFINES += SW_VERSION_N4=19 # internal # #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage diff --git a/header/fsw_spacewire.h b/header/fsw_spacewire.h --- a/header/fsw_spacewire.h +++ b/header/fsw_spacewire.h @@ -16,6 +16,7 @@ extern spw_stats grspw_stats; extern rtems_name timecode_timer_name; extern rtems_id timecode_timer_id; +extern unsigned char oneTcLfrUpdateTimeReceived; // RTEMS TASK rtems_task spiq_task( rtems_task_argument argument ); @@ -47,10 +48,10 @@ void spw_send_asm_f1( ring_node *ring_no void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); void spw_send_k_dump( ring_node *ring_node_to_send ); -rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data ); unsigned int check_timecode_and_previous_timecode_coherency(unsigned char currentTimecodeCtr); unsigned int check_timecode_and_internal_time_coherency(unsigned char timecode, unsigned char internalTime); void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ); +rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data ); void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc ); diff --git a/header/tc_handler.h b/header/tc_handler.h --- a/header/tc_handler.h +++ b/header/tc_handler.h @@ -13,6 +13,7 @@ #include "lfr_cpu_usage_report.h" extern unsigned int lastValidEnterModeTime; +extern unsigned char oneTcLfrUpdateTimeReceived; //**** // ISR diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -33,6 +33,7 @@ int fdUART = 0; unsigned char lfrCurrentMode; unsigned char pa_bia_status_info; unsigned char thisIsAnASMRestart = 0; +unsigned char oneTcLfrUpdateTimeReceived = 0; // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 // 97 * 256 = 24832 => delta = 248 bytes = 62 words diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -813,51 +813,6 @@ void increase_unsigned_char_counter( uns } } -rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data ) -{ - static unsigned char initStep = 1; - - unsigned char currentTimecodeCtr; - - currentTimecodeCtr = (unsigned char) (grspwPtr[0] & TIMECODE_MASK); - - if (initStep == 1) - { - if (currentTimecodeCtr == previousTimecodeCtr) - { - //************************ - // HK_LFR_TIMECODE_MISSING - // the timecode value has not changed, no valid timecode has been received, the timecode is MISSING - increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing ); - update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING ); - } - else if (currentTimecodeCtr == (previousTimecodeCtr+1)) - { - // the timecode value has changed and the value is valid, this is unexpected because - // the timer should not have fired, the timecode_irq_handler should have been raised - } - else - { - //************************ - // HK_LFR_TIMECODE_INVALID - // the timecode value has changed and the value is not valid, no tickout has been generated - // this is why the timer has fired - increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_invalid ); - update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_INVALID ); - } - } - else - { - initStep = 1; - //************************ - // HK_LFR_TIMECODE_MISSING - increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing ); - update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING ); - } - - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_13 ); -} - unsigned int check_timecode_and_previous_timecode_coherency(unsigned char currentTimecodeCtr) { /** This function checks the coherency between the incoming timecode and the last valid timecode. @@ -967,10 +922,13 @@ void timecode_irq_handler( void *pDev, v //******************** // HK_LFR_TIMECODE_CTR // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 - if (incomingTimecode != updateTime) + if (oneTcLfrUpdateTimeReceived == 1) { - increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_ctr ); - update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_TIMECODE_CTR ); + if ( incomingTimecode != updateTime ) + { + increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_ctr ); + update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_TIMECODE_CTR ); + } } // launch the timecode timer to detect missing or invalid timecodes @@ -982,6 +940,51 @@ void timecode_irq_handler( void *pDev, v } } +rtems_timer_service_routine timecode_timer_routine( rtems_id timer_id, void *user_data ) +{ + static unsigned char initStep = 1; + + unsigned char currentTimecodeCtr; + + currentTimecodeCtr = (unsigned char) (grspwPtr[0] & TIMECODE_MASK); + + if (initStep == 1) + { + if (currentTimecodeCtr == previousTimecodeCtr) + { + //************************ + // HK_LFR_TIMECODE_MISSING + // the timecode value has not changed, no valid timecode has been received, the timecode is MISSING + increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing ); + update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING ); + } + else if (currentTimecodeCtr == (previousTimecodeCtr+1)) + { + // the timecode value has changed and the value is valid, this is unexpected because + // the timer should not have fired, the timecode_irq_handler should have been raised + } + else + { + //************************ + // HK_LFR_TIMECODE_INVALID + // the timecode value has changed and the value is not valid, no tickout has been generated + // this is why the timer has fired + increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_invalid ); + update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_INVALID ); + } + } + else + { + initStep = 1; + //************************ + // HK_LFR_TIMECODE_MISSING + increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing ); + update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING ); + } + + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_13 ); +} + void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) { header->targetLogicalAddress = CCSDS_DESTINATION_ID; diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -206,8 +206,6 @@ int action_enter_mode(ccsdsTelecommandPa { PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); - update_last_valid_transition_date( transitionCoarseTime ); - switch(requestedMode) { case LFR_MODE_STANDBY: @@ -361,6 +359,8 @@ int action_update_time(ccsdsTelecommandP housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); + oneTcLfrUpdateTimeReceived = 1; + return LFR_SUCCESSFUL; } @@ -454,7 +454,7 @@ void update_last_valid_transition_date( if (transitionCoarseTime == 0) { lastValidEnterModeTime = time_management_regs->coarse_time + 1; - PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", transitionCoarseTime); + PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); } else { @@ -681,12 +681,14 @@ int enter_mode_normal( unsigned int tran } break; case LFR_MODE_SBM1: - restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters + status = 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 + update_last_valid_transition_date( transitionCoarseTime ); break; case LFR_MODE_SBM2: - restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters + status = 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 + update_last_valid_transition_date( transitionCoarseTime ); break; default: break; @@ -778,8 +780,9 @@ int enter_mode_sbm1( unsigned int transi } break; case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action - restart_asm_activities( LFR_MODE_SBM1 ); + status = restart_asm_activities( LFR_MODE_SBM1 ); status = LFR_SUCCESSFUL; + update_last_valid_transition_date( transitionCoarseTime ); break; case LFR_MODE_BURST: status = stop_current_mode(); // stop the current mode @@ -791,8 +794,9 @@ int enter_mode_sbm1( unsigned int transi } break; case LFR_MODE_SBM2: - restart_asm_activities( LFR_MODE_SBM1 ); + status = restart_asm_activities( LFR_MODE_SBM1 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action + update_last_valid_transition_date( transitionCoarseTime ); break; default: break; @@ -844,8 +848,9 @@ int enter_mode_sbm2( unsigned int transi } break; case LFR_MODE_NORMAL: - restart_asm_activities( LFR_MODE_SBM2 ); + status = restart_asm_activities( LFR_MODE_SBM2 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action + update_last_valid_transition_date( transitionCoarseTime ); break; case LFR_MODE_BURST: status = stop_current_mode(); // stop the current mode @@ -857,8 +862,9 @@ int enter_mode_sbm2( unsigned int transi } break; case LFR_MODE_SBM1: - restart_asm_activities( LFR_MODE_SBM2 ); + status = restart_asm_activities( LFR_MODE_SBM2 ); status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action + update_last_valid_transition_date( transitionCoarseTime ); break; default: break; @@ -1273,7 +1279,7 @@ void launch_waveform_picker( unsigned ch if (transitionCoarseTime == 0) { // instant transition means transition on the next valid date - // this is mandatory to have a good snapshot period a a good correction of the snapshot period + // this is mandatory to have a good snapshot period and a good correction of the snapshot period waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; } else diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -964,6 +964,7 @@ void snapshot_resynchronization( unsigne static double correction = 0.; static resynchro_state state = MEASURE; + static unsigned int nbSnapshots = 0; int correctionInt; @@ -974,7 +975,7 @@ void snapshot_resynchronization( unsigne case MEASURE: // ******** - PRINTF("MEASURE ===\n"); + PRINTF1("MEASURE === %d\n", nbSnapshots); state = CORRECTION; correction = computeCorrection( timePtr ); PRINTF1("MEASURE === correction = %.2f\n", correction ); @@ -985,7 +986,7 @@ void snapshot_resynchronization( unsigne case CORRECTION: //************ - PRINTF("CORRECTION ===\n"); + PRINTF1("CORRECTION === %d\n", nbSnapshots); state = MEASURE; computeCorrection( timePtr ); correction = -correction; @@ -999,6 +1000,8 @@ void snapshot_resynchronization( unsigne break; } + + nbSnapshots++; } //**************