# HG changeset patch # User paul # Date 2014-03-31 13:54:27 # Node ID 5b5da8d2c053719f8b4d6e9f19f33f78826c67ae # Parent 169204beff11a93c5155bba7c7120ca5d741b452 the interrupt sub routine related to the waveform picker is now lighter no more picks are observed on the waveforms 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/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -52,7 +52,7 @@ typedef struct ring_node #define TDS_MODE_SBM2 4 #define THR_MODE_STANDBY 0 -#define THR_MODE_NORMAL 1 +#define THR_MODE_NORMAL 1 #define THR_MODE_BURST 2 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 @@ -106,13 +106,8 @@ typedef struct ring_node #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 #define REGS_ADDR_GRGPIO 0x80000b00 -#ifdef VHDL_DEV #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40 -#else -#define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 -#define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 -#endif #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff #define APBUART_CTRL_REG_MASK_TE 0x00000002 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 @@ -1,8 +1,6 @@ #ifndef TM_BYTE_POSITIONS_H #define TM_BYTE_POSITIONS_H -#define BYTE_POS_CP_LFR_MODE 11 - // TC_LFR_LOAD_COMMON_PAR // TC_LFR_LOAD_NORMAL_PAR @@ -20,10 +18,11 @@ // 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 +#define BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 34 +#define BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 35 // TC_LFR_ENTER_MODE -#define BYTE_POS_CP_LFR_ENTER_MODE_TIME 2 // 12 - 10 +#define BYTE_POS_CP_MODE_LFR_SET 11 +#define BYTE_POS_CP_LFR_ENTER_MODE_TIME 12 #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 @@ -12,7 +12,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_parser( ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC ); int tc_check_type( unsigned char packetType ); int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType ); int tc_check_sid( unsigned char sid ); 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 @@ -14,7 +14,7 @@ int send_tm_lfr_tc_exe_inconsistent( ccs 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_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); 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 ); diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -232,7 +232,7 @@ void init_local_mode_parameters( void ) void reset_local_time( void ) { - + time_management_regs->coarse_time_load = 0x80000000; } void create_names( void ) // create all names for tasks and queues diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -116,7 +116,7 @@ rtems_task recv_task( rtems_task_argumen unsigned char computed_CRC[ 2 ]; unsigned char currentTC_LEN_RCV[ 2 ]; unsigned char destinationID; - unsigned int currentTC_LEN_RCV_AsUnsignedInt; + unsigned int estimatedPacketLength; unsigned int parserCode; rtems_status_code status; rtems_id queue_recv_id; @@ -149,11 +149,11 @@ rtems_task recv_task( rtems_task_argumen PRINTF("in RECV *** packet lenght too short\n") } else { - currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes - currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8); - currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt ); + estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes + currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); + currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); // CHECK THE TC - parserCode = tc_parser( ¤tTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ; + parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) @@ -181,7 +181,7 @@ rtems_task recv_task( rtems_task_argumen else { // send valid TC to the action launcher status = rtems_message_queue_send( queue_recv_id, ¤tTC, - currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3); + estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); } } } diff --git a/src/tc_acceptance.c b/src/tc_acceptance.c --- a/src/tc_acceptance.c +++ b/src/tc_acceptance.c @@ -93,12 +93,12 @@ void GetCRCAsTwoBytes(unsigned char* dat //********************* // ACCEPTANCE FUNCTIONS -int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC) +int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC) { /** This function parses TeleCommands. * * @param TC points to the TeleCommand that will be parsed. - * @param TC_LEN_RCV is the received packet length. + * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet. * * @return Status code of the parsing. * @@ -116,7 +116,7 @@ int tc_parser(ccsdsTelecommandPacket_t * int status_crc; unsigned char pid; unsigned char category; - unsigned int length; + unsigned int packetLength; unsigned char packetType; unsigned char packetSubtype; unsigned char sid; @@ -124,12 +124,12 @@ int tc_parser(ccsdsTelecommandPacket_t * status = CCSDS_TM_VALID; // APID check *** APID on 2 bytes - pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx - category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 - length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; - packetType = TCPacket->serviceType; - packetSubtype = TCPacket->serviceSubType; - sid = TCPacket->sourceID; + pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx + category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 + packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; + packetType = TCPacket->serviceType; + packetSubtype = TCPacket->serviceSubType; + sid = TCPacket->sourceID; if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID { @@ -142,15 +142,15 @@ int tc_parser(ccsdsTelecommandPacket_t * status = ILLEGAL_APID; } } - if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE + if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE { - if (length != TC_LEN_RCV ) { + if (packetLength != estimatedPacketLength ) { status = WRONG_LEN_PKT; } } if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE { - if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { + if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) { status = WRONG_LEN_PKT; } } @@ -168,9 +168,9 @@ int tc_parser(ccsdsTelecommandPacket_t * } if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE { - status = tc_check_length( packetSubtype, length ); + status = tc_check_length( packetSubtype, packetLength ); } - status_crc = tc_check_crc( TCPacket, length, computed_CRC ); + status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC ); if (status == CCSDS_TM_VALID ) // CHECK CRC { status = status_crc; diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -162,16 +162,19 @@ int action_enter_mode(ccsdsTelecommandPa unsigned char requestedMode; unsigned int *transitionCoarseTime_ptr; unsigned int transitionCoarseTime; + unsigned char * bytePosPtr; - requestedMode = TC->dataAndCRC[1]; - transitionCoarseTime_ptr = (unsigned int *) (&TC->dataAndCRC[BYTE_POS_CP_LFR_ENTER_MODE_TIME]); + bytePosPtr = (unsigned char *) &TC->packetID; + + requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; + transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; status = check_mode_value( requestedMode ); - if ( status != LFR_SUCCESSFUL ) + if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent { - send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); + send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); } else // the mode value is consistent, check the transition { @@ -189,7 +192,9 @@ int action_enter_mode(ccsdsTelecommandPa if (status != LFR_SUCCESSFUL) { PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") - send_tm_lfr_tc_exe_not_executable( TC, queue_id ); + send_tm_lfr_tc_exe_inconsistent( TC, queue_id, + BYTE_POS_CP_LFR_ENTER_MODE_TIME, + bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); } } @@ -219,18 +224,21 @@ int action_update_info(ccsdsTelecommandP int result; unsigned int status; unsigned char mode; + unsigned char * bytePosPtr; + + bytePosPtr = (unsigned char *) &TC->packetID; // check LFR mode - mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1; + mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; status = check_update_info_hk_lfr_mode( mode ); if (status == LFR_SUCCESSFUL) // check TDS mode { - mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4; + mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; status = check_update_info_hk_tds_mode( mode ); } if (status == LFR_SUCCESSFUL) // check THR mode { - mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f); + mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); status = check_update_info_hk_thr_mode( mode ); } if (status == LFR_SUCCESSFUL) // if the parameter check is successful @@ -420,7 +428,7 @@ int check_transition_date( unsigned int { localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; - if ( transitionCoarseTime < localCoarseTime ) // SSS-CP-EQS-322 + if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 { status = LFR_DEFAULT; PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) @@ -840,6 +848,10 @@ void close_action(ccsdsTelecommandPacket updateLFRCurrentMode(); } } + else + { + send_tm_lfr_tc_exe_error( TC, queue_id ); + } } //*************************** 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 @@ -164,7 +164,7 @@ int action_load_sbm1_par(ccsdsTelecomman result = LFR_DEFAULT; lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { + if ( lfrMode == LFR_MODE_SBM1 ) { status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); result = LFR_DEFAULT; } @@ -194,7 +194,7 @@ int action_load_sbm2_par(ccsdsTelecomman result = LFR_DEFAULT; lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { + if ( lfrMode == LFR_MODE_SBM2 ) { status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); result = LFR_DEFAULT; } 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 @@ -282,7 +282,7 @@ int send_tm_lfr_tc_exe_not_implemented( return status; } -int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) +int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) { /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue. * diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -154,33 +154,13 @@ rtems_isr waveforms_isr( rtems_vector_nu // SBM1 case(LFR_MODE_SBM1): if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit - // (0) launch snapshot extraction if needed - if (extractSWF == true) - { - ring_node_to_send_swf_f1 = current_ring_node_f1; - // extract the snapshot - status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); - extractSWF = false; - swf_f1_ready = true; - } // (1) change the receiving buffer for the waveform picker ring_node_to_send_cwf_f1 = current_ring_node_f1; current_ring_node_f1 = current_ring_node_f1->next; waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; - // (2) send an event for the the CWF1 task for transmission + // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 - if (swf_f0_ready == true) - { - extractSWF = true; - swf_f0_ready = false; - } - if ((swf_f1_ready == true) && (swf_f2_ready == true)) - { - status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); - swf_f1_ready = false; - swf_f2_ready = false; - } } if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit swf_f0_ready = true; @@ -196,16 +176,6 @@ rtems_isr waveforms_isr( rtems_vector_nu // SBM2 case(LFR_MODE_SBM2): if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit - // (0) launch snapshot extraction if needed - if (extractSWF == true) - { - ring_node_to_send_swf_f2 = current_ring_node_f2; - // extract the snapshot - status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 ); - // send the snapshot when build, SWBD priority < WFRM priority - status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); - extractSWF = false; - } // (1) change the receiving buffer for the waveform picker ring_node_to_send_cwf_f2 = current_ring_node_f2; current_ring_node_f2 = current_ring_node_f2->next; @@ -213,13 +183,6 @@ rtems_isr waveforms_isr( rtems_vector_nu // (2) send an event for the waveforms transmission status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 - // (3) check whether swf_fo and swf_f& are ready or not - if (swf_f0_ready && swf_f1_ready) - { - extractSWF = true; - swf_f0_ready = false; - swf_f1_ready = false; - } } if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit swf_f0_ready = true; @@ -402,6 +365,22 @@ rtems_task cwf2_task(rtems_task_argument if (event_out == RTEMS_EVENT_MODE_SBM2) { send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); + // launch snapshot extraction if needed + if (extractSWF == true) + { + ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; + // extract the snapshot + build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); + // send the snapshot when built + status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); + extractSWF = false; + } + if (swf_f0_ready && swf_f1_ready) + { + extractSWF = true; + swf_f0_ready = false; + swf_f1_ready = false; + } } } } @@ -436,6 +415,25 @@ rtems_task cwf1_task(rtems_task_argument rtems_event_receive( RTEMS_EVENT_MODE_SBM1, RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); + // launch snapshot extraction if needed + if (extractSWF == true) + { + ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; + // launch the snapshot extraction + status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); + extractSWF = false; + } + if (swf_f0_ready == true) + { + extractSWF = true; + swf_f0_ready = false; // this step shall be executed only one time + } + if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction + { + status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); + swf_f1_ready = false; + swf_f2_ready = false; + } } } @@ -458,10 +456,7 @@ rtems_task swbd_task(rtems_task_argument if (event_out == RTEMS_EVENT_MODE_SBM1) { build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); - } - else if (event_out == RTEMS_EVENT_MODE_SBM2) - { - build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); + swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent } else {