LCOV - code coverage report
Current view: top level - message/msg_recovery.c (source / functions) Coverage Total Hit
Test: coverage-filtered.info Lines: 100.0 % 37 37
Test Date: 2026-04-10 08:50:57 Functions: 100.0 % 4 4
Branches: 54.5 % 22 12
MC/DC: 50.0 % 22 11

             Branch data      MC/DC data    Line data    Source code
       1                 :              :             : #include <stdbool.h>
       2                 :              :             : #include <stdint.h>
       3                 :              :             : 
       4                 :              :             : #include "common.h"
       5                 :              :             : 
       6                 :              :             : #include "can.h"
       7                 :              :             : #include "message_types.h"
       8                 :              :             : #include "msg_common.h"
       9                 :              :             : #include "msg_recovery.h"
      10                 :              :             : 
      11                 :              :           1 : void build_alt_arm_cmd_msg(can_msg_prio_t prio, uint16_t timestamp, can_altimeter_id_t alt_id,
      12                 :              :             :                                                    can_alt_arm_state_t arm_cmd, can_msg_t *output) {
      13         [ +  - ]:      [ T  f ]:           1 :         w_assert(output);
      14                 :              :             : 
      15                 :              :           1 :         output->sid = build_sid(prio, MSG_ALT_ARM_CMD, alt_id);
      16                 :              :           1 :         write_timestamp(timestamp, output);
      17                 :              :             : 
      18                 :              :           1 :         output->data[2] = arm_cmd;
      19                 :              :           1 :         output->data_len = 3;
      20                 :              :           1 : }
      21                 :              :             : 
      22                 :              :           1 : void build_alt_arm_status_msg(can_msg_prio_t prio, uint16_t timestamp, can_altimeter_id_t alt_id,
      23                 :              :             :                                                           can_alt_arm_state_t arm_state, uint16_t v_drogue, uint16_t v_main,
      24                 :              :             :                                                           can_msg_t *output) {
      25         [ +  - ]:      [ T  f ]:           1 :         w_assert(output);
      26                 :              :             : 
      27                 :              :           1 :         output->sid = build_sid(prio, MSG_ALT_ARM_STATUS, alt_id);
      28                 :              :           1 :         write_timestamp(timestamp, output);
      29                 :              :             : 
      30                 :              :           1 :         output->data[2] = arm_state;
      31                 :              :             :         // drogue voltage
      32                 :              :           1 :         output->data[3] = v_drogue >> 8; // 8 msb
      33                 :              :           1 :         output->data[4] = v_drogue & 0x00FF; // 8 lsb
      34                 :              :             :         // main voltage
      35                 :              :           1 :         output->data[5] = v_main >> 8; // 8 msb
      36                 :              :           1 :         output->data[6] = v_main & 0x00FF; // 8 lsb
      37                 :              :             : 
      38                 :              :           1 :         output->data_len = 7;
      39                 :              :           1 : }
      40                 :              :             : 
      41                 :              :           2 : bool get_alt_arm_state(const can_msg_t *msg, can_altimeter_id_t *alt_id,
      42                 :              :             :                                            can_alt_arm_state_t *arm_state) {
      43         [ +  - ]:      [ T  f ]:           2 :         w_assert(msg);
      44         [ +  - ]:      [ T  f ]:           2 :         w_assert(alt_id);
      45         [ +  - ]:      [ T  f ]:           2 :         w_assert(arm_state);
      46                 :              :             : 
      47   [ +  +  +  - ]:[ t  F  t  F ]:           3 :         if ((get_message_type(msg) != MSG_ALT_ARM_CMD) &&
      48                 :              :           1 :                 (get_message_type(msg) != MSG_ALT_ARM_STATUS)) {
      49                 :              :             :                 return false;
      50                 :              :             :         }
      51                 :              :           2 :         *alt_id = (can_altimeter_id_t)get_message_metadata(msg);
      52                 :              :           2 :         *arm_state = (can_alt_arm_state_t)msg->data[2];
      53                 :              :             : 
      54                 :              :           2 :         return true;
      55                 :              :             : }
      56                 :              :             : 
      57                 :              :           1 : bool get_pyro_voltage_data(const can_msg_t *msg, uint16_t *v_drogue, uint16_t *v_main) {
      58         [ +  - ]:      [ T  f ]:           1 :         w_assert(msg);
      59         [ +  - ]:      [ T  f ]:           1 :         w_assert(v_drogue);
      60         [ +  - ]:      [ T  f ]:           1 :         w_assert(v_main);
      61                 :              :             : 
      62         [ +  - ]:      [ t  F ]:           1 :         if (get_message_type(msg) != MSG_ALT_ARM_STATUS) {
      63                 :              :             :                 return false;
      64                 :              :             :         }
      65                 :              :             : 
      66                 :              :           1 :         *v_drogue = (msg->data[3] << 8);
      67                 :              :           1 :         *v_drogue += msg->data[4];
      68                 :              :           1 :         *v_main = (msg->data[5] << 8);
      69                 :              :           1 :         *v_main += msg->data[6];
      70                 :              :             : 
      71                 :              :           1 :         return true;
      72                 :              :             : }
      73                 :              :             : 
        

Generated by: LCOV version 2.0-1