LCOV - code coverage report
Current view: top level - src/tc_tm - tm_lfr_tc_exe.c (source / functions) Hit Total Coverage
Test: trace.info Lines: 169 201 84.1 %
Date: 2023-02-20 11:47:18 Functions: 5 6 83.3 %

          Line data    Source code
       1             : /*------------------------------------------------------------------------------
       2             : --  Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
       3             : --  This file is a part of the LFR FSW
       4             : --  Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS
       5             : --
       6             : --  This program is free software; you can redistribute it and/or modify
       7             : --  it under the terms of the GNU General Public License as published by
       8             : --  the Free Software Foundation; either version 2 of the License, or
       9             : --  (at your option) any later version.
      10             : --
      11             : --  This program is distributed in the hope that it will be useful,
      12             : --  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : --  GNU General Public License for more details.
      15             : --
      16             : --  You should have received a copy of the GNU General Public License
      17             : --  along with this program; if not, write to the Free Software
      18             : --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      19             : -------------------------------------------------------------------------------*/
      20             : /*--                  Author : Paul Leroy
      21             : --                   Contact : Alexis Jeandet
      22             : --                      Mail : alexis.jeandet@lpp.polytechnique.fr
      23             : ----------------------------------------------------------------------------*/
      24             : 
      25             : /** Functions to send TM packets related to TC parsing and execution.
      26             :  *
      27             :  * @file
      28             :  * @author P. LEROY
      29             :  *
      30             :  * A group of functions to send appropriate TM packets after parsing and execution:
      31             :  * - TM_LFR_TC_EXE_SUCCESS
      32             :  * - TM_LFR_TC_EXE_INCONSISTENT
      33             :  * - TM_LFR_TC_EXE_NOT_EXECUTABLE
      34             :  * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
      35             :  * - TM_LFR_TC_EXE_ERROR
      36             :  * - TM_LFR_TC_EXE_CORRUPTED
      37             :  *
      38             :  */
      39             : 
      40             : #include "tc_tm/tm_lfr_tc_exe.h"
      41             : #include "fsw_debug.h"
      42             : #include "hw/lfr_regs.h"
      43             : 
      44        1333 : int send_tm_lfr_tc_exe_success(const ccsdsTelecommandPacket_t* const TC, rtems_id queue_id)
      45             : {
      46             :     /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
      47             :      *
      48             :      * @param TC points to the TeleCommand packet that is being processed
      49             :      * @param queue_id is the id of the queue which handles TM
      50             :      *
      51             :      * @return RTEMS directive status code:
      52             :      * - RTEMS_SUCCESSFUL - message sent successfully
      53             :      * - RTEMS_INVALID_ID - invalid queue id
      54             :      * - RTEMS_INVALID_SIZE - invalid message size
      55             :      * - RTEMS_INVALID_ADDRESS - buffer is NULL
      56             :      * - RTEMS_UNSATISFIED - out of message buffers
      57             :      * - RTEMS_TOO_MANY - queue s limit has been reached
      58             :      *
      59             :      */
      60             : 
      61             :     rtems_status_code status;
      62             :     Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
      63             : 
      64        1333 :     TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
      65        1333 :     TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
      66        1333 :     TM.reserved = DEFAULT_RESERVED;
      67        1333 :     TM.userApplication = CCSDS_USER_APP;
      68             :     // PACKET HEADER
      69        1333 :     TM.packetID[0] = (unsigned char)(APID_TM_TC_EXE >> SHIFT_1_BYTE);
      70        1333 :     TM.packetID[1] = (unsigned char)(APID_TM_TC_EXE);
      71        1333 :     increment_seq_counter_destination_id(TM.packetSequenceControl, TC->sourceID);
      72        1333 :     TM.packetLength[0] = (unsigned char)(PACKET_LENGTH_TC_EXE_SUCCESS >> SHIFT_1_BYTE);
      73        1333 :     TM.packetLength[1] = (unsigned char)(PACKET_LENGTH_TC_EXE_SUCCESS);
      74             :     // DATA FIELD HEADER
      75        1333 :     TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
      76        1333 :     TM.serviceType = TM_TYPE_TC_EXE;
      77        1333 :     TM.serviceSubType = TM_SUBTYPE_EXE_OK;
      78        1333 :     TM.destinationID = TC->sourceID;
      79        1333 :     TM.time[BYTE_0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
      80        1333 :     TM.time[BYTE_1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
      81        1333 :     TM.time[BYTE_2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
      82        1333 :     TM.time[BYTE_3] = (unsigned char)(time_management_regs->coarse_time);
      83        1333 :     TM.time[BYTE_4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
      84        1333 :     TM.time[BYTE_5] = (unsigned char)(time_management_regs->fine_time);
      85             :     //
      86        1333 :     TM.telecommand_pkt_id[0] = TC->packetID[0];
      87        1333 :     TM.telecommand_pkt_id[1] = TC->packetID[1];
      88        1333 :     TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
      89        1333 :     TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
      90             : 
      91             :     // SEND DATA
      92        1333 :     status = rtems_message_queue_send(queue_id, &TM, sizeof(TM));
      93             :     DEBUG_CHECK_STATUS(status);
      94             : 
      95             :     // UPDATE HK FIELDS
      96        1333 :     update_last_TC_exe(TC, TM.time);
      97             : 
      98        1333 :     return status;
      99             : }
     100             : 
     101          50 : int send_tm_lfr_tc_exe_inconsistent(const ccsdsTelecommandPacket_t* const TC, rtems_id queue_id,
     102             :     unsigned char byte_position, unsigned char rcv_value)
     103             : {
     104             :     /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message
     105             :      * queue.
     106             :      *
     107             :      * @param TC points to the TeleCommand packet that is being processed
     108             :      * @param queue_id is the id of the queue which handles TM
     109             :      * @param byte_position is the byte position of the MSB of the parameter that has been seen as
     110             :      * inconsistent
     111             :      * @param rcv_value  is the value of the LSB of the parameter that has been detected as
     112             :      * inconsistent
     113             :      *
     114             :      * @return RTEMS directive status code:
     115             :      * - RTEMS_SUCCESSFUL - message sent successfully
     116             :      * - RTEMS_INVALID_ID - invalid queue id
     117             :      * - RTEMS_INVALID_SIZE - invalid message size
     118             :      * - RTEMS_INVALID_ADDRESS - buffer is NULL
     119             :      * - RTEMS_UNSATISFIED - out of message buffers
     120             :      * - RTEMS_TOO_MANY - queue s limit has been reached
     121             :      *
     122             :      */
     123             : 
     124             :     rtems_status_code status;
     125             :     Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
     126             : 
     127          50 :     TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
     128          50 :     TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
     129          50 :     TM.reserved = DEFAULT_RESERVED;
     130          50 :     TM.userApplication = CCSDS_USER_APP;
     131             :     // PACKET HEADER
     132          50 :     TM.packetID[0] = (unsigned char)(APID_TM_TC_EXE >> SHIFT_1_BYTE);
     133          50 :     TM.packetID[1] = (unsigned char)(APID_TM_TC_EXE);
     134          50 :     increment_seq_counter_destination_id(TM.packetSequenceControl, TC->sourceID);
     135          50 :     TM.packetLength[0] = (unsigned char)(PACKET_LENGTH_TC_EXE_INCONSISTENT >> SHIFT_1_BYTE);
     136          50 :     TM.packetLength[1] = (unsigned char)(PACKET_LENGTH_TC_EXE_INCONSISTENT);
     137             :     // DATA FIELD HEADER
     138          50 :     TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
     139          50 :     TM.serviceType = TM_TYPE_TC_EXE;
     140          50 :     TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
     141          50 :     TM.destinationID = TC->sourceID;
     142          50 :     TM.time[BYTE_0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
     143          50 :     TM.time[BYTE_1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
     144          50 :     TM.time[BYTE_2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
     145          50 :     TM.time[BYTE_3] = (unsigned char)(time_management_regs->coarse_time);
     146          50 :     TM.time[BYTE_4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
     147          50 :     TM.time[BYTE_5] = (unsigned char)(time_management_regs->fine_time);
     148             :     //
     149          50 :     TM.tc_failure_code[0] = (char)(WRONG_APP_DATA >> SHIFT_1_BYTE);
     150          50 :     TM.tc_failure_code[1] = (char)(WRONG_APP_DATA);
     151          50 :     TM.telecommand_pkt_id[0] = TC->packetID[0];
     152          50 :     TM.telecommand_pkt_id[1] = TC->packetID[1];
     153          50 :     TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
     154          50 :     TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
     155          50 :     TM.tc_service = TC->serviceType; // type of the rejected TC
     156          50 :     TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
     157          50 :     TM.byte_position = byte_position;
     158          50 :     TM.rcv_value = rcv_value;
     159             : 
     160             :     // SEND DATA
     161          50 :     status = rtems_message_queue_send(queue_id, &TM, sizeof(TM));
     162             :     DEBUG_CHECK_STATUS(status);
     163             : 
     164             :     // UPDATE HK FIELDS
     165          50 :     update_last_TC_rej(TC, TM.time);
     166             : 
     167          50 :     return status;
     168             : }
     169             : 
     170         212 : int send_tm_lfr_tc_exe_not_executable(const ccsdsTelecommandPacket_t* const TC, rtems_id queue_id)
     171             : {
     172             :     /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message
     173             :      * queue.
     174             :      *
     175             :      * @param TC points to the TeleCommand packet that is being processed
     176             :      * @param queue_id is the id of the queue which handles TM
     177             :      *
     178             :      * @return RTEMS directive status code:
     179             :      * - RTEMS_SUCCESSFUL - message sent successfully
     180             :      * - RTEMS_INVALID_ID - invalid queue id
     181             :      * - RTEMS_INVALID_SIZE - invalid message size
     182             :      * - RTEMS_INVALID_ADDRESS - buffer is NULL
     183             :      * - RTEMS_UNSATISFIED - out of message buffers
     184             :      * - RTEMS_TOO_MANY - queue s limit has been reached
     185             :      *
     186             :      */
     187             : 
     188             :     rtems_status_code status;
     189             :     Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
     190             : 
     191         212 :     TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
     192         212 :     TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
     193         212 :     TM.reserved = DEFAULT_RESERVED;
     194         212 :     TM.userApplication = CCSDS_USER_APP;
     195             :     // PACKET HEADER
     196         212 :     TM.packetID[0] = (unsigned char)(APID_TM_TC_EXE >> SHIFT_1_BYTE);
     197         212 :     TM.packetID[1] = (unsigned char)(APID_TM_TC_EXE);
     198         212 :     increment_seq_counter_destination_id(TM.packetSequenceControl, TC->sourceID);
     199         212 :     TM.packetLength[0] = (unsigned char)(PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> SHIFT_1_BYTE);
     200         212 :     TM.packetLength[1] = (unsigned char)(PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE);
     201             :     // DATA FIELD HEADER
     202         212 :     TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
     203         212 :     TM.serviceType = TM_TYPE_TC_EXE;
     204         212 :     TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
     205         212 :     TM.destinationID = TC->sourceID; // default destination id
     206         212 :     TM.time[BYTE_0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
     207         212 :     TM.time[BYTE_1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
     208         212 :     TM.time[BYTE_2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
     209         212 :     TM.time[BYTE_3] = (unsigned char)(time_management_regs->coarse_time);
     210         212 :     TM.time[BYTE_4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
     211         212 :     TM.time[BYTE_5] = (unsigned char)(time_management_regs->fine_time);
     212             :     //
     213         212 :     TM.tc_failure_code[0] = (char)(TC_NOT_EXE >> SHIFT_1_BYTE);
     214         212 :     TM.tc_failure_code[1] = (char)(TC_NOT_EXE);
     215         212 :     TM.telecommand_pkt_id[0] = TC->packetID[0];
     216         212 :     TM.telecommand_pkt_id[1] = TC->packetID[1];
     217         212 :     TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
     218         212 :     TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
     219         212 :     TM.tc_service = TC->serviceType; // type of the rejected TC
     220         212 :     TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
     221         212 :     TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
     222         212 :     TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
     223             : 
     224             :     // SEND DATA
     225         212 :     status = rtems_message_queue_send(queue_id, &TM, sizeof(TM));
     226             :     DEBUG_CHECK_STATUS(status);
     227             : 
     228             :     // UPDATE HK FIELDS
     229         212 :     update_last_TC_rej(TC, TM.time);
     230             : 
     231         212 :     return status;
     232             : }
     233             : 
     234           0 : int send_tm_lfr_tc_exe_error(const ccsdsTelecommandPacket_t* const TC, rtems_id queue_id)
     235             : {
     236             :     /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
     237             :      *
     238             :      * @param TC points to the TeleCommand packet that is being processed
     239             :      * @param queue_id is the id of the queue which handles TM
     240             :      *
     241             :      * @return RTEMS directive status code:
     242             :      * - RTEMS_SUCCESSFUL - message sent successfully
     243             :      * - RTEMS_INVALID_ID - invalid queue id
     244             :      * - RTEMS_INVALID_SIZE - invalid message size
     245             :      * - RTEMS_INVALID_ADDRESS - buffer is NULL
     246             :      * - RTEMS_UNSATISFIED - out of message buffers
     247             :      * - RTEMS_TOO_MANY - queue s limit has been reached
     248             :      *
     249             :      */
     250             : 
     251             :     rtems_status_code status;
     252             :     Packet_TM_LFR_TC_EXE_ERROR_t TM;
     253             : 
     254           0 :     TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
     255           0 :     TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
     256           0 :     TM.reserved = DEFAULT_RESERVED;
     257           0 :     TM.userApplication = CCSDS_USER_APP;
     258             :     // PACKET HEADER
     259           0 :     TM.packetID[0] = (unsigned char)(APID_TM_TC_EXE >> SHIFT_1_BYTE);
     260           0 :     TM.packetID[1] = (unsigned char)(APID_TM_TC_EXE);
     261           0 :     increment_seq_counter_destination_id(TM.packetSequenceControl, TC->sourceID);
     262           0 :     TM.packetLength[0] = (unsigned char)(PACKET_LENGTH_TC_EXE_ERROR >> SHIFT_1_BYTE);
     263           0 :     TM.packetLength[1] = (unsigned char)(PACKET_LENGTH_TC_EXE_ERROR);
     264             :     // DATA FIELD HEADER
     265           0 :     TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
     266           0 :     TM.serviceType = TM_TYPE_TC_EXE;
     267           0 :     TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
     268           0 :     TM.destinationID = TC->sourceID; // default destination id
     269           0 :     TM.time[BYTE_0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
     270           0 :     TM.time[BYTE_1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
     271           0 :     TM.time[BYTE_2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
     272           0 :     TM.time[BYTE_3] = (unsigned char)(time_management_regs->coarse_time);
     273           0 :     TM.time[BYTE_4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
     274           0 :     TM.time[BYTE_5] = (unsigned char)(time_management_regs->fine_time);
     275             :     //
     276           0 :     TM.tc_failure_code[0] = (char)(FAIL_DETECTED >> SHIFT_1_BYTE);
     277           0 :     TM.tc_failure_code[1] = (char)(FAIL_DETECTED);
     278           0 :     TM.telecommand_pkt_id[0] = TC->packetID[0];
     279           0 :     TM.telecommand_pkt_id[1] = TC->packetID[1];
     280           0 :     TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
     281           0 :     TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
     282           0 :     TM.tc_service = TC->serviceType; // type of the rejected TC
     283           0 :     TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
     284             : 
     285             :     // SEND DATA
     286           0 :     status = rtems_message_queue_send(queue_id, &TM, sizeof(TM));
     287             :     DEBUG_CHECK_STATUS(status);
     288             : 
     289             :     // UPDATE HK FIELDS
     290           0 :     update_last_TC_rej(TC, TM.time);
     291             : 
     292           0 :     return status;
     293             : }
     294             : 
     295        3996 : int send_tm_lfr_tc_exe_corrupted(const ccsdsTelecommandPacket_t* const TC, rtems_id queue_id,
     296             :     const unsigned char* const computed_CRC, const unsigned char* const currentTC_LEN_RCV,
     297             :     unsigned char destinationID)
     298             : {
     299             :     /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
     300             :      *
     301             :      * @param TC points to the TeleCommand packet that is being processed
     302             :      * @param queue_id is the id of the queue which handles TM
     303             :      * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the
     304             :      * parsing of the TeleCommand
     305             :      * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field
     306             :      * computed on the received data
     307             :      *
     308             :      * @return RTEMS directive status code:
     309             :      * - RTEMS_SUCCESSFUL - message sent successfully
     310             :      * - RTEMS_INVALID_ID - invalid queue id
     311             :      * - RTEMS_INVALID_SIZE - invalid message size
     312             :      * - RTEMS_INVALID_ADDRESS - buffer is NULL
     313             :      * - RTEMS_UNSATISFIED - out of message buffers
     314             :      * - RTEMS_TOO_MANY - queue s limit has been reached
     315             :      *
     316             :      */
     317             : 
     318             :     rtems_status_code status;
     319             :     Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
     320             : 
     321             :     unsigned int estimatedPacketLength
     322        3996 :         = (unsigned int)((currentTC_LEN_RCV[0] * CONST_256) + currentTC_LEN_RCV[1]);
     323             :     const unsigned char* const packetDataField
     324        3996 :         = &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
     325             : 
     326             : 
     327        3996 :     TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
     328        3996 :     TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
     329        3996 :     TM.reserved = DEFAULT_RESERVED;
     330        3996 :     TM.userApplication = CCSDS_USER_APP;
     331             :     // PACKET HEADER
     332        3996 :     TM.packetID[0] = (unsigned char)(APID_TM_TC_EXE >> SHIFT_1_BYTE);
     333        3996 :     TM.packetID[1] = (unsigned char)(APID_TM_TC_EXE);
     334        3996 :     increment_seq_counter_destination_id(TM.packetSequenceControl, TC->sourceID);
     335        3996 :     TM.packetLength[0] = (unsigned char)(PACKET_LENGTH_TC_EXE_CORRUPTED >> SHIFT_1_BYTE);
     336        3996 :     TM.packetLength[1] = (unsigned char)(PACKET_LENGTH_TC_EXE_CORRUPTED);
     337             :     // DATA FIELD HEADER
     338        3996 :     TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
     339        3996 :     TM.serviceType = TM_TYPE_TC_EXE;
     340        3996 :     TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
     341        3996 :     TM.destinationID = destinationID;
     342        3996 :     TM.time[BYTE_0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
     343        3996 :     TM.time[BYTE_1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
     344        3996 :     TM.time[BYTE_2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
     345        3996 :     TM.time[BYTE_3] = (unsigned char)(time_management_regs->coarse_time);
     346        3996 :     TM.time[BYTE_4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
     347        3996 :     TM.time[BYTE_5] = (unsigned char)(time_management_regs->fine_time);
     348             :     //
     349        3996 :     TM.tc_failure_code[0] = (unsigned char)(CORRUPTED >> SHIFT_1_BYTE);
     350        3996 :     TM.tc_failure_code[1] = (unsigned char)(CORRUPTED);
     351        3996 :     TM.telecommand_pkt_id[0] = TC->packetID[0];
     352        3996 :     TM.telecommand_pkt_id[1] = TC->packetID[1];
     353        3996 :     TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
     354        3996 :     TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
     355        3996 :     TM.tc_service = TC->serviceType; // type of the rejected TC
     356        3996 :     TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
     357        3996 :     TM.pkt_len_rcv_value[0] = TC->packetLength[0];
     358        3996 :     TM.pkt_len_rcv_value[1] = TC->packetLength[1];
     359        3996 :     TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
     360        3996 :     TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
     361        3996 :     TM.rcv_crc[0] = packetDataField[estimatedPacketLength - 1];
     362        3996 :     TM.rcv_crc[1] = packetDataField[estimatedPacketLength];
     363        3996 :     TM.computed_crc[0] = computed_CRC[0];
     364        3996 :     TM.computed_crc[1] = computed_CRC[1];
     365             : 
     366             :     // SEND DATA
     367        3996 :     status = rtems_message_queue_send(queue_id, &TM, sizeof(TM));
     368             :     DEBUG_CHECK_STATUS(status);
     369             : 
     370             :     // UPDATE HK FIELDS
     371        3996 :     update_last_TC_rej(TC, TM.time);
     372             : 
     373        3996 :     return status;
     374             : }
     375             : 
     376        5591 : void increment_seq_counter_destination_id(
     377             :     unsigned char* packet_sequence_control, unsigned char destination_id)
     378             : {
     379             :     /** This function increment the packet sequence control parameter of a TC, depending on its
     380             :      * destination ID.
     381             :      *
     382             :      * @param packet_sequence_control points to the packet sequence control which will be
     383             :      * incremented
     384             :      * @param destination_id is the destination ID of the TM, there is one counter by destination ID
     385             :      *
     386             :      * If the destination ID is not known, a dedicated counter is incremented.
     387             :      *
     388             :      */
     389             : 
     390             :     unsigned short sequence_cnt;
     391             :     unsigned short segmentation_grouping_flag;
     392             :     unsigned short new_packet_sequence_control;
     393             :     unsigned char i;
     394             : 
     395        5591 :     switch (destination_id)
     396             :     {
     397             :         case SID_TC_GROUND:
     398          14 :             i = GROUND;
     399          14 :             break;
     400             :         case SID_TC_MISSION_TIMELINE:
     401        2198 :             i = MISSION_TIMELINE;
     402        2198 :             break;
     403             :         case SID_TC_TC_SEQUENCES:
     404          13 :             i = TC_SEQUENCES;
     405          13 :             break;
     406             :         case SID_TC_RECOVERY_ACTION_CMD:
     407          13 :             i = RECOVERY_ACTION_CMD;
     408          13 :             break;
     409             :         case SID_TC_BACKUP_MISSION_TIMELINE:
     410          13 :             i = BACKUP_MISSION_TIMELINE;
     411          13 :             break;
     412             :         case SID_TC_DIRECT_CMD:
     413          13 :             i = DIRECT_CMD;
     414          13 :             break;
     415             :         case SID_TC_SPARE_GRD_SRC1:
     416          13 :             i = SPARE_GRD_SRC1;
     417          13 :             break;
     418             :         case SID_TC_SPARE_GRD_SRC2:
     419          13 :             i = SPARE_GRD_SRC2;
     420          13 :             break;
     421             :         case SID_TC_OBCP:
     422          13 :             i = OBCP;
     423          13 :             break;
     424             :         case SID_TC_SYSTEM_CONTROL:
     425          13 :             i = SYSTEM_CONTROL;
     426          13 :             break;
     427             :         case SID_TC_AOCS:
     428          13 :             i = AOCS;
     429          13 :             break;
     430             :         case SID_TC_RPW_INTERNAL:
     431          13 :             i = RPW_INTERNAL;
     432          13 :             break;
     433             :         default:
     434        3249 :             i = GROUND;
     435             :             break;
     436             :     }
     437             : 
     438        5591 :     segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
     439        5591 :     sequence_cnt = sequenceCounters_TC_EXE[i] & SEQ_CNT_MASK;
     440             : 
     441        5591 :     new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt;
     442             : 
     443        5591 :     packet_sequence_control[0] = (unsigned char)(new_packet_sequence_control >> SHIFT_1_BYTE);
     444        5591 :     packet_sequence_control[1] = (unsigned char)(new_packet_sequence_control);
     445             : 
     446             :     // increment the sequence counter
     447        5591 :     if (sequenceCounters_TC_EXE[i] < SEQ_CNT_MAX)
     448             :     {
     449        5591 :         sequenceCounters_TC_EXE[i] = sequenceCounters_TC_EXE[i] + 1;
     450             :     }
     451             :     else
     452             :     {
     453           0 :         sequenceCounters_TC_EXE[i] = 0;
     454             :     }
     455        5591 : }

Generated by: LCOV version 1.14