Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / DeadReckoning_Did_Heading_dr.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /************************************************************************
18 @file      DeadReckoning_Did_Heading.cpp
19 @detail      DeadReckoning data Master(VEHICLE_DID_DR_HEADING)<BR>
20         DeadReckoning data master(VEHICLE_DID_DR_HEADING)
21 *****************************************************************************/
22
23 #include <vehicle_service/positioning_base_library.h>
24 #include "DeadReckoning_DataMaster.h"
25
26 /*************************************************/
27 /*           Global variable                      */
28 /*************************************************/
29 static  DEADRECKONING_DATA_MASTER  gst_heading;    // NOLINT(readability/nolint)
30
31 /************************************************************************
32 @brief      Heading Dead Reckoning initialization function
33 @outline    Heading initialization process data master
34 @type      Completion return type
35 @param[in]    none
36 @threshold    none
37 @return      void
38 @retval      none
39 @trace
40 **************************************************************************** */
41 void DeadReckoningInitHeadingDr(void) {  // LCOV_EXCL_START 8: dead code.
42     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
43     memset(&(gst_heading), 0x00, sizeof(DEADRECKONING_DATA_MASTER));
44     gst_heading.ul_did    = VEHICLE_DID_DR_HEADING;
45     gst_heading.us_size    = VEHICLE_DSIZE_HEADING;
46     gst_heading.uc_rcv_flag  = DEADRECKONING_RCVFLAG_OFF;
47     gst_heading.dr_status    = SENSORMOTION_DRSTATUS_INVALID;
48     gst_heading.uc_data[0]  = VEHICLE_DINIT_HEADING;
49 }
50
51 /*************************************************************************
52 @brief      Heading Dead Reckoning SET function
53 @outline    To update the master data Heading.
54 @type      Completion return type
55 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  The pointer to GPS incoming message data
56 @threshold    none
57 @return      u_int8
58 @retval      DEADRECKONING_EQ  :   No data changes
59 @retval      DEADRECKONING_NEQ  :   With data changes
60 @trace
61 *****************************************************************************/
62 u_int8 DeadReckoningSetHeadingDr(const DEADRECKONING_DATA_MASTER *p_st_data) {
63     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
64     u_int8 uc_ret;
65     DEADRECKONING_DATA_MASTER *p_st_master;
66
67     p_st_master = &gst_heading;
68
69     /** Compare data master and received data */
70     uc_ret = DeadReckoningMemcmp(p_st_master->uc_data, p_st_data->uc_data, p_st_data->us_size);
71
72     /** Received data is set in the data master. */
73     p_st_master->ul_did    = p_st_data->ul_did;
74     p_st_master->us_size    = p_st_data->us_size;
75     p_st_master->uc_rcv_flag  = DEADRECKONING_RCVFLAG_ON;
76     p_st_master->dr_status    = p_st_data->dr_status;
77
78     memcpy(p_st_master->uc_data, p_st_data->uc_data, p_st_data->us_size);
79
80     return (uc_ret);
81 }
82
83 /************************************************************************
84 @brief      Heading Dead Reckoning GET function
85 @outline    Master Data provides the Heading
86 @type      Completion return type
87 @param[in]    DEADRECKONING_DATA_MASTER *p_st_data  :  Where to get a pointer to the data master
88 @threshold    none
89 @return      void
90 @retval      none
91 @trace
92 *****************************************************************************/
93 void DeadReckoningGetHeadingDr(DEADRECKONING_DATA_MASTER *p_st_data) {
94     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
95     const DEADRECKONING_DATA_MASTER *p_st_master;
96
97     p_st_master = &gst_heading;
98
99     /** Store the data master in the specified destination. */
100     p_st_data->ul_did    = p_st_master->ul_did;
101     p_st_data->us_size    = p_st_master->us_size;
102     p_st_data->uc_rcv_flag  = p_st_master->uc_rcv_flag;
103     p_st_data->dr_status  = p_st_master->dr_status;
104     memcpy(p_st_data->uc_data, p_st_master->uc_data, p_st_master->us_size);
105 }
106 // LCOV_EXCL_STOP