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 VehicleSens_Did_MotionHeading_g.cpp
19 @detail Orientation Information Data Master Management(NMEA information)
20 ******************************************************************************/
21 #include <vehicle_service/positioning_base_library.h>
22 #include "VehicleSens_DataMaster.h"
23 #include "CommonDefine.h"
25 /*************************************************
27 *************************************************/
28 static VEHICLESENS_DATA_MASTER gstMotionHeading_g; // NOLINT(readability/nolint)
30 /****************************************************************************
31 @brief VehicleSensInitMotionHeadingG<BR>
32 Orientation information data master initialization process(NMEA information)
33 @outline Initialize the orientation information data master
38 *******************************************************************************/
39 void VehicleSensInitMotionHeadingG(void) {
40 SENSORMOTION_HEADINGINFO_DAT st_heading;
42 memset(&gstMotionHeading_g, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
44 /** Data ID setting */
45 gstMotionHeading_g.ul_did = VEHICLE_DID_MOTION_HEADING;
46 /** Data size setting */
47 gstMotionHeading_g.us_size = sizeof(SENSORMOTION_HEADINGINFO_DAT);
48 /** Data content setting */
49 memset(&st_heading, 0x00, sizeof(st_heading));
50 st_heading.getMethod = SENSOR_GET_METHOD_GPS;
51 st_heading.SyncCnt = 0x00;
52 st_heading.isEnable = SENSORMOTION_STATUS_DISABLE;
53 memcpy(&gstMotionHeading_g.uc_data[0], &st_heading, sizeof(st_heading));
56 /****************************************************************************
57 @brief VehicleSensSetMotionHeadingG<BR>
58 Compass Data Master SET Processing(NMEA information)
59 @outline Update the orientation information data master
60 @param[in] SENSORMOTION_HEADINGINFO_DAT* pst_heading : Bearing information
63 @retval VEHICLESENS_EQ : No data change
64 @retval VEHICLESENS_NEQ : Data change
65 *******************************************************************************/
66 u_int8 VehicleSensSetMotionHeadingG(const SENSORMOTION_HEADINGINFO_DAT *pst_heading) {
68 VEHICLESENS_DATA_MASTER *pst_master;
70 pst_master = &gstMotionHeading_g;
72 /** With the contents of the current data master,Compare received data */
73 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_heading,
74 sizeof(SENSORMOTION_HEADINGINFO_DAT));
76 /** Received data is set in the data master. */
77 pst_master->ul_did = VEHICLE_DID_MOTION_HEADING;
78 pst_master->us_size = sizeof(SENSORMOTION_HEADINGINFO_DAT);
79 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
80 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
81 memcpy(pst_master->uc_data, pst_heading, sizeof(SENSORMOTION_HEADINGINFO_DAT));
86 /****************************************************************************
87 @brief VehicleSensGetMotionHeadingG<BR>
88 Compass Data Master GET Processing(NMEA information)
89 @outline Provide an orientation information data master
91 @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
94 *******************************************************************************/
95 void VehicleSensGetMotionHeadingG(VEHICLESENS_DATA_MASTER *pst_data) {
96 const VEHICLESENS_DATA_MASTER *pst_master;
98 pst_master = &gstMotionHeading_g;
100 /* Store the data master in the specified destination. */
101 pst_data->ul_did = pst_master->ul_did;
102 pst_data->us_size = pst_master->us_size;
103 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
104 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */