# HG changeset patch # User paul # Date 2014-09-24 09:11:45 # Node ID b9d810e81e1d4bc0d6ae0b63ba7467e1aadc9122 # Parent 3367da3ef050e8b3401ea629a080562e1e989045 Many corrections done after Logiscope analysis 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.6) on: Tue Jul 15 15:57:23 2014 +# Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 11:10:53 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=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=0 -DPRINT_MESSAGES_ON_CONSOLE +DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/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 @@ -11,7 +11,7 @@ SWVERSION=-1-0 DEFINES += SW_VERSION_N1=2 # major DEFINES += SW_VERSION_N2=0 # minor DEFINES += SW_VERSION_N3=1 # patch -DEFINES += SW_VERSION_N4=0 # internal +DEFINES += SW_VERSION_N4=1 # internal contains( CONFIG, debug_tch ) { DEFINES += DEBUG_TCH 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,8 +1,12 @@ - + + EnvironmentId + {2e58a81f-9962-4bba-ae6b-760177f0656c} + + ProjectExplorer.Project.ActiveTarget 0 @@ -29,9 +33,12 @@ false 4 false + 80 + true true 1 true + false 0 true 0 @@ -191,11 +198,11 @@ 1 - ProjectExplorer.Project.Updater.EnvironmentId - {2e58a81f-9962-4bba-ae6b-760177f0656c} + ProjectExplorer.Project.Updater.FileVersion + 16 - ProjectExplorer.Project.Updater.FileVersion - 15 + Version + 16 diff --git a/TimeGenerator-qt/Makefile b/TimeGenerator-qt/Makefile --- a/TimeGenerator-qt/Makefile +++ b/TimeGenerator-qt/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bin/timegen -# Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Mar 21 09:10:01 2014 +# Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 10:50:53 2014 # Project: timegen.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.pro diff --git a/TimeGenerator-qt/header/timegen_init.h b/TimeGenerator-qt/header/timegen_init.h --- a/TimeGenerator-qt/header/timegen_init.h +++ b/TimeGenerator-qt/header/timegen_init.h @@ -6,7 +6,6 @@ #include "fsw_params.h" #include "fsw_misc.h" -#include "fsw_processing.h" #include "wf_handler.h" #include "timegen_spacewire.h" @@ -14,6 +13,7 @@ extern rtems_name Task_name[20]; /* array of task names */ extern rtems_id Task_id[20]; /* array of task ids */ +extern rtems_name misc_name[5]; // RTEMS TASKS rtems_task Init( rtems_task_argument argument); @@ -32,8 +32,6 @@ 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 ); extern void rtems_stack_checker_report_usage( void ); extern int sched_yield( void ); diff --git a/TimeGenerator-qt/header/timegen_misc.h b/TimeGenerator-qt/header/timegen_misc.h --- a/TimeGenerator-qt/header/timegen_misc.h +++ b/TimeGenerator-qt/header/timegen_misc.h @@ -24,6 +24,8 @@ unsigned int coarseTime; rtems_name rtems_name_updt; rtems_id rtems_id_updt; +rtems_name rtems_name_act_; +rtems_id rtems_id_act_; void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ); diff --git a/TimeGenerator-qt/header/timegen_tc_handler.h b/TimeGenerator-qt/header/timegen_tc_handler.h --- a/TimeGenerator-qt/header/timegen_tc_handler.h +++ b/TimeGenerator-qt/header/timegen_tc_handler.h @@ -18,34 +18,12 @@ rtems_isr commutation_isr2( rtems_vector //*********** // RTEMS TASK -rtems_task actn_task( rtems_task_argument unused ); +rtems_task act__task( rtems_task_argument unused ); //*********** // TC ACTIONS -int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); -int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); -int action_update_time(ccsdsTelecommandPacket_t *TC); - -// mode transition -int transition_validation(unsigned char requestedMode); -int stop_current_mode( void ); -int enter_mode(unsigned char mode); -int restart_science_tasks(); -int suspend_science_tasks(); -void launch_waveform_picker( unsigned char mode ); -void launch_spectral_matrix( unsigned char mode ); -void set_irq_on_new_ready_matrix(unsigned char value ); -void set_run_matrix_spectral( unsigned char value ); -void launch_spectral_matrix_simu( unsigned char mode ); - -// other functions -void updateLFRCurrentMode(); -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 ); +int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); +int timegen_action_update_time(ccsdsTelecommandPacket_t *TC); 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/TimeGenerator-qt/src/timegen_init.c b/TimeGenerator-qt/src/timegen_init.c --- a/TimeGenerator-qt/src/timegen_init.c +++ b/TimeGenerator-qt/src/timegen_init.c @@ -155,13 +155,6 @@ rtems_task Init( rtems_task_argument ign PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) } - // suspend science tasks. they will be restarted later depending on the mode - status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) - } - // if the spacewire link is not up then send an event to the SPIQ task for link recovery if ( status_spw != RTEMS_SUCCESSFUL ) { @@ -177,31 +170,6 @@ rtems_task Init( rtems_task_argument ign } -void init_local_mode_parameters( void ) -{ - /** This function initialize the param_local global variable with default values. - * - */ - - unsigned int i; - - // LOCAL PARAMETERS -// set_local_nb_interrupt_f0_MAX(); - - BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) - BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) - BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) - - // init sequence counters - - for(i = 0; i -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 ); - // CHECK THE TC - parserCode = tc_parser( ¤tTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ; - if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) - || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) - || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) - || (parserCode == WRONG_SRC_ID) ) - { // send TM_LFR_TC_EXE_CORRUPTED - if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) - && - !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) - ) - { - if ( parserCode == WRONG_SRC_ID ) - { - destinationID = SID_TC_GROUND; - } - else - { - destinationID = currentTC.sourceID; - } - getTime( 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 ); - } - } - 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); - } - } - } - } -} - -rtems_task send_task( rtems_task_argument argument) -{ - /** This RTEMS task is dedicated to the transmission of TeleMetry packets. - * - * @param unused is the starting argument of the RTEMS task - * - * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: - * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. - * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After - * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the - * data it contains. - * - */ - - rtems_status_code status; // RTEMS status code - char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer - size_t size; // size of the incoming TC packet - u_int32_t count; - rtems_id queue_id; - - status = get_message_queue_id_send( &queue_id ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) - } - - BOOT_PRINTF("in SEND *** \n") - - while(1) - { - status = rtems_message_queue_receive( queue_id, incomingData, &size, - RTEMS_WAIT, RTEMS_NO_TIMEOUT ); - - if (status!=RTEMS_SUCCESSFUL) - { - PRINTF1("in SEND *** (1) ERR = %d\n", status) - } - else - { - status = write( fdSPW, incomingData, size ); - if (status == -1){ - PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) - } - } - - status = rtems_message_queue_get_number_pending( queue_id, &count ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in SEND *** (3) ERR = %d\n", status) - } - else - { - if (count > maxCount) - { - maxCount = count; - } - } - } -} - -rtems_task wtdg_task( rtems_task_argument argument ) -{ - rtems_event_set event_out; - rtems_status_code status; - int linkStatus; - - BOOT_PRINTF("in WTDG ***\n") - - while(1) - { - // wait for an RTEMS_EVENT - rtems_event_receive( RTEMS_EVENT_0, - RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); - PRINTF("in WTDG *** wait for the link\n") - status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status - while( linkStatus != 5) // wait for the link - { - rtems_task_wake_after( 10 ); - status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status - } - - status = spacewire_stop_start_link( fdSPW ); - - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in WTDG *** ERR link not started %d\n", status) - } - else - { - PRINTF("in WTDG *** OK link started\n") - } - - // restart the SPIQ task - status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); - if ( status != RTEMS_SUCCESSFUL ) { - PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") - } - - // restart RECV and SEND - status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); - if ( status != RTEMS_SUCCESSFUL ) { - PRINTF("in SPIQ *** ERR restarting SEND Task\n") - } - status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); - if ( status != RTEMS_SUCCESSFUL ) { - PRINTF("in SPIQ *** ERR restarting RECV Task\n") - } - } -} - -//**************** -// OTHER FUNCTIONS -int spacewire_open_link( void ) -{ - /** This function opens the SpaceWire link. - * - * @return a valid file descriptor in case of success, -1 in case of a failure - * - */ - rtems_status_code status; - - fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware - if ( fdSPW < 0 ) { - PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) - } - else - { - status = RTEMS_SUCCESSFUL; - } - - return status; -} - -int spacewire_start_link( int fd ) -{ - rtems_status_code status; - - status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started - // -1 default hardcoded driver timeout - - return status; -} - -int spacewire_stop_start_link( int fd ) -{ - rtems_status_code status; - - status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 - status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started - // -1 default hardcoded driver timeout - - return status; -} - -int spacewire_configure_link( int fd ) -{ - /** This function configures the SpaceWire link. - * - * @return GR-RTEMS-DRIVER directive status codes: - * - 22 EINVAL - Null pointer or an out of range value was given as the argument. - * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. - * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. - * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. - * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. - * - 5 EIO - Error when writing to grswp hardware registers. - * - 2 ENOENT - No such file or directory - */ - - rtems_status_code status; - - spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force - spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration - - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") - // - status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL\n") - - return status; -} - -int spacewire_reset_link( void ) -{ - /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. - * - * @return RTEMS directive status code: - * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. - * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. - * - */ - - rtems_status_code status_spw; - int i; - - for ( i=0; i> 8); - housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); - housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); - housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); - //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; - //housekeeping_packet.hk_lfr_dpu_spw_last_timc; - - //****************************************** - // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY - housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; - housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; - housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; - housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; - housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; - - //********************************************* - // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY - housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; - housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; - housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; - housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; -} - void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) { // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ); diff --git a/TimeGenerator-qt/src/timegen_tc_handler.c b/TimeGenerator-qt/src/timegen_tc_handler.c --- a/TimeGenerator-qt/src/timegen_tc_handler.c +++ b/TimeGenerator-qt/src/timegen_tc_handler.c @@ -15,7 +15,7 @@ //*********** // RTEMS TASK -rtems_task actn_task( rtems_task_argument unused ) +rtems_task act__task( rtems_task_argument unused ) { /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. * @@ -66,63 +66,12 @@ rtems_task actn_task( rtems_task_argumen subtype = TC.serviceSubType; switch(subtype) { - case TC_SUBTYPE_RESET: -// result = action_reset( &TC, 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 ); - break; - // - case TC_SUBTYPE_LOAD_NORM: -// result = action_load_normal_par( &TC, 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 ); - break; - // - case TC_SUBTYPE_LOAD_SBM1: -// result = action_load_sbm1_par( &TC, 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 ); + case TC_SUBTYPE_ENTER: + result = timegen_action_enter_mode( &TC, 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 ); - break; - // - case TC_SUBTYPE_ENTER: - result = action_enter_mode( &TC, 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 ); - break; - // - case TC_SUBTYPE_EN_CAL: -// result = action_enable_calibration( &TC, 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 ); - break; - // case TC_SUBTYPE_UPDT_TIME: - result = action_update_time( &TC ); + result = timegen_action_update_time( &TC ); close_action( &TC, result, queue_snd_id ); break; // @@ -136,658 +85,23 @@ rtems_task actn_task( rtems_task_argumen //*********** // TC ACTIONS -int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) +int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) { - /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. - * - * @param TC points to the TeleCommand packet that is being processed - * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver - * - */ - - send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); - return LFR_DEFAULT; -} - -int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) -{ - /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. - * - * @param TC points to the TeleCommand packet that is being processed - * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver - * - */ - - rtems_status_code status; - unsigned char requestedMode; - - requestedMode = TC->dataAndCRC[1]; + int ret; - if ( (requestedMode != LFR_MODE_STANDBY) - && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) - && (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 ); - } - else - { - printf("in action_enter_mode *** enter mode %d\n", requestedMode); - - status = transition_validation(requestedMode); + ret = LFR_SUCCESSFUL; - if ( status == LFR_SUCCESSFUL ) { - if ( lfrCurrentMode != LFR_MODE_STANDBY) - { - status = stop_current_mode(); - } - if (status != RTEMS_SUCCESSFUL) - { - PRINTF("ERR *** in action_enter *** stop_current_mode\n") - } - status = enter_mode( requestedMode ); - } - else - { - PRINTF("ERR *** in action_enter *** transition rejected\n") - send_tm_lfr_tc_exe_not_executable( TC, queue_id ); - } - } - - return status; + return ret; } -int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) +int timegen_action_update_time(ccsdsTelecommandPacket_t *TC) { -// /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. -// * -// * @param TC points to the TeleCommand packet that is being processed -// * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver -// * -// * @return LFR directive status code: -// * - LFR_DEFAULT -// * - LFR_SUCCESSFUL -// * -// */ - -// unsigned int val; - int result; - - result = LFR_DEFAULT; -// unsigned int status; -// unsigned char mode; - -// // 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; -} - -int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) -{ - /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. - * - * @param TC points to the TeleCommand packet that is being processed - * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver - * - */ + int ret; - int result; - unsigned char lfrMode; - - result = LFR_DEFAULT; - lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; - - send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); - result = LFR_DEFAULT; - - return result; -} - -int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) -{ - /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. - * - * @param TC points to the TeleCommand packet that is being processed - * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver - * - */ - - int result; - unsigned char lfrMode; - - result = LFR_DEFAULT; - lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; + ret = LFR_SUCCESSFUL; - send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); - result = LFR_DEFAULT; - - return result; -} - -int action_update_time(ccsdsTelecommandPacket_t *TC) -{ - /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. - * - * @param TC points to the TeleCommand packet that is being processed - * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver - * - * @return LFR_SUCCESSFUL - * - */ - - unsigned int val; - - time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) - + (TC->dataAndCRC[1] << 16) - + (TC->dataAndCRC[2] << 8) - + TC->dataAndCRC[3]; - val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 - + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; - val++; - 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); -// time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick - - return LFR_SUCCESSFUL; + return ret; } //******************* // ENTERING THE MODES - -int transition_validation(unsigned char requestedMode) -{ - /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. - * - * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE - * - * @return LFR directive status codes: - * - LFR_SUCCESSFUL - the transition is authorized - * - LFR_DEFAULT - the transition is not authorized - * - */ - - int status; - - switch (requestedMode) - { - case LFR_MODE_STANDBY: - if ( lfrCurrentMode == LFR_MODE_STANDBY ) { - status = LFR_DEFAULT; - } - else - { - status = LFR_SUCCESSFUL; - } - break; - case LFR_MODE_NORMAL: - if ( lfrCurrentMode == LFR_MODE_NORMAL ) { - status = LFR_DEFAULT; - } - else { - status = LFR_SUCCESSFUL; - } - break; - case LFR_MODE_BURST: - if ( lfrCurrentMode == LFR_MODE_BURST ) { - status = LFR_DEFAULT; - } - else { - status = LFR_SUCCESSFUL; - } - break; - case LFR_MODE_SBM1: - if ( lfrCurrentMode == LFR_MODE_SBM1 ) { - status = LFR_DEFAULT; - } - else { - status = LFR_SUCCESSFUL; - } - break; - case LFR_MODE_SBM2: - if ( lfrCurrentMode == LFR_MODE_SBM2 ) { - status = LFR_DEFAULT; - } - else { - status = LFR_SUCCESSFUL; - } - break; - default: - status = LFR_DEFAULT; - break; - } - - return status; -} - -int stop_current_mode(void) -{ - /** This function stops the current mode by masking interrupt lines and suspending science tasks. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - task restarted successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_ALREADY_SUSPENDED - task already suspended - * - */ - - rtems_status_code status; - - status = RTEMS_SUCCESSFUL; - - // (1) mask interruptions - LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt - LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt - - // (2) clear interruptions - LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt - LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt - - // (3) reset registers - // waveform picker -// reset_wfp_burst_enable(); // reset burst and enable bits -// reset_wfp_status(); // reset all the status bits - // spectral matrices - set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices - set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 -// reset_extractSWF(); // reset the extractSWF flag to false - - // - LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator - timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); - LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator - // - - // suspend several tasks - if (lfrCurrentMode != LFR_MODE_STANDBY) { - status = suspend_science_tasks(); - } - - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) - } - - return status; -} - -int enter_mode(unsigned char mode ) -{ - /** This function is launched after a mode transition validation. - * - * @param mode is the mode in which LFR will be put. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - the mode has been entered successfully - * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully - * - */ - - rtems_status_code status; - - status = RTEMS_UNSATISFIED; - - housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); - updateLFRCurrentMode(); - - if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) - || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) - { -#ifdef PRINT_TASK_STATISTICS - rtems_cpu_usage_reset(); - maxCount = 0; -#endif - status = restart_science_tasks(); -// launch_waveform_picker( mode ); -// launch_spectral_matrix( mode ); - } - else if ( mode == LFR_MODE_STANDBY ) - { -#ifdef PRINT_TASK_STATISTICS - rtems_cpu_usage_report(); -#endif - -#ifdef PRINT_STACK_REPORT - rtems_stack_checker_report_usage(); -#endif - status = stop_current_mode(); - PRINTF1("maxCount = %d\n", maxCount) - } - else - { - status = RTEMS_UNSATISFIED; - } - - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in enter_mode *** ERR = %d\n", status) - status = RTEMS_UNSATISFIED; - } - - return status; -} - -int restart_science_tasks() -{ - /** This function is used to restart all science tasks. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - task restarted successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_INCORRECT_STATE - task never started - * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task - * - * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 - * - */ - - rtems_status_code status[6]; - rtems_status_code ret; - - ret = RTEMS_SUCCESSFUL; - - status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); - if (status[0] != RTEMS_SUCCESSFUL) - { - PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) - } - - status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); - if (status[2] != RTEMS_SUCCESSFUL) - { - PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) - } - - status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); - if (status[3] != RTEMS_SUCCESSFUL) - { - PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) - } - - status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); - if (status[4] != RTEMS_SUCCESSFUL) - { - PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) - } - - status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); - if (status[5] != RTEMS_SUCCESSFUL) - { - PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) - } - - if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || - (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) - { - ret = RTEMS_UNSATISFIED; - } - - return ret; -} - -int suspend_science_tasks() -{ - /** This function suspends the science tasks. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - task restarted successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_ALREADY_SUSPENDED - task already suspended - * - */ - - rtems_status_code status; - - status = rtems_task_suspend( Task_id[TASKID_AVF0] ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) - } - - if (status == RTEMS_SUCCESSFUL) // suspend WFRM - { - status = rtems_task_suspend( Task_id[TASKID_WFRM] ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) - } - } - - if (status == RTEMS_SUCCESSFUL) // suspend CWF3 - { - status = rtems_task_suspend( Task_id[TASKID_CWF3] ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) - } - } - - if (status == RTEMS_SUCCESSFUL) // suspend CWF2 - { - status = rtems_task_suspend( Task_id[TASKID_CWF2] ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) - } - } - - if (status == RTEMS_SUCCESSFUL) // suspend CWF1 - { - status = rtems_task_suspend( Task_id[TASKID_CWF1] ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) - } - } - - return status; -} - -void launch_waveform_picker( unsigned char mode ) -{ -// int startDate; - -// reset_current_ring_nodes(); -// reset_waveform_picker_regs(); -// set_wfp_burst_enable_register( mode ); - -// LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); -// LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); - -// startDate = time_management_regs->coarse_time + 2; -// waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] -// waveform_picker_regs->start_date = startDate; -} - -void launch_spectral_matrix( unsigned char mode ) -{ -// reset_nb_sm_f0(); -// reset_current_sm_ring_nodes(); -// reset_spectral_matrix_regs(); - -//#ifdef VHDL_DEV -// set_irq_on_new_ready_matrix( 1 ); -// LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); -// LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); -// set_run_matrix_spectral( 1 ); -//#else -// // Spectral Matrices simulator -// timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); -// LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); -// LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); -//#endif -} - -void set_irq_on_new_ready_matrix( unsigned char value ) -{ - if (value == 1) - { - spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; - } - else - { - spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 - } -} - -void set_run_matrix_spectral( unsigned char value ) -{ - if (value == 1) - { - spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1 - } - else - { - spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0 - } -} - -void launch_spectral_matrix_simu( unsigned char mode ) -{ -// reset_nb_sm_f0(); -// reset_current_sm_ring_nodes(); -// reset_spectral_matrix_regs(); - -// // Spectral Matrices simulator -// timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); -// LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); -// LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); -// set_local_nb_interrupt_f0_MAX(); -} - -//**************** -// CLOSING ACTIONS -void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) -{ - /** This function is used to update the HK packets statistics after a successful TC execution. - * - * @param TC points to the TC being processed - * @param time is the time used to date the TC execution - * - */ - - housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; - housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; - housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; - 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] = (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 ) -{ - /** This function is used to update the HK packets statistics after a TC rejection. - * - * @param TC points to the TC being processed - * @param time is the time used to date the TC rejection - * - */ - - housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; - housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; - housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; - 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] = (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 ) -{ - /** This function is the last step of the TC execution workflow. - * - * @param TC points to the TC being processed - * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) - * @param queue_id is the id of the RTEMS message queue used to send TM packets - * @param time is the time used to date the TC execution - * - */ - - unsigned int val = 0; - - if (result == LFR_SUCCESSFUL) - { - if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) - && - !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) - ) - { - send_tm_lfr_tc_exe_success( TC, queue_id ); - } - 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); - housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); - } - else - { - 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); - housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); - } -} - -//*************************** -// Interrupt Service Routines -rtems_isr commutation_isr1( rtems_vector_number vector ) -{ - if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - printf("In commutation_isr1 *** Error sending event to DUMB\n"); - } -} - -rtems_isr commutation_isr2( rtems_vector_number vector ) -{ - if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - printf("In commutation_isr2 *** Error sending event to DUMB\n"); - } -} - -//**************** -// OTHER FUNCTIONS -void updateLFRCurrentMode() -{ - /** This function updates the value of the global variable lfrCurrentMode. - * - * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. - * - */ - // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure - lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; -} - diff --git a/TimeGenerator-qt/timegen.pro.user b/TimeGenerator-qt/timegen.pro.user --- a/TimeGenerator-qt/timegen.pro.user +++ b/TimeGenerator-qt/timegen.pro.user @@ -1,8 +1,12 @@ - + + EnvironmentId + {2e58a81f-9962-4bba-ae6b-760177f0656c} + + ProjectExplorer.Project.ActiveTarget 0 @@ -29,9 +33,12 @@ false 4 false + 80 + true true 1 true + false 0 true 0 @@ -388,11 +395,11 @@ 2 - ProjectExplorer.Project.Updater.EnvironmentId - {2e58a81f-9962-4bba-ae6b-760177f0656c} + ProjectExplorer.Project.Updater.FileVersion + 16 - ProjectExplorer.Project.Updater.FileVersion - 15 + Version + 16 diff --git a/header/fsw_init.h b/header/fsw_init.h --- a/header/fsw_init.h +++ b/header/fsw_init.h @@ -39,8 +39,8 @@ 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 ); +extern void rtems_cpu_usage_report( void ); +extern void rtems_cpu_usage_reset( void ); extern void rtems_stack_checker_report_usage( void ); extern int sched_yield( void ); diff --git a/header/fsw_misc.h b/header/fsw_misc.h --- a/header/fsw_misc.h +++ b/header/fsw_misc.h @@ -12,10 +12,6 @@ rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic rtems_id HK_id; // id of the HK rate monotonic period -//extern rtems_name misc_name[5]; -//time_management_regs_t *time_management_regs; -//extern Packet_TM_LFR_HK_t housekeeping_packet; - void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, unsigned char interrupt_level, rtems_isr (*timer_isr)() ); void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); @@ -41,7 +37,7 @@ void get_v_e1_e2_f3 (unsigned char *spac void get_cpu_load( unsigned char *resource_statistics ); extern int sched_yield( void ); -extern int rtems_cpu_usage_reset(); +extern void rtems_cpu_usage_reset(); extern ring_node *current_ring_node_f3; extern ring_node *ring_node_to_send_cwf_f3; extern unsigned short sequenceCounterHK; diff --git a/header/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -86,12 +86,12 @@ typedef struct ring_node #define DEFAULT_SY_LFR_COMMON0 0x00 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 // NORM -#define SY_LFR_N_SWF_L 2048 // nb sample -#define SY_LFR_N_SWF_P 300 // sec -#define SY_LFR_N_ASM_P 3600 // sec -#define SY_LFR_N_BP_P0 4 // sec -#define SY_LFR_N_BP_P1 20 // sec -#define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 +#define DFLT_SY_LFR_N_SWF_L 2048 // nb sample +#define DFLT_SY_LFR_N_SWF_P 300 // sec +#define DFLT_SY_LFR_N_ASM_P 3600 // sec +#define DFLT_SY_LFR_N_BP_P0 4 // sec +#define DFLT_SY_LFR_N_BP_P1 20 // sec +#define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 #define MIN_DELTA_SNAPSHOT 16 // sec // BURST #define DEFAULT_SY_LFR_B_BP_P0 1 // sec diff --git a/header/lfr_cpu_usage_report.h b/header/lfr_cpu_usage_report.h --- a/header/lfr_cpu_usage_report.h +++ b/header/lfr_cpu_usage_report.h @@ -1,6 +1,32 @@ #ifndef LFR_CPU_USAGE_REPORT_H #define LFR_CPU_USAGE_REPORT_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #include +#endif + +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + extern Timestamp_Control CPU_usage_Uptime_at_last_reset; +#else + extern uint32_t CPU_usage_Ticks_at_last_reset; +#endif + unsigned char lfr_rtems_cpu_usage_report( void ); #endif // LFR_CPU_USAGE_REPORT_H 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 @@ -99,7 +99,7 @@ void BP_send( char *data, void reset_spectral_matrix_regs( void ); void set_time(unsigned char *time, unsigned char *timeInBuffer ); unsigned long long int get_acquisition_time( unsigned char *timePtr ); -void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, +void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id, ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time); unsigned char getSID( rtems_event_set event ); 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 @@ -9,6 +9,8 @@ #include "tm_lfr_tc_exe.h" #include "fsw_misc.h" +#define FLOAT_EQUAL_ZERO 0.001 + extern unsigned short sequenceCounterParameterDump; int action_load_common_par( ccsdsTelecommandPacket_t *TC ); diff --git a/src/fsw_config.c b/src/fsw_config.c --- a/src/fsw_config.c +++ b/src/fsw_config.c @@ -10,36 +10,6 @@ struct drvmgr_key grlib_grspw_0n1_res[] KEY_EMPTY }; -#if 0 - /* APBUART0 */ - struct drvmgr_key grlib_drv_res_apbuart0[] = - { - {"mode", KEY_TYPE_INT, {(unsigned int)1}}, - {"syscon", KEY_TYPE_INT, {(unsigned int)1}}, - KEY_EMPTY - }; - /* APBUART1 */ - struct drvmgr_key grlib_drv_res_apbuart1[] = - { - {"mode", KEY_TYPE_INT, {(unsigned int)1}}, - {"syscon", KEY_TYPE_INT, {(unsigned int)0}}, - KEY_EMPTY - }; - /* LEON3 System with driver configuration for 2 APBUARTs, the - * the rest of the AMBA device drivers use their defaults. - */ - - /* Override default debug UART assignment. - * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0, - * CPU1=APBUART1... - * 1 = APBUART[0] - * 2 = APBUART[1] - * 3 = APBUART[2] - * ... - */ - //int debug_uart_index = 2; /* second UART -- APBUART[1] */ -#endif - // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP. struct drvmgr_bus_res grlib_drv_resources = { diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -142,6 +142,7 @@ rtems_task stat_task(rtems_task_argument rtems_task hous_task(rtems_task_argument argument) { rtems_status_code status; + rtems_status_code spare_status; rtems_id queue_id; rtems_rate_monotonic_period_status period_status; @@ -208,7 +209,7 @@ rtems_task hous_task(rtems_task_argument status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); if ( status != RTEMS_SUCCESSFUL ) { PRINTF1( "in HOUS *** ERR period: %d\n", status); - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); + spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); } else { housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); @@ -290,11 +291,9 @@ rtems_task dumb_task( rtems_task_argumen printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); if (i==8) { - PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status) } if (i==10) { - PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status) } } } @@ -453,6 +452,8 @@ void get_v_e1_e2_f3( unsigned char *spac unsigned int offset_in_bytes; unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz + bufferPtr = NULL; + if (lfrCurrentMode == LFR_MODE_STANDBY) { spacecraft_potential[0] = 0x00; diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -374,25 +374,39 @@ int spacewire_configure_link( int fd ) spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") + } // status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] - if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") + if (status!=RTEMS_SUCCESSFUL) { + PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") + } return status; } diff --git a/src/lfr_cpu_usage_report.c b/src/lfr_cpu_usage_report.c --- a/src/lfr_cpu_usage_report.c +++ b/src/lfr_cpu_usage_report.c @@ -11,39 +11,8 @@ * $Id$ */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - #include "lfr_cpu_usage_report.h" -#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - #include -#endif - -#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - extern Timestamp_Control CPU_usage_Uptime_at_last_reset; -#else - extern uint32_t CPU_usage_Ticks_at_last_reset; -#endif - -/*PAGE - * - * rtems_cpu_usage_report - */ - unsigned char lfr_rtems_cpu_usage_report( void ) { uint32_t api_index; @@ -51,7 +20,9 @@ unsigned char lfr_rtems_cpu_usage_report Objects_Information *information; uint32_t ival, fval; #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - Timestamp_Control uptime, total, ran; + Timestamp_Control uptime; + Timestamp_Control total; + Timestamp_Control ran; #else uint32_t total_units = 0; #endif @@ -69,18 +40,18 @@ unsigned char lfr_rtems_cpu_usage_report _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total ); #else for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) { - if ( !_Objects_Information_table[ api_index ] ) + if ( !_Objects_Information_table[ api_index ] ) { } + else { - continue; - } - information = _Objects_Information_table[ api_index ][ 1 ]; - if ( information ) - { - for ( i=1 ; i <= information->maximum ; i++ ) { - the_thread = (Thread_Control *)information->local_table[ i ]; + information = _Objects_Information_table[ api_index ][ 1 ]; + if ( information != NULL ) + { + for ( i=1 ; i <= information->maximum ; i++ ) { + the_thread = (Thread_Control *)information->local_table[ i ]; - if ( the_thread ) - total_units += the_thread->cpu_time_used; + if ( the_thread != NULL ) + total_units += the_thread->cpu_time_used; + } } } } @@ -88,53 +59,52 @@ unsigned char lfr_rtems_cpu_usage_report for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) { - if ( !_Objects_Information_table[ api_index ] ) - { - continue; - } - information = _Objects_Information_table[ api_index ][ 1 ]; - if ( information ) + if ( !_Objects_Information_table[ api_index ] ) { } + else { - the_thread = (Thread_Control *)information->local_table[ 1 ]; - - if ( !the_thread ) - { - continue; - } - -#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - /* - * If this is the currently executing thread, account for time - * since the last context switch. - */ - ran = the_thread->cpu_time_used; - if ( _Thread_Executing->Object.id == the_thread->Object.id ) + information = _Objects_Information_table[ api_index ][ 1 ]; + if ( information != NULL ) { - Timestamp_Control used; - _Timestamp_Subtract( - &_Thread_Time_of_last_context_switch, &uptime, &used - ); - _Timestamp_Add_to( &ran, &used ); - } - _Timestamp_Divide( &ran, &total, &ival, &fval ); - -#else - if (total_units) - { - uint64_t ival_64; + the_thread = (Thread_Control *)information->local_table[ 1 ]; - ival_64 = the_thread->cpu_time_used; - ival_64 *= 100000; - ival = ival_64 / total_units; + if ( the_thread == NULL ) { } + else + { + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + /* + * If this is the currently executing thread, account for time + * since the last context switch. + */ + ran = the_thread->cpu_time_used; + if ( _Thread_Executing->Object.id == the_thread->Object.id ) + { + Timestamp_Control used; + _Timestamp_Subtract( + &_Thread_Time_of_last_context_switch, &uptime, &used + ); + _Timestamp_Add_to( &ran, &used ); + } + _Timestamp_Divide( &ran, &total, &ival, &fval ); + + #else + if (total_units != 0) + { + uint64_t ival_64; + + ival_64 = the_thread->cpu_time_used; + ival_64 *= 100000; + ival = ival_64 / total_units; + } + else + { + ival = 0; + } + + fval = ival % 1000; + ival /= 1000; + #endif + } } - else - { - ival = 0; - } - - fval = ival % 1000; - ival /= 1000; -#endif } } cpu_load = (unsigned char) (100 - ival); diff --git a/src/processing/avf2_prc2.c b/src/processing/avf2_prc2.c --- a/src/processing/avf2_prc2.c +++ b/src/processing/avf2_prc2.c @@ -139,6 +139,8 @@ rtems_task prc2_task( rtems_task_argumen unsigned long long int localTime; + incomingMsg = NULL; + ASM_init_header( &headerASM ); //************* 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 @@ -96,6 +96,7 @@ void spectral_matrices_isr_f1( void ) unsigned char status; unsigned long long int time; unsigned long long int syncBit; + rtems_status_code status_code; status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits @@ -106,7 +107,7 @@ void spectral_matrices_isr_f1( void ) case 3: // UNEXPECTED VALUE spectral_matrix_regs->status = 0xc0; // [1100] - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); break; case 1: time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time ); @@ -132,6 +133,7 @@ void spectral_matrices_isr_f1( void ) void spectral_matrices_isr_f2( void ) { unsigned char status; + rtems_status_code status_code; status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits @@ -146,7 +148,7 @@ void spectral_matrices_isr_f2( void ) case 3: // UNEXPECTED VALUE spectral_matrix_regs->status = 0x30; // [0011 0000] - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); break; case 1: ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; @@ -155,7 +157,7 @@ void spectral_matrices_isr_f2( void ) spectral_matrix_regs->status = 0x10; // [0001 0000] if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } break; case 2: @@ -165,7 +167,7 @@ void spectral_matrices_isr_f2( void ) spectral_matrix_regs->status = 0x20; // [0010 0000] if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } break; } @@ -173,9 +175,11 @@ void spectral_matrices_isr_f2( void ) void spectral_matrix_isr_error_handler( void ) { + rtems_status_code status_code; + if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000] { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); } } @@ -198,6 +202,8 @@ rtems_isr spectral_matrices_isr( rtems_v rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) { + rtems_status_code status_code; + //*** // F0 nb_sm_f0 = nb_sm_f0 + 1; @@ -206,7 +212,7 @@ rtems_isr spectral_matrices_isr_simu( rt ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } nb_sm_f0 = 0; } @@ -224,7 +230,7 @@ rtems_isr spectral_matrices_isr_simu( rt ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } nb_sm_f1 = 0; } @@ -238,7 +244,7 @@ rtems_isr spectral_matrices_isr_simu( rt ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } } } @@ -620,13 +626,14 @@ unsigned long long int get_acquisition_t return acquisitionTimeAslong; } -void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, +void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id, ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time ) { unsigned char *timePtr; unsigned char *coarseTimePtr; unsigned char *fineTimePtr; + rtems_status_code status_code; timePtr = (unsigned char *) &time; coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime; @@ -642,9 +649,9 @@ void close_matrix_actions(unsigned int * coarseTimePtr[3] = timePtr[5]; fineTimePtr[2] = timePtr[6]; fineTimePtr[3] = timePtr[7]; - if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); } *nb_sm = 0; } diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -322,7 +322,6 @@ int action_update_time(ccsdsTelecommandP val++; 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); -// time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick return LFR_SUCCESSFUL; } @@ -764,6 +763,8 @@ void launch_waveform_picker( unsigned ch { waveform_picker_regs->start_date = transitionCoarseTime; } + + PRINTF1("commutation coarse time = %d\n", transitionCoarseTime) } void launch_spectral_matrix( void ) 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 @@ -120,7 +120,7 @@ int action_load_burst_par(ccsdsTelecomma sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); - if (aux != 0) + if (aux > FLOAT_EQUAL_ZERO) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); flag = LFR_DEFAULT; @@ -185,7 +185,7 @@ int action_load_sbm1_par(ccsdsTelecomman if (flag == LFR_SUCCESSFUL) { aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); - if (aux != 0) + if (aux > FLOAT_EQUAL_ZERO) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); flag = LFR_DEFAULT; @@ -252,7 +252,7 @@ int action_load_sbm2_par(ccsdsTelecomman sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); - if (aux != 0) + if (aux > FLOAT_EQUAL_ZERO) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); flag = LFR_DEFAULT; @@ -368,7 +368,7 @@ int check_common_par_consistency( ccsdsT // sy_lfr_n_bp_p0 if (flag == LFR_SUCCESSFUL) { - if (sy_lfr_n_bp_p0 < SY_LFR_N_BP_P0) + if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); flag = WRONG_APP_DATA; @@ -387,7 +387,7 @@ int check_common_par_consistency( ccsdsT if (flag == LFR_SUCCESSFUL) { aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); - if (aux != 0) + if (aux > FLOAT_EQUAL_ZERO) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); flag = WRONG_APP_DATA; @@ -396,7 +396,7 @@ int check_common_par_consistency( ccsdsT // sy_lfr_n_bp_p1 if (flag == LFR_SUCCESSFUL) { - if (sy_lfr_n_bp_p1 < SY_LFR_N_BP_P1) + if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); flag = WRONG_APP_DATA; @@ -406,7 +406,7 @@ int check_common_par_consistency( ccsdsT if (flag == LFR_SUCCESSFUL) { aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); - if (aux != 0) + if (aux > FLOAT_EQUAL_ZERO) { status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); flag = LFR_DEFAULT; @@ -476,7 +476,7 @@ int set_sy_lfr_n_asm_p( ccsdsTelecommand int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) { - /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). + /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). * * @param TC points to the TeleCommand packet that is being processed * @param queue_id is the id of the queue which handles TM related to this execution step @@ -738,15 +738,15 @@ void init_parameter_dump( void ) //****************** // NORMAL PARAMETERS - parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); - parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); - parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); - parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); - parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); - parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); - parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; - parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; - parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; + parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); + parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); + parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); + parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); + parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); + parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); + parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; + parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; + parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; //***************** // BURST PARAMETERS diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -68,6 +68,7 @@ rtems_isr waveforms_isr( rtems_vector_nu */ rtems_status_code status; + rtems_status_code spare_status; if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) @@ -79,7 +80,7 @@ rtems_isr waveforms_isr( rtems_vector_nu waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // (2) send an event for the waveforms transmission if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); + spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2); waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] @@ -98,7 +99,7 @@ rtems_isr waveforms_isr( rtems_vector_nu case(LFR_MODE_NORMAL): if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); + spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits { @@ -117,7 +118,7 @@ rtems_isr waveforms_isr( rtems_vector_nu // if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); + spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] } @@ -133,7 +134,7 @@ rtems_isr waveforms_isr( rtems_vector_nu waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // (2) send an event for the waveforms transmission if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); + spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 } @@ -505,6 +506,9 @@ void WFP_reset_current_ring_nodes( void int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) { unsigned char i; + int return_value; + + return_value = LFR_SUCCESSFUL; for (i=0; i<7; i++) { @@ -547,12 +551,16 @@ int init_header_snapshot_wf_table( unsig headerSWF[ i ].sid = sid; headerSWF[ i ].hkBIA = DEFAULT_HKBIA; } - return LFR_SUCCESSFUL; + + return return_value; } int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) { unsigned int i; + int return_value; + + return_value = LFR_SUCCESSFUL; for (i=0; i