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_GsnsXFst_l.cpp
21 * Vehicle sensor data master(POSHAL_DID_GSNS_X_FST)
24 #include <vehicle_service/positioning_base_library.h>
25 #include "VehicleSens_DataMaster.h"
27 /*************************************************/
29 /*************************************************/
30 static VEHICLESENS_DATA_MASTER_FST g_st_gsnsx_fst_l; // NOLINT(readability/nolint)
34 * Vehicle sensor GSNS_X initialization function
36 * GSNS_X data master initialization processing
38 void VehicleSensInitGsnsXFstl(void) {
39 memset(&g_st_gsnsx_fst_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_FST));
40 g_st_gsnsx_fst_l.ul_did = POSHAL_DID_GSNS_X_FST;
41 g_st_gsnsx_fst_l.us_size = VEHICLE_DSIZE_GSNS_X_EXT_INIT;
42 g_st_gsnsx_fst_l.uc_rcvflag = VEHICLE_RCVFLAG_OFF;
43 g_st_gsnsx_fst_l.partition_flg = 0;
48 * Vehicle sensor GSNS_X SET function
50 * Update the GSNS_X data master
52 * @param[in] *pst_data : Pointer to the message data received by the direct line
54 * @return VEHICLESENS_EQ No data change<br>
55 * VEHICLESENS_NEQ Data change
57 u_int8 VehicleSensSetGsnsXFstG(const LSDRV_LSDATA_FST_GSENSOR_X *pst_data) {
58 static u_int8 uc_ret = VEHICLESENS_EQ;
59 VEHICLESENS_DATA_MASTER_FST *pst_master;
61 u_int8 partition_max; /* Total number of partitions */
62 u_int8 partition_num; /* Data number */
64 pst_master = &g_st_gsnsx_fst_l;
66 partition_max = pst_data->uc_partition_max;
67 partition_num = pst_data->uc_partition_num;
69 if (partition_max == 1) {
70 /* Compare data master and received data */
71 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
73 /* Received data is set in the data master. */
74 pst_master->ul_did = pst_data->ul_did;
75 pst_master->us_size = pst_data->uc_size;
76 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
77 pst_master->partition_flg = 0;
78 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
79 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
80 } else if (partition_max == 2) {
81 if (partition_num == 1) {
82 /* Compare data master and received data */
83 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
85 /* Received data is set in the data master. */
86 pst_master->ul_did = pst_data->ul_did;
87 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
88 pst_master->partition_flg = 1;
89 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
90 } else if (partition_num == 2) {
91 /* Compare data master and received data */
92 if (uc_ret == VEHICLESENS_EQ) {
93 uc_ret = VehicleSensmemcmp(&pst_master->uc_data[VEHICLE_DSIZE_GSNSX_FST],
94 pst_data->uc_data, pst_data->uc_size);
97 /* Received data is set in the data master. */
98 pst_master->ul_did = pst_data->ul_did;
99 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
100 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
101 pst_master->partition_flg = 1;
102 memcpy(&pst_master->uc_data[VEHICLE_DSIZE_GSNSX_FST], pst_data->uc_data, pst_data->uc_size);
110 * Vehicle sensor GSNS_X GET function
112 * Provide the GSNS_X data master
114 * @param[in] Pointer to the data master acquisition destination
116 void VehicleSensGetGsnsXFstl(VEHICLESENS_DATA_MASTER_FST *pst_data) {
117 const VEHICLESENS_DATA_MASTER_FST *pst_master;
119 pst_master = &g_st_gsnsx_fst_l;
121 /* Store the data master in the specified destination. */
122 pst_data->ul_did = pst_master->ul_did;
123 pst_data->us_size = pst_master->us_size;
124 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
125 pst_data->partition_flg = pst_master->partition_flg;
126 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);