2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /*************************************************************************
18 @file DeadReckoning_Did_Speed.cpp
19 @detail DeadReckoning data Master(VEHICLE_DID_DR_SPEED)
20 *****************************************************************************/
22 #include <vehicle_service/positioning_base_library.h>
23 #include "DeadReckoning_DataMaster.h"
25 /*************************************************/
27 /*************************************************/
28 static DEADRECKONING_DATA_MASTER gst_speed; // NOLINT(readability/nolint)
30 /************************************************************************
31 @brief Speed Dead Reckoning initialization function
32 @outline Speed initialization process data master
33 @type Completion return type
39 **************************************************************************** */
40 void DeadReckoningInitSpeedDr(void) { // LCOV_EXCL_START 8: dead code.
41 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
42 memset(&(gst_speed), 0x00, sizeof(DEADRECKONING_DATA_MASTER));
43 gst_speed.ul_did = VEHICLE_DID_DR_SPEED;
44 gst_speed.us_size = VEHICLE_DSIZE_SPEED;
45 gst_speed.uc_rcv_flag = DEADRECKONING_RCVFLAG_OFF;
46 gst_speed.dr_status = SENSORMOTION_DRSTATUS_INVALID;
47 gst_speed.uc_data[0] = VEHICLE_DINIT_SPEED;
50 /************************************************************************
51 @brief Speed Dead Reckoning SET function
52 @outline To update the master data Speed.
53 @type Completion return type
54 @param[in] DEADRECKONING_DATA_MASTER *p_st_data : The pointer to GPS incoming message data
57 @retval DEADRECKONING_EQ : No data changes
58 @retval DEADRECKONING_NEQ : With data changes
60 *****************************************************************************/
61 u_int8 DeadReckoningSetSpeedDr(const DEADRECKONING_DATA_MASTER *p_st_data) {
62 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
64 DEADRECKONING_DATA_MASTER *p_st_master;
66 p_st_master = &gst_speed;
68 /** Compare data master and received data */
69 uc_ret = DeadReckoningMemcmp(p_st_master->uc_data, p_st_data->uc_data, p_st_data->us_size);
71 /** Received data is set in the data master. */
72 p_st_master->ul_did = p_st_data->ul_did;
73 p_st_master->us_size = p_st_data->us_size;
74 p_st_master->uc_rcv_flag = DEADRECKONING_RCVFLAG_ON;
75 p_st_master->dr_status = p_st_data->dr_status;
77 memcpy(p_st_master->uc_data, p_st_data->uc_data, p_st_data->us_size);
82 /*************************************************************************
83 @brief Speed Dead Reckoning GET function
84 @outline Master Data provides the Speed
85 @type Completion return type
86 @param[in] DEADRECKONING_DATA_MASTER *p_st_data : Where to get a pointer to the data master
91 *****************************************************************************/
92 void DeadReckoningGetSpeedDr(DEADRECKONING_DATA_MASTER *p_st_data) {
93 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
94 const DEADRECKONING_DATA_MASTER *p_st_master;
96 p_st_master = &gst_speed;
98 /** Store the data master in the specified destination. */
99 p_st_data->ul_did = p_st_master->ul_did;
100 p_st_data->us_size = p_st_master->us_size;
101 p_st_data->uc_rcv_flag = p_st_master->uc_rcv_flag;
102 p_st_data->dr_status = p_st_master->dr_status;
103 memcpy(p_st_data->uc_data, p_st_master->uc_data, p_st_master->us_size);