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.
19 * VehicleSens_Did_MotionHeading_n.cpp
22 /*---------------------------------------------------------------------------------*
24 *---------------------------------------------------------------------------------*/
25 #include <vehicle_service/positioning_base_library.h>
26 #include "VehicleSens_DataMaster.h"
27 #include "SensorMotion_API.h"
28 #include "CommonDefine.h"
30 /*---------------------------------------------------------------------------------*
32 *---------------------------------------------------------------------------------*/
33 static VEHICLESENS_DATA_MASTER gstMotionHeading_n; // NOLINT(readability/nolint)
37 * Orientation information data master initialization process(NAVI information)
39 * Initialize the orientation information data master
46 void VehicleSensInitMotionHeadingN(void) {
47 SENSORMOTION_HEADINGINFO_DAT st_heading;
49 memset(&gstMotionHeading_n, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
51 /** Data ID setting */
52 gstMotionHeading_n.ul_did = VEHICLE_DID_MOTION_HEADING_NAVI;
54 /** Data size setting */
55 gstMotionHeading_n.us_size = sizeof(SENSORMOTION_HEADINGINFO_DAT);
57 /** Data content setting */
58 memset(&st_heading, 0x00, sizeof(st_heading));
59 st_heading.getMethod = SENSOR_GET_METHOD_NAVI;
60 st_heading.SyncCnt = 0x00;
61 st_heading.isEnable = SENSORMOTION_STATUS_DISABLE;
62 st_heading.posSts = 0x00;
63 st_heading.Heading = 0x00;
64 memcpy(&gstMotionHeading_n.uc_data[0], &st_heading, sizeof(st_heading));
71 * Compass Data Master SET Processing(NAVI information)
73 * Update the orientation information data master
75 * @param[in] VEHICLESENS_DATA_MASTER *pst_heading : Pointer to the data master acquisition destination
78 * @retval VEHICLESENS_EQ : No data change
79 * @retval VEHICLESENS_NEQ : Data change
81 u_int8 VehicleSensSetMotionHeadingN(const SENSORMOTION_HEADINGINFO_DAT *pst_heading) {
83 VEHICLESENS_DATA_MASTER *pst_master;
85 pst_master = &gstMotionHeading_n;
87 /** With the contents of the current data master,Compare received data */
88 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_heading, sizeof(SENSORMOTION_HEADINGINFO_DAT));
90 /** Received data is set in the data master. */
91 pst_master->ul_did = VEHICLE_DID_MOTION_HEADING_NAVI;
92 pst_master->us_size = sizeof(SENSORMOTION_HEADINGINFO_DAT);
93 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
94 memcpy(pst_master->uc_data, pst_heading, sizeof(SENSORMOTION_HEADINGINFO_DAT));
101 * Compass Data Master GET Processing(NAVI information)
103 * Provide an orientation information data master
106 * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
110 void VehicleSensGetMotionHeadingN(VEHICLESENS_DATA_MASTER *pst_data) { // LCOV_EXCL_START 8: dead code.
111 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
112 const VEHICLESENS_DATA_MASTER *pst_master;
114 pst_master = &gstMotionHeading_n;
116 /** Store the data master in the specified destination. */
117 pst_data->ul_did = pst_master->ul_did;
118 pst_data->us_size = pst_master->us_size;
119 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
120 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
128 * Compass Data Master GET Processing(NAVI information)
130 * Providing orientation information data master with orientation and unit conversion
133 * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
137 void VehicleSensGetMotionHeadingnCnvData(VEHICLESENS_DATA_MASTER *pst_data) {
138 const VEHICLESENS_DATA_MASTER *pst_master;
139 SENSORMOTION_HEADINGINFO_DAT st_heading;
142 pst_master = &gstMotionHeading_n;
144 /* Perform the orientation conversion[-179 to +180] -> [0 to 359] */
145 memcpy(&st_heading, pst_master->uc_data, sizeof(st_heading));
146 i_heading = static_cast<int16>(st_heading.Heading);
148 i_heading = static_cast<int16>(360 - i_heading);
150 i_heading = static_cast<int16>(i_heading * -1);
152 /* Perform unit conversion[Once] -> [0.01 degree] */
153 st_heading.Heading = (u_int16)(i_heading * 100);
155 /** Store the data master in the specified destination. */
156 pst_data->ul_did = pst_master->ul_did;
157 pst_data->us_size = pst_master->us_size;
158 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
159 memcpy(pst_data->uc_data, &st_heading, sizeof(st_heading));