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 name :DeadReckoning_Common.cpp
19 * System name :PastModel002
20 * Subsystem name :DeadReckoning processes
21 * Program name :DeadReckoning shared process(DEADRECKONING_COMMON)
22 * Module configuration DeadReckoningMemcmp() Functions for Common Processing Memory Block Comparisons
23 * DeadReckoningCheckDid() Common Processing Data ID Check Function
24 * DeadReckoningGetDataMasterOffset() Get function for common processing data master offset value
25 ******************************************************************************/
26 #include "DeadReckoning_Common.h"
27 #include <vehicle_service/positioning_base_library.h>
29 /*************************************************/
31 /*************************************************/
32 static const DEADRECKONING_DID_OFFSET_TBL kGstDidListS[] = {
33 /* Data ID Offset size Reserved */
34 { VEHICLE_DID_DR_LONGITUDE, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
35 { VEHICLE_DID_DR_LATITUDE, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
36 { VEHICLE_DID_DR_ALTITUDE, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
37 { VEHICLE_DID_DR_SPEED, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
38 { VEHICLE_DID_DR_HEADING, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
39 { VEHICLE_DID_DR_GYRO_OFFSET, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
40 { VEHICLE_DID_DR_GYRO_SCALE_FACTOR, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
41 { VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
42 { VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
43 { VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, DEADRECKONING_OFFSET_NORMAL, {0, 0} },
44 { 0, 0, {0, 0} } /* Termination code */
47 /*******************************************************************************
48 * MODULE : DeadReckoningMemcmp
49 * ABSTRACT : Functions for Common Processing Memory Block Comparisons
50 * FUNCTION : Memory block comparison processing
51 * ARGUMENT : *vp_data1 : Comparison target address 1
52 * : *vp_data2 : Comparison target address 2
53 * : uc_size : Comparison Size
55 * RETURN : DEADRECKONING_EQ : No data change
56 * : DEADRECKONING_NEQ : Data change
57 ******************************************************************************/
58 u_int8 DeadReckoningMemcmp(const void *vp_data1, const void *vp_data2, size_t uc_size) { // LCOV_EXCL_START 8: dead code. // NOLINT(whitespace/line_length)
59 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
60 u_int8 l_ret = DEADRECKONING_EQ;
61 const u_int8 *p_data1 = (const u_int8 *)vp_data1;
62 const u_int8 *p_data2 = (const u_int8 *)vp_data1;
64 /* Loop by data size */
66 if (*p_data1 != *p_data2) {
68 l_ret = DEADRECKONING_NEQ;
78 /*******************************************************************************
79 * MODULE : DeadReckoningCheckDid
80 * ABSTRACT : Common Processing Data ID Check Function
81 * FUNCTION : Check if the specified DID corresponds to the vehicle sensor information
82 * ARGUMENT : ul_did : Data ID
84 * RETURN : DEADRECKONING_INVALID :Disabled
85 * : DEADRECKONING_EFFECTIVE :Enabled
86 ******************************************************************************/
87 int32 DeadReckoningCheckDid(DID ul_did) {
88 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
90 int32 l_ret = DEADRECKONING_INVALID;
92 while (0 != kGstDidListS[i].ul_did) {
93 if (kGstDidListS[i].ul_did == ul_did) {
95 l_ret = DEADRECKONING_EFFECTIVE;
103 /*******************************************************************************
104 * MODULE : DeadReckoningGetDataMasterOffset
105 * ABSTRACT : Get function for common processing data master offset value
106 * FUNCTION : Get the fixed offset value for a given DID
107 * ARGUMENT : ul_did : Data ID
109 * RETURN : Offset value(Returns 0 if DID is invalid)
111 ******************************************************************************/
112 u_int16 DeadReckoningGetDataMasterOffset(DID ul_did) {
113 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
114 int32 i = 0; /* Generic counters */
115 u_int16 us_ret = 0; /* Return value of this function */
117 while (0 != kGstDidListS[i].ul_did) {
118 if (kGstDidListS[i].ul_did == ul_did) {
120 us_ret = kGstDidListS[i].us_offset;