# HG changeset patch # User paul # Date 2016-01-22 16:15:42 # Node ID 43d4aa6b88297e598c24445a2369275ca88320a4 # Parent c648c60c0eef8f08f3fede224720bdcb93d0d044 hk_lfr_time_not_synchro is updated each time the synchro is lost. hk_lfr_timecode_erroneous is updated after the reception of the second valid timecode to avoid errors at startup diff --git a/header/fsw_misc.h b/header/fsw_misc.h --- a/header/fsw_misc.h +++ b/header/fsw_misc.h @@ -61,6 +61,7 @@ void set_hk_lfr_mag_fields_flag( bool st void set_hk_lfr_calib_enable( bool state ); void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); void hk_lfr_le_me_he_update(); +void set_hk_lfr_time_not_synchro(); extern int sched_yield( void ); extern void rtems_cpu_usage_reset(); diff --git a/header/fsw_spacewire.h b/header/fsw_spacewire.h --- a/header/fsw_spacewire.h +++ b/header/fsw_spacewire.h @@ -33,7 +33,7 @@ void spacewire_set_NP( unsigned char val void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable void spacewire_compute_stats_offsets( void ); void spacewire_update_statistics( void ); -void increase_an_unsigned_char_counter( unsigned char *counter ); +void increase_unsigned_char_counter( unsigned char *counter ); void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ); void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ); diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -298,6 +298,8 @@ rtems_task hous_task(rtems_task_argument hk_lfr_le_me_he_update(); + set_hk_lfr_time_not_synchro(); + housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; @@ -679,6 +681,11 @@ void hk_lfr_le_me_he_update() + housekeeping_packet.hk_lfr_dpu_spw_write_sync + housekeeping_packet.hk_lfr_dpu_spw_rx_ahb + housekeeping_packet.hk_lfr_dpu_spw_tx_ahb + + housekeeping_packet.hk_lfr_timecode_erroneous + + housekeeping_packet.hk_lfr_timecode_missing + + housekeeping_packet.hk_lfr_timecode_invalid + + housekeeping_packet.hk_lfr_time_timecode_it + + housekeeping_packet.hk_lfr_time_not_synchro + housekeeping_packet.hk_lfr_time_timecode_ctr; //update the medium severity error counter @@ -703,3 +710,33 @@ void hk_lfr_le_me_he_update() housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff); } + +void set_hk_lfr_time_not_synchro() +{ + static unsigned char synchroLost = 0; + int synchronizationBit; + + // get the synchronization bit + synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000 + + switch (synchronizationBit) + { + case 0: + if (synchroLost == 1) + { + synchroLost = 0; + } + break; + case 1: + if (synchroLost == 0 ) + { + synchroLost = 1; + increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); + } + break; + default: + PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); + break; + } + +} diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -707,31 +707,40 @@ rtems_timer_service_routine timecode_tim unsigned int check_timecode_and_previous_timecode_coherency(unsigned char currentTimecodeCtr) { + static unsigned char firstTickout = 1; unsigned char ret; ret = LFR_DEFAULT; - if (currentTimecodeCtr == 0) + if (firstTickout == 0) { - if (previousTimecodeCtr == 63) + if (currentTimecodeCtr == 0) { - ret = LFR_SUCCESSFUL; + if (previousTimecodeCtr == 63) + { + ret = LFR_SUCCESSFUL; + } + else + { + ret = LFR_DEFAULT; + } } else { - ret = LFR_DEFAULT; + if (currentTimecodeCtr == (previousTimecodeCtr +1)) + { + ret = LFR_SUCCESSFUL; + } + else + { + ret = LFR_DEFAULT; + } } } else { - if (currentTimecodeCtr == (previousTimecodeCtr +1)) - { - ret = LFR_SUCCESSFUL; - } - else - { - ret = LFR_DEFAULT; - } + firstTickout = 0; + ret = LFR_SUCCESSFUL; } return ret; @@ -778,7 +787,7 @@ void timecode_irq_handler( void *pDev, v // MISSING and INVALID are handled by the timecode_timer_routine service routine if (check_timecode_and_previous_timecode_coherency( incomingTimecode ) == LFR_DEFAULT) { - // this is unexpected but a tickout has been raised and the timecode is erroneous + // this is unexpected but a tickout could have been raised despite of the timecode being erroneous increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_erroneous ); }