LCOV - code coverage report
Current view: top level - message - msg_actuator.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 34 0
Test Date: 2026-02-15 13:08:52 Functions: 0.0 % 5 0
Branches: 0.0 % 9 0

             Branch data     Line data    Source code
       1                 :             : #include <stdbool.h>
       2                 :             : #include <stdint.h>
       3                 :             : 
       4                 :             : #include "can.h"
       5                 :             : #include "message_types.h"
       6                 :             : #include "msg_actuator.h"
       7                 :             : #include "msg_common.h"
       8                 :             : 
       9                 :           0 : void build_actuator_cmd_msg(can_msg_prio_t prio, uint16_t timestamp, can_actuator_id_t actuator_id,
      10                 :             :                                                         can_actuator_state_t actuator_cmd, can_msg_t *output) {
      11                 :           0 :         w_assert(output);
      12                 :             : 
      13                 :           0 :         output->sid = build_sid(prio, MSG_ACTUATOR_CMD, actuator_id);
      14                 :           0 :         write_timestamp(timestamp, output);
      15                 :             : 
      16                 :           0 :         output->data[2] = (uint8_t)actuator_cmd;
      17                 :           0 :         output->data_len = 3;
      18                 :           0 : }
      19                 :             : 
      20                 :           0 : void build_actuator_status_msg(can_msg_prio_t prio, uint16_t timestamp,
      21                 :             :                                                            can_actuator_id_t actuator_id,
      22                 :             :                                                            can_actuator_state_t actuator_curr_state,
      23                 :             :                                                            can_actuator_state_t actuator_cmd_state, can_msg_t *output) {
      24                 :           0 :         w_assert(output);
      25                 :             : 
      26                 :           0 :         output->sid = build_sid(prio, MSG_ACTUATOR_STATUS, actuator_id);
      27                 :           0 :         write_timestamp(timestamp, output);
      28                 :             : 
      29                 :           0 :         output->data[2] = (uint8_t)actuator_curr_state;
      30                 :           0 :         output->data[3] = (uint8_t)actuator_cmd_state;
      31                 :           0 :         output->data_len = 4;
      32                 :           0 : }
      33                 :             : 
      34                 :           0 : int get_actuator_id(const can_msg_t *msg) {
      35                 :           0 :         w_assert(msg);
      36                 :             : 
      37                 :           0 :         uint16_t msg_type = get_message_type(msg);
      38         [ #  # ]:           0 :         switch (msg_type) {
      39                 :           0 :                 case MSG_ACTUATOR_CMD:
      40                 :             :                 case MSG_ACTUATOR_STATUS:
      41                 :             : 
      42                 :           0 :                         return get_message_metadata(msg);
      43                 :             : 
      44                 :             :                 default:
      45                 :             :                         // not a valid field for this message type
      46                 :             :                         return -1;
      47                 :             :         }
      48                 :             : }
      49                 :             : 
      50                 :           0 : int get_curr_actuator_state(const can_msg_t *msg) {
      51                 :           0 :         w_assert(msg);
      52                 :             : 
      53                 :           0 :         uint16_t msg_type = get_message_type(msg);
      54         [ #  # ]:           0 :         if (msg_type == MSG_ACTUATOR_STATUS) {
      55                 :           0 :                 return msg->data[2];
      56                 :             :         } else {
      57                 :             :                 // not a valid field for this message type
      58                 :             :                 return -1;
      59                 :             :         }
      60                 :             : }
      61                 :             : 
      62                 :           0 : int get_cmd_actuator_state(const can_msg_t *msg) {
      63         [ #  # ]:           0 :         if (!msg) {
      64                 :             :                 return -1;
      65                 :             :         }
      66                 :             : 
      67                 :           0 :         uint16_t msg_type = get_message_type(msg);
      68      [ #  #  # ]:           0 :         switch (msg_type) {
      69                 :           0 :                 case MSG_ACTUATOR_STATUS:
      70                 :           0 :                         return msg->data[3];
      71                 :             : 
      72                 :           0 :                 case MSG_ACTUATOR_CMD:
      73                 :           0 :                         return msg->data[2];
      74                 :             : 
      75                 :             :                 default:
      76                 :             :                         // not a valid field for this message type
      77                 :             :                         return -1;
      78                 :             :         }
      79                 :             : }
        

Generated by: LCOV version 2.0-1