# HG changeset patch # User paul # Date 2014-03-04 11:59:13 # Node ID e5b7ab03049c83fb447fb2e673720bbd61efd7cb # Parent b24459a013ed605e74c4d86c45ee3161df7d6d36 rev 1.0.0.2 to be used with VHDL 0.0.10 all issues in redmine, pc-instru and hephaistos addressed issues are either resolved or in progress diff --git a/.hgsub b/.hgsub --- a/.hgsub +++ b/.hgsub @@ -1,1 +1,1 @@ -src/basic_parameters = https://leroy@hephaistos.lpp.polytechnique.fr/rhodecode/HG_REPOSITORIES/LPP/INSTRUMENTATION/SOLO_LFR/LFR_basic-parameters +src/basic_parameters = https://hephaistos.lpp.polytechnique.fr/rhodecode/HG_REPOSITORIES/LPP/INSTRUMENTATION/SOLO_LFR/LFR_basic-parameters diff --git a/FSW-qt/Makefile b/FSW-qt/Makefile --- a/FSW-qt/Makefile +++ b/FSW-qt/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bin/fsw -# Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Feb 21 15:32:25 2014 +# Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 4 09:15:37 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro @@ -10,7 +10,7 @@ CC = sparc-rtems-gcc CXX = sparc-rtems-g++ -DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=2 -DPRINT_MESSAGES_ON_CONSOLE +DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=2 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters 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 @@ -1,7 +1,7 @@ TEMPLATE = app # CONFIG += console v8 sim # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report -CONFIG += console verbose +CONFIG += console verbose debug_messages CONFIG -= qt include(./sparc.pri) @@ -69,7 +69,6 @@ HEADERS += \ ../header/ccsds_types.h \ ../header/fsw_params_processing.h \ ../header/fsw_spacewire.h \ - ../header/tm_byte_positions.h \ ../header/tc_load_dump_parameters.h \ ../header/tm_lfr_tc_exe.h \ ../header/tc_acceptance.h \ diff --git a/FSW-qt/fsw-qt.pro.user b/FSW-qt/fsw-qt.pro.user --- a/FSW-qt/fsw-qt.pro.user +++ b/FSW-qt/fsw-qt.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/header/ccsds_types.h b/header/ccsds_types.h --- a/header/ccsds_types.h +++ b/header/ccsds_types.h @@ -123,7 +123,7 @@ #define CCSDS_TM_VALID 7 // TC SID -#define SID_TC_GROUND 0 +#define SID_TC_GROUND 0 #define SID_TC_MISSION_TIMELINE 110 #define SID_TC_TC_SEQUENCES 111 #define SID_TC_RECOVERY_ACTION_CMD 112 diff --git a/header/fsw_init.h b/header/fsw_init.h --- a/header/fsw_init.h +++ b/header/fsw_init.h @@ -30,6 +30,7 @@ rtems_status_code get_message_queue_id_r int start_recv_send_tasks( void ); // void init_local_mode_parameters( void ); +void reset_local_time( void ); extern int rtems_cpu_usage_report( void ); extern int rtems_cpu_usage_reset( void ); diff --git a/header/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -3,6 +3,7 @@ #include "grlib_regs.h" #include "fsw_params_processing.h" +#include "fsw_params_nb_bytes.h" #include "tm_byte_positions.h" #include "ccsds_types.h" @@ -40,12 +41,22 @@ typedef struct ring_node //********** // LFR MODES -#define LFR_MODE_STANDBY 0 -#define LFR_MODE_NORMAL 1 -#define LFR_MODE_BURST 2 -#define LFR_MODE_SBM1 3 -#define LFR_MODE_SBM2 4 -#define LFR_MODE_NORMAL_CWF_F3 5 +#define LFR_MODE_STANDBY 0 +#define LFR_MODE_NORMAL 1 +#define LFR_MODE_BURST 2 +#define LFR_MODE_SBM1 3 +#define LFR_MODE_SBM2 4 + +#define TDS_MODE_LFM 5 +#define TDS_MODE_STANDBY 0 +#define TDS_MODE_NORMAL 1 +#define TDS_MODE_BURST 2 +#define TDS_MODE_SBM1 3 +#define TDS_MODE_SBM2 4 + +#define THR_MODE_STANDBY 0 +#define THR_MODE_NORMAL 1 +#define THR_MODE_BURST 2 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 @@ -116,7 +127,9 @@ typedef struct ring_node // TIME #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms #define TIMER_SM_SIMULATOR 1 -#define HK_PERIOD 100 // 100 * 10ms => 1sec +#define HK_PERIOD 100 // 100 * 10ms => 1s +#define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 +#define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s //********** // LPP CODES diff --git a/header/fsw_params_nb_bytes.h b/header/fsw_params_nb_bytes.h --- a/header/fsw_params_nb_bytes.h +++ b/header/fsw_params_nb_bytes.h @@ -11,6 +11,7 @@ #define BYTE_POS_SY_LFR_N_ASM_P 4 #define BYTE_POS_SY_LFR_N_BP_P0 6 #define BYTE_POS_SY_LFR_N_BP_P1 7 +#define BYTE_POS_SY_LFR_N_CWF_LONG_F3 8 // TC_LFR_LOAD_BURST_PAR @@ -18,5 +19,8 @@ // TC_LFR_LOAD_SBM2_PAR +// TC_LFR_UPDATE_INFO +#define BYTE_POS_HK_UPDATE_INFO_PAR_SET5 24 // 34 - 10 +#define BYTE_POS_HK_UPDATE_INFO_PAR_SET6 25 // 35 - 10 #endif // TM_BYTE_POSITIONS_H diff --git a/header/tc_acceptance.h b/header/tc_acceptance.h --- a/header/tc_acceptance.h +++ b/header/tc_acceptance.h @@ -14,7 +14,7 @@ void GetCRCAsTwoBytes(unsigned char* dat // ACCEPTANCE FUNCTIONS int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC); int tc_check_type( unsigned char packetType ); -int tc_check_subtype( unsigned char packetType ); +int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ); int tc_check_sid( unsigned char sid ); int tc_check_length( unsigned char packetType, unsigned int length ); int tc_check_crc(ccsdsTelecommandPacket_t * TCPacket, unsigned int length , unsigned char *computed_CRC); diff --git a/header/tc_handler.h b/header/tc_handler.h --- a/header/tc_handler.h +++ b/header/tc_handler.h @@ -45,9 +45,9 @@ void launch_spectral_matrix_simu( unsign // other functions void updateLFRCurrentMode(); -void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time); -void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time); -void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time); +void update_last_TC_exe(ccsdsTelecommandPacket_t *TC ); +void update_last_TC_rej(ccsdsTelecommandPacket_t *TC ); +void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); diff --git a/header/tc_load_dump_parameters.h b/header/tc_load_dump_parameters.h --- a/header/tc_load_dump_parameters.h +++ b/header/tc_load_dump_parameters.h @@ -23,6 +23,11 @@ int set_sy_lfr_n_bp_p0( ccsdsTelecommand int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); +// TC_LFR_UPDATE_INFO +unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); +unsigned int check_update_info_hk_tds_mode( unsigned char mode ); +unsigned int check_update_info_hk_thr_mode( unsigned char mode ); + void init_parameter_dump( void ); #endif // TC_LOAD_DUMP_PARAMETERS_H diff --git a/header/tm_lfr_tc_exe.h b/header/tm_lfr_tc_exe.h --- a/header/tm_lfr_tc_exe.h +++ b/header/tm_lfr_tc_exe.h @@ -9,14 +9,14 @@ extern unsigned short sequenceCounters_TC_EXE[]; -int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, - unsigned char byte_position, unsigned char rcv_value, unsigned char *time); -int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, - unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID, unsigned char *time); +int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); +int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, + unsigned char byte_position, unsigned char rcv_value ); +int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); +int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); +int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); +int send_tm_lfr_tc_exe_corrupted( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, + unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID ); void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id ); diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -70,6 +70,7 @@ rtems_task Init( rtems_task_argument ign * */ + reset_local_time(); rtems_status_code status; rtems_status_code status_spw; @@ -224,6 +225,11 @@ void init_local_mode_parameters( void ) sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; } +void reset_local_time( void ) +{ + +} + void create_names( void ) // create all names for tasks and queues { /** This function creates all RTEMS names used in the software for tasks and queues. diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -143,6 +143,7 @@ rtems_task hous_task(rtems_task_argument { rtems_status_code status; rtems_id queue_id; + rtems_rate_monotonic_period_status period_status; status = get_message_queue_id_send( &queue_id ); if (status != RTEMS_SUCCESSFUL) @@ -183,6 +184,25 @@ rtems_task hous_task(rtems_task_argument DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") } + // startup phase + status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); + status = rtems_rate_monotonic_get_status( HK_id, &period_status ); + DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) + while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway + { + if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization + { + break; // break if LFR is synchronized + } + else + { + status = rtems_rate_monotonic_get_status( HK_id, &period_status ); + sched_yield(); + } + } + status = rtems_rate_monotonic_cancel(HK_id); + DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) + while(1){ // launch the rate monotonic task status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); if ( status != RTEMS_SUCCESSFUL ) { diff --git a/src/fsw_processing.c b/src/fsw_processing.c --- a/src/fsw_processing.c +++ b/src/fsw_processing.c @@ -186,6 +186,9 @@ rtems_task avf0_task(rtems_task_argument ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous; ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; } + + averaged_sm_f0[0] = ( (int *) (ring_node_tab[7]->buffer_address) ) [0]; + averaged_sm_f0[1] = ( (int *) (ring_node_tab[7]->buffer_address) ) [1]; for(i=0; ibuffer_address) ) [i + TIME_OFFSET] diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -174,10 +174,10 @@ rtems_task recv_task( rtems_task_argumen destinationID = currentTC.sourceID; } getTime( time ); - close_action( ¤tTC, LFR_DEFAULT, queue_send_id, time); + close_action( ¤tTC, LFR_DEFAULT, queue_send_id ); send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, computed_CRC, currentTC_LEN_RCV, - destinationID, time ); + destinationID ); } } else diff --git a/src/tc_acceptance.c b/src/tc_acceptance.c --- a/src/tc_acceptance.c +++ b/src/tc_acceptance.c @@ -160,7 +160,7 @@ int tc_parser(ccsdsTelecommandPacket_t * } if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE { - status = tc_check_subtype( packetSubtype ); + status = tc_check_type_subtype( packetType, packetSubtype ); } if (status == CCSDS_TM_VALID) // CHECK THE SID { @@ -203,10 +203,11 @@ int tc_check_type( unsigned char packetT return status; } -int tc_check_subtype( unsigned char packetSubType ) +int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ) { - /** This function checks that the subtype of a TeleCommand is valid. + /** This function checks that the subtype of a TeleCommand is valid and coherent with the type. * + * @param packetType is the type of the TC. * @param packetSubType is the subtype to check. * * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. @@ -215,20 +216,40 @@ int tc_check_subtype( unsigned char pack int status; - if ( (packetSubType == TC_SUBTYPE_RESET) - || (packetSubType == TC_SUBTYPE_LOAD_COMM) - || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) - || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) - || (packetSubType == TC_SUBTYPE_DUMP) - || (packetSubType == TC_SUBTYPE_ENTER) - || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME) - || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) + switch(packetType) { - status = CCSDS_TM_VALID; - } - else - { + case TC_TYPE_GEN: + if ( (packetSubType == TC_SUBTYPE_RESET) + || (packetSubType == TC_SUBTYPE_LOAD_COMM) + || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) + || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) + || (packetSubType == TC_SUBTYPE_DUMP) + || (packetSubType == TC_SUBTYPE_ENTER) + || (packetSubType == TC_SUBTYPE_UPDT_INFO) + || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) + { + status = CCSDS_TM_VALID; + } + else + { + status = ILL_SUBTYPE; + } + break; + + case TC_TYPE_TIME: + if (packetSubType == TC_SUBTYPE_UPDT_TIME) + { + status = CCSDS_TM_VALID; + } + else + { + status = ILL_SUBTYPE; + } + break; + + default: status = ILL_SUBTYPE; + break; } return status; @@ -246,8 +267,7 @@ int tc_check_sid( unsigned char sid ) int status; - if ( (sid == SID_TC_GROUND) - || (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) + if ( (sid == SID_TC_MISSION_TIMELINE) || (sid == SID_TC_TC_SEQUENCES) || (sid == SID_TC_RECOVERY_ACTION_CMD) || (sid == SID_TC_BACKUP_MISSION_TIMELINE) || (sid == SID_TC_DIRECT_CMD) || (sid == SID_TC_SPARE_GRD_SRC1) || (sid == SID_TC_SPARE_GRD_SRC2) || (sid == SID_TC_OBCP) || (sid == SID_TC_SYSTEM_CONTROL) || (sid == SID_TC_AOCS) diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -68,62 +68,62 @@ rtems_task actn_task( rtems_task_argumen { case TC_SUBTYPE_RESET: result = action_reset( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_LOAD_COMM: result = action_load_common_par( &TC ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_LOAD_NORM: result = action_load_normal_par( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_LOAD_BURST: result = action_load_burst_par( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_LOAD_SBM1: result = action_load_sbm1_par( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_LOAD_SBM2: result = action_load_sbm2_par( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_DUMP: result = action_dump_par( queue_snd_id ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_ENTER: result = action_enter_mode( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_UPDT_INFO: result = action_update_info( &TC, queue_snd_id ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_EN_CAL: result = action_enable_calibration( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_DIS_CAL: result = action_disable_calibration( &TC, queue_snd_id, time ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // case TC_SUBTYPE_UPDT_TIME: result = action_update_time( &TC ); - close_action( &TC, result, queue_snd_id, time ); + close_action( &TC, result, queue_snd_id ); break; // default: @@ -168,7 +168,7 @@ int action_enter_mode(ccsdsTelecommandPa && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) { status = RTEMS_UNSATISFIED; - send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time ); + send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); } else { @@ -190,7 +190,7 @@ int action_enter_mode(ccsdsTelecommandPa else { PRINTF("ERR *** in action_enter *** transition rejected\n") - send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); + send_tm_lfr_tc_exe_not_executable( TC, queue_id ); } } @@ -212,14 +212,32 @@ int action_update_info(ccsdsTelecommandP unsigned int val; int result; - - result = LFR_SUCCESSFUL; + unsigned int status; + unsigned char mode; - val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 - + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; - val++; - housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); - housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); + // check LFR MODE + mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1; + status = check_update_info_hk_lfr_mode( mode ); + if (status != LFR_DEFAULT) // check TDS mode + { + mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4; + status = check_update_info_hk_tds_mode( mode ); + } + if (status != LFR_DEFAULT) // check THR mode + { + mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f); + status = check_update_info_hk_thr_mode( mode ); + } + if (status != LFR_DEFAULT) // if the parameter check is successful + { + val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 + + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; + val++; + housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); + housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); + } + + result = status; return result; } @@ -239,14 +257,9 @@ int action_enable_calibration(ccsdsTelec result = LFR_DEFAULT; lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { - send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); - result = LFR_DEFAULT; - } - else { - send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); - result = LFR_DEFAULT; - } + send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); + result = LFR_DEFAULT; + return result; } @@ -265,14 +278,9 @@ int action_disable_calibration(ccsdsTele result = LFR_DEFAULT; lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { - send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); - result = LFR_DEFAULT; - } - else { - send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); - result = LFR_DEFAULT; - } + send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); + result = LFR_DEFAULT; + return result; } @@ -642,7 +650,7 @@ void launch_spectral_matrix_simu( unsign //**************** // CLOSING ACTIONS -void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time) +void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) { /** This function is used to update the HK packets statistics after a successful TC execution. * @@ -657,15 +665,15 @@ void update_last_TC_exe(ccsdsTelecommand housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; - housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; - housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; - housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; - housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; - housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; - housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; + housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); + housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); + housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); } -void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time) +void update_last_TC_rej(ccsdsTelecommandPacket_t *TC ) { /** This function is used to update the HK packets statistics after a TC rejection. * @@ -680,15 +688,15 @@ void update_last_TC_rej(ccsdsTelecommand housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; - housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; - housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; - housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; - housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; - housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; - housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; + housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); + housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); + housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); } -void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time) +void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) { /** This function is the last step of the TC execution workflow. * @@ -708,9 +716,9 @@ void close_action(ccsdsTelecommandPacket !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) ) { - send_tm_lfr_tc_exe_success( TC, queue_id, time ); + send_tm_lfr_tc_exe_success( TC, queue_id ); } - update_last_TC_exe( TC, time ); + update_last_TC_exe( TC ); val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; val++; housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); @@ -718,7 +726,7 @@ void close_action(ccsdsTelecommandPacket } else { - update_last_TC_rej( TC, time ); + update_last_TC_rej( TC ); val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; val++; housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); diff --git a/src/tc_load_dump_parameters.c b/src/tc_load_dump_parameters.c --- a/src/tc_load_dump_parameters.c +++ b/src/tc_load_dump_parameters.c @@ -46,7 +46,7 @@ int action_load_normal_par(ccsdsTelecomm if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { - status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); + status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); flag = LFR_DEFAULT; } @@ -136,7 +136,7 @@ int action_load_burst_par(ccsdsTelecomma lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; if ( lfrMode == LFR_MODE_BURST ) { - status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); + status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); result = LFR_DEFAULT; } else { @@ -165,7 +165,7 @@ int action_load_sbm1_par(ccsdsTelecomman lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { - status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); + status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); result = LFR_DEFAULT; } else { @@ -194,8 +194,8 @@ int action_load_sbm2_par(ccsdsTelecomman result = LFR_DEFAULT; lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) { - status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); + if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { + status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); result = LFR_DEFAULT; } else { @@ -271,7 +271,7 @@ int set_sy_lfr_n_swf_l( ccsdsTelecommand if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 { // 2048 is the maximum limit due to the size of the buffers - status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb, time ); + status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb ); result = WRONG_APP_DATA; } else if (tmp != 2048) @@ -311,7 +311,7 @@ int set_sy_lfr_n_swf_p(ccsdsTelecommandP if ( tmp < 16 ) { - status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb, time ); + status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb ); result = WRONG_APP_DATA; } else @@ -410,6 +410,62 @@ int set_sy_lfr_n_cwf_long_f3(ccsdsTeleco //********************* // SBM2 MODE PARAMETERS +//******************* +// TC_LFR_UPDATE_INFO +unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) +{ + unsigned int status; + + if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) + || (mode = LFR_MODE_BURST) + || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) + { + status = LFR_SUCCESSFUL; + } + else + { + status = LFR_DEFAULT; + } + + return status; +} + +unsigned int check_update_info_hk_tds_mode( unsigned char mode ) +{ + unsigned int status; + + if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) + || (mode = TDS_MODE_BURST) + || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) + || (mode == TDS_MODE_LFM)) + { + status = LFR_SUCCESSFUL; + } + else + { + status = LFR_DEFAULT; + } + + return status; +} + +unsigned int check_update_info_hk_thr_mode( unsigned char mode ) +{ + unsigned int status; + + if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) + || (mode = THR_MODE_BURST)) + { + status = LFR_SUCCESSFUL; + } + else + { + status = LFR_DEFAULT; + } + + return status; +} + //********** // init dump diff --git a/src/tm_lfr_tc_exe.c b/src/tm_lfr_tc_exe.c --- a/src/tm_lfr_tc_exe.c +++ b/src/tm_lfr_tc_exe.c @@ -15,7 +15,7 @@ #include "tm_lfr_tc_exe.h" -int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) +int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) { /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue. * @@ -51,12 +51,12 @@ int send_tm_lfr_tc_exe_success( ccsdsTel TM.serviceType = TM_TYPE_TC_EXE; TM.serviceSubType = TM_SUBTYPE_EXE_OK; TM.destinationID = TC->sourceID; - TM.time[0] = time[0]; - TM.time[1] = time[1]; - TM.time[2] = time[2]; - TM.time[3] = time[3]; - TM.time[4] = time[4]; - TM.time[5] = time[5]; + TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + TM.time[3] = (unsigned char) (time_management_regs->coarse_time); + TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); + TM.time[5] = (unsigned char) (time_management_regs->fine_time); // TM.telecommand_pkt_id[0] = TC->packetID[0]; TM.telecommand_pkt_id[1] = TC->packetID[1]; @@ -75,8 +75,7 @@ int send_tm_lfr_tc_exe_success( ccsdsTel } int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, - unsigned char byte_position, unsigned char rcv_value, - unsigned char *time) + unsigned char byte_position, unsigned char rcv_value ) { /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue. * @@ -143,7 +142,7 @@ int send_tm_lfr_tc_exe_inconsistent( ccs return status; } -int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) +int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) { /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue. * @@ -336,7 +335,7 @@ int send_tm_lfr_tc_exe_error( ccsdsTelec int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, - unsigned char destinationID, unsigned char *time) + unsigned char destinationID ) { /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue. * @@ -473,6 +472,16 @@ void increment_seq_counter_destination_i break; } + // increment the sequence counter + if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX ) + { + sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1; + } + else + { + sequenceCounters_TC_EXE[ i ] = 0; + } + segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff; @@ -481,14 +490,4 @@ void increment_seq_counter_destination_i packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); - // increment the sequence counter for the next packet - if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX) - { - sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1; - } - else - { - sequenceCounters_TC_EXE[ i ] = 0; - } - }