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_MotionSpeed_i.cpp
21 * Vehicle Speed Information Data Master Management(Internal calculation information)
24 /*---------------------------------------------------------------------------------*
26 *---------------------------------------------------------------------------------*/
27 #include <vehicle_service/positioning_base_library.h>
28 #include "VehicleSens_DataMaster.h"
29 #include "CommonDefine.h"
31 /*---------------------------------------------------------------------------------*
33 *---------------------------------------------------------------------------------*/
34 static VEHICLESENS_DATA_MASTER gstMotionSpeed_i; // NOLINT(readability/nolint)
36 /*---------------------------------------------------------------------------------*
38 *---------------------------------------------------------------------------------*/
41 * Speed information data master initialization process(Internal calculation information)
43 void VehicleSensInitMotionSpeedI(void) {
44 SENSORMOTION_SPEEDINFO_DAT st_speed;
46 memset(&gstMotionSpeed_i, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
48 /** Data ID setting */
49 gstMotionSpeed_i.ul_did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
50 /** Data size setting */
51 gstMotionSpeed_i.us_size = sizeof(SENSORMOTION_SPEEDINFO_DAT);
52 /** Data content setting */
53 memset(&st_speed, 0x00, sizeof(st_speed));
54 st_speed.getMethod = SENSOR_GET_METHOD_POS;
55 st_speed.SyncCnt = 0x00;
56 st_speed.isEnable = SENSORMOTION_STATUS_DISABLE;
57 memcpy(&gstMotionSpeed_i.uc_data[0], &st_speed, sizeof(st_speed));
62 * Rate information data master SET process(Internal calculation information)
64 * @param[in] *pst_speed - SENSORMOTION_SPEEDINFO_DAT Pointer to vehicle speed information
66 * @return VEHICLESENS_EQ : No data change<br>
67 * VEHICLESENS_NEQ : Data change
69 u_int8 VehicleSensSetMotionSpeedI(const SENSORMOTION_SPEEDINFO_DAT *pst_speed) {
71 VEHICLESENS_DATA_MASTER *pst_master;
73 pst_master = &gstMotionSpeed_i;
75 /** With the contents of the current data master,Compare received data */
76 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
78 /** Received data is set in the data master. */
79 pst_master->ul_did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
80 pst_master->us_size = sizeof(SENSORMOTION_SPEEDINFO_DAT);
81 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
82 memcpy(pst_master->uc_data, pst_speed, sizeof(SENSORMOTION_SPEEDINFO_DAT));
89 * Speed information data master GET processing(Internal calculation information)
91 * @param[out] *pst_speed - VEHICLESENS_DATA_MASTER Pointer to the data master acquisition destination
93 void VehicleSensGetMotionSpeedI(VEHICLESENS_DATA_MASTER *pst_data) {
94 const VEHICLESENS_DATA_MASTER *pst_master;
96 pst_master = &gstMotionSpeed_i;
98 /* Store the data master in the specified destination. */
99 pst_data->ul_did = pst_master->ul_did;
100 pst_data->us_size = pst_master->us_size;
101 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
102 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);