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_LocationLonLat_n.cpp
22 /*---------------------------------------------------------------------------------*
24 *---------------------------------------------------------------------------------*/
25 #include <vehicle_service/positioning_base_library.h>
26 #include "VehicleSens_DataMaster.h"
27 #include "SensorLocation_API.h"
28 #include "CommonDefine.h"
30 /*---------------------------------------------------------------------------------*
32 *---------------------------------------------------------------------------------*/
33 static VEHICLESENS_DATA_MASTER gstLocationLonLat_n; // NOLINT(readability/nolint)
37 * Latitude and longitudeInitialization of information data master(NAVI information)
39 * Latitude and longitudeInitialize the information data master
46 void VehicleSensInitLocationLonLatN(void) {
47 SENSORLOCATION_LONLATINFO_DAT st_lonlat;
49 memset(&gstLocationLonLat_n, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
51 /** Data ID setting */
52 gstLocationLonLat_n.ul_did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
54 /** Data size setting */
55 gstLocationLonLat_n.us_size = sizeof(SENSORLOCATION_LONLATINFO_DAT);
57 /** Data content setting */
58 memset(&st_lonlat, 0x00, sizeof(st_lonlat));
59 st_lonlat.getMethod = SENSOR_GET_METHOD_NAVI;
60 st_lonlat.SyncCnt = 0x00;
61 st_lonlat.isEnable = SENSORLOCATION_STATUS_DISABLE;
62 st_lonlat.posSts = 0x00;
63 st_lonlat.posAcc = 0x00;
64 st_lonlat.Longitude = 0x00;
65 st_lonlat.Latitude = 0x00;
66 memcpy(&gstLocationLonLat_n.uc_data[0], &st_lonlat, sizeof(st_lonlat));
73 * Latitude and longitudeInformation data master SET process(NAVI information)
75 * Latitude and longitudeUpdate the information data master
77 * @param[in] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
80 * @retval VEHICLESENS_EQ : No data change
81 * @retval VEHICLESENS_NEQ : Data change
83 u_int8 VehicleSensSetLocationLonLatN(const SENSORLOCATION_LONLATINFO_DAT *pst_lonlat) {
85 VEHICLESENS_DATA_MASTER *pst_master;
87 pst_master = &gstLocationLonLat_n;
89 /** With the contents of the current data master,Compare received data */
90 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
92 /** Received data is set in the data master. */
93 pst_master->ul_did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
94 pst_master->us_size = sizeof(SENSORLOCATION_LONLATINFO_DAT);
95 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
96 memcpy(pst_master->uc_data, pst_lonlat, sizeof(SENSORLOCATION_LONLATINFO_DAT));
103 * Latitude and longitudeInformation Data Master GET Processing(NAVI information)
105 * Latitude and longitudeProvide an information data master
108 * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
112 void VehicleSensGetLocationLonLatN(VEHICLESENS_DATA_MASTER *pst_data) {
113 const VEHICLESENS_DATA_MASTER *pst_master;
115 pst_master = &gstLocationLonLat_n;
117 /** Store the data master in the specified destination. */
118 pst_data->ul_did = pst_master->ul_did;
119 pst_data->us_size = pst_master->us_size;
120 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
121 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
128 * Latitude and longitudeInformation Data Master GET Processing(NAVI information)
130 * Latitude and longitudeProvide an information data master(Unit:10^-7th degree)
132 * @param[out] VEHICLESENS_DATA_MASTER *pst_data : Pointer to the data master acquisition destination
134 void VehicleSensGetLocationLonLatnUnitCnv(VEHICLESENS_DATA_MASTER *pst_data) {
135 const VEHICLESENS_DATA_MASTER *pst_master;
136 SENSORLOCATION_LONLATINFO_DAT st_lonlat;
141 pst_master = &gstLocationLonLat_n;
143 /* Perform unit conversion[1/128Second] -> [10^-7 degree] */
144 memcpy(&st_lonlat, pst_master->uc_data, sizeof(st_lonlat));
147 l_lon = st_lonlat.Longitude;
148 ll_tmp = (int64_t)l_lon * 10000000;
149 st_lonlat.Longitude = (int32_t)(ll_tmp / (128 * 60 * 60));
152 l_lat = st_lonlat.Latitude;
153 ll_tmp = (int64_t)l_lat * 10000000;
154 st_lonlat.Latitude = (int32_t)(ll_tmp / (128 * 60 * 60));
156 /** Store the data master in the specified destination. */
157 pst_data->ul_did = pst_master->ul_did;
158 pst_data->us_size = pst_master->us_size;
159 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
160 memcpy(pst_data->uc_data, &st_lonlat, sizeof(st_lonlat));