LCOV - code coverage report
Current view: top level - message/msg_actuator.c (source / functions) Coverage Total Hit
Test: coverage-filtered.info Lines: 84.9 % 53 45
Test Date: 2026-04-29 08:47:32 Functions: 100.0 % 5 5
Branches: 69.4 % 36 25
MC/DC: 69.4 % 36 25

             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_actuator.h"
       9                 :              :             : #include "msg_common.h"
      10                 :              :             : 
      11                 :              :           2 : void build_actuator_cmd_msg(can_msg_prio_t prio, uint16_t timestamp, can_actuator_id_t actuator_id,
      12                 :              :             :                                                         can_actuator_state_t actuator_cmd, can_msg_t *output) {
      13         [ +  + ]:      [ T  F ]:           2 :         w_assert(output);
      14                 :              :             : 
      15                 :              :           1 :         output->sid = build_sid(prio, MSG_ACTUATOR_CMD, actuator_id);
      16                 :              :           1 :         write_timestamp(timestamp, output);
      17                 :              :             : 
      18                 :              :           1 :         output->data[2] = (uint8_t)actuator_cmd;
      19                 :              :           1 :         output->data_len = 3;
      20                 :              :           1 : }
      21                 :              :             : 
      22                 :              :           2 : void build_actuator_status_msg(can_msg_prio_t prio, uint16_t timestamp,
      23                 :              :             :                                                            can_actuator_id_t actuator_id,
      24                 :              :             :                                                            can_actuator_state_t actuator_cmd_state,
      25                 :              :             :                                                            can_actuator_state_t actuator_curr_state, can_msg_t *output) {
      26         [ +  + ]:      [ T  F ]:           2 :         w_assert(output);
      27                 :              :             : 
      28                 :              :           1 :         output->sid = build_sid(prio, MSG_ACTUATOR_STATUS, actuator_id);
      29                 :              :           1 :         write_timestamp(timestamp, output);
      30                 :              :             : 
      31                 :              :           1 :         output->data[2] = (uint8_t)actuator_cmd_state;
      32                 :              :           1 :         output->data[3] = (uint8_t)actuator_curr_state;
      33                 :              :           1 :         output->data_len = 4;
      34                 :              :           1 : }
      35                 :              :             : 
      36                 :              :           3 : w_status_t get_actuator_id(const can_msg_t *msg, can_actuator_id_t *actuator_id) {
      37         [ +  + ]:      [ T  F ]:           3 :         w_assert(msg);
      38         [ +  - ]:      [ T  f ]:           2 :         w_assert(actuator_id);
      39                 :              :             : 
      40                 :              :           2 :         *actuator_id = (can_actuator_id_t)get_message_metadata(msg);
      41                 :              :             : 
      42                 :              :           2 :         can_msg_type_t msg_type = get_message_type(msg);
      43                 :              :             : 
      44         [ +  + ]:      [ T  F ]:           2 :         if (msg_type == MSG_ACTUATOR_CMD) {
      45         [ +  - ]:      [ T  f ]:           1 :                 if (msg->data_len == 3) {
      46                 :              :           1 :                         return W_SUCCESS;
      47                 :              :             :                 } else {
      48                 :              :           0 :                         return W_DATA_FORMAT_ERROR;
      49                 :              :             :                 }
      50         [ +  - ]:      [ T  f ]:           1 :         } else if (msg_type == MSG_ACTUATOR_STATUS) {
      51         [ +  - ]:      [ T  f ]:           1 :                 if (msg->data_len == 4) {
      52                 :              :           1 :                         return W_SUCCESS;
      53                 :              :             :                 } else {
      54                 :              :           0 :                         return W_DATA_FORMAT_ERROR;
      55                 :              :             :                 }
      56                 :              :             :         }
      57                 :              :             : 
      58                 :              :           0 :         return W_INVALID_PARAM;
      59                 :              :             : }
      60                 :              :             : 
      61                 :              :           2 : w_status_t get_curr_actuator_state(const can_msg_t *msg,
      62                 :              :             :                                                                    can_actuator_state_t *curr_actuator_state) {
      63         [ +  + ]:      [ T  F ]:           2 :         w_assert(msg);
      64         [ +  - ]:      [ T  f ]:           1 :         w_assert(curr_actuator_state);
      65                 :              :             : 
      66                 :              :           1 :         *curr_actuator_state = (can_actuator_state_t)msg->data[3];
      67                 :              :             : 
      68                 :              :           1 :         can_msg_type_t msg_type = get_message_type(msg);
      69                 :              :             : 
      70         [ -  + ]:      [ t  F ]:           1 :         if (msg_type != MSG_ACTUATOR_STATUS) {
      71                 :              :           0 :                 return W_INVALID_PARAM;
      72                 :              :             :         }
      73                 :              :             : 
      74         [ +  - ]:      [ T  f ]:           1 :         if (msg->data_len == 4) {
      75                 :              :           1 :                 return W_SUCCESS;
      76                 :              :             :         } else {
      77                 :              :           0 :                 return W_DATA_FORMAT_ERROR;
      78                 :              :             :         }
      79                 :              :             : 
      80                 :              :             :         return W_SUCCESS;
      81                 :              :             : }
      82                 :              :             : 
      83                 :              :           3 : w_status_t get_cmd_actuator_state(const can_msg_t *msg, can_actuator_state_t *cmd_actuator_state) {
      84         [ +  + ]:      [ T  F ]:           3 :         w_assert(msg);
      85         [ +  - ]:      [ T  f ]:           2 :         w_assert(cmd_actuator_state);
      86                 :              :             : 
      87                 :              :           2 :         *cmd_actuator_state = (can_actuator_state_t)msg->data[2];
      88                 :              :             : 
      89                 :              :           2 :         can_msg_type_t msg_type = get_message_type(msg);
      90                 :              :             : 
      91         [ +  + ]:      [ T  F ]:           2 :         if (msg_type == MSG_ACTUATOR_CMD) {
      92         [ +  - ]:      [ T  f ]:           1 :                 if (msg->data_len == 3) {
      93                 :              :           1 :                         return W_SUCCESS;
      94                 :              :             :                 } else {
      95                 :              :           0 :                         return W_DATA_FORMAT_ERROR;
      96                 :              :             :                 }
      97         [ +  - ]:      [ T  f ]:           1 :         } else if (msg_type == MSG_ACTUATOR_STATUS) {
      98         [ +  - ]:      [ T  f ]:           1 :                 if (msg->data_len == 4) {
      99                 :              :           1 :                         return W_SUCCESS;
     100                 :              :             :                 } else {
     101                 :              :           0 :                         return W_DATA_FORMAT_ERROR;
     102                 :              :             :                 }
     103                 :              :             :         }
     104                 :              :             : 
     105                 :              :           0 :         return W_INVALID_PARAM;
     106                 :              :             : }
        

Generated by: LCOV version 2.0-1