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 name :VehicleSens_Did_SpeedPulseFst_l.cpp
19 * System name :_CWORD107_
20 * Subsystem name :Vehicle sensor process
21 * Program name :Vehicle sensor data master(POSHAL_DID_SPEED_PULSE_FST)
22 * Module configuration :VehicleSensInitSpeedPulseFstl() Vehicle sensor SPEED_PULSE initialization function
23 * :VehicleSensSetSpeedPulseFstl() Vehicle Sensor SPEED_PULSE SET Function
24 * :VehicleSensSetSpeedPulseFstG() Vehicle Sensor SPEED_PULSE SET Function
25 * :VehicleSensGetSpeedPulseFstl() Vehicle Sensor SPEED_PULSE GET Function
26 ******************************************************************************/
28 #include <vehicle_service/positioning_base_library.h>
29 #include "VehicleSens_DataMaster.h"
31 #if CONFIG_SENSOR_EXT_VALID /* Initial Sensor Support */
32 /*************************************************/
34 /*************************************************/
35 static VEHICLESENS_DATA_MASTER_FST gstSpeedPulseFst_l; // NOLINT(readability/nolint)
37 /*******************************************************************************
38 * MODULE : VehicleSensInitSpeedPulseFstl
39 * ABSTRACT : Vehicle sensor SPEED_PULSE initialization function
40 * FUNCTION : SPEED_PULSE data master initialization processing
44 ******************************************************************************/
45 void VehicleSensInitSpeedPulseFstl(void) {
48 memset(&gstSpeedPulseFst_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_FST));
49 gstSpeedPulseFst_l.ul_did = POSHAL_DID_SPEED_PULSE_FST;
50 gstSpeedPulseFst_l.us_size = 0;
51 gstSpeedPulseFst_l.partition_flg = 0;
52 pus = reinterpret_cast<u_int16 *>(gstSpeedPulseFst_l.uc_data);
53 memset(reinterpret_cast<void*>(pus), VEHICLE_DINIT_SPEED_PULSE, VEHICLE_DSIZE_SPEED_PULSE_FST);
56 /*******************************************************************************
57 * MODULE : VehicleSensSetSpeedPulseFstl
58 * ABSTRACT : Vehicle Sensor SPEED_PULSE SET Function
59 * FUNCTION : Update the SPEED_PULSE data master
60 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
62 * RETURN : VEHICLESENS_EQ : No data change
63 * VEHICLESENS_NEQ : Data change
64 ******************************************************************************/
65 u_int8 VehicleSensSetSpeedPulseFstl(const LSDRV_LSDATA_FST *pst_data) {
67 VEHICLESENS_DATA_MASTER_FST *pst_master;
69 pst_master = &gstSpeedPulseFst_l;
71 /* Compare data master and received data */
72 /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
73 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
75 /* Received data is set in the data master. */
76 pst_master->ul_did = pst_data->ul_did;
77 pst_master->us_size = pst_data->uc_size;
78 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
79 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
80 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
85 /*******************************************************************************
86 * MODULE : VehicleSensSetSpeedPulseFstG
87 * ABSTRACT : Vehicle Sensor SPEED_PULSE SET Function
88 * FUNCTION : Update the SPEED_PULSE data master
89 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
91 * RETURN : VEHICLESENS_EQ : No data change
92 * VEHICLESENS_NEQ : Data change
93 ******************************************************************************/
94 u_int8 VehicleSensSetSpeedPulseFstG(const LSDRV_LSDATA_FST_SPEED *pst_data) {
95 static u_int8 uc_ret = VEHICLESENS_EQ;
96 VEHICLESENS_DATA_MASTER_FST *pst_master;
98 u_int8 partition_max; /* Total number of partitions */
99 u_int8 partition_num; /* Data number */
101 pst_master = &gstSpeedPulseFst_l;
103 partition_max = pst_data->uc_partition_max;
104 partition_num = pst_data->uc_partition_num;
106 if (partition_max == 1) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
107 /* Compare data master and received data */
108 /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
109 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
111 /* Received data is set in the data master. */
112 pst_master->ul_did = pst_data->ul_did;
113 pst_master->us_size = pst_data->uc_size;
114 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
115 pst_master->partition_flg = 0;
116 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
117 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
118 } else if (partition_max == 2) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
119 if (partition_num == 1) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
120 /* Compare data master and received data */
121 /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
122 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
124 /* Received data is set in the data master. */
125 pst_master->ul_did = pst_data->ul_did;
126 /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
127 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
128 pst_master->partition_flg = 1;
129 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
130 } else if (partition_num == 2) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
131 /* Compare data master and received data */
132 if (uc_ret == VEHICLESENS_EQ) {
133 uc_ret = VehicleSensmemcmp(&pst_master->uc_data[VEHICLE_DSIZE_SPEED_PULSE_FST],
134 pst_data->uc_data, pst_data->uc_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
137 /* Received data is set in the data master. */
138 pst_master->ul_did = pst_data->ul_did;
139 /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
140 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
141 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
142 pst_master->partition_flg = 1;
143 memcpy(&pst_master->uc_data[VEHICLE_DSIZE_SPEED_PULSE_FST],
144 pst_data->uc_data, pst_data->uc_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
151 /*******************************************************************************
152 * MODULE : VehicleSensGetSpeedPulseFstl
153 * ABSTRACT : Vehicle Sensor SPEED_PULSE GET Function
154 * FUNCTION : Provide the SPEED_PULSE data master
155 * ARGUMENT : *pst_data : Pointer to the data master acquisition destination
158 ******************************************************************************/
159 void VehicleSensGetSpeedPulseFstl(VEHICLESENS_DATA_MASTER_FST *pst_data) {
160 const VEHICLESENS_DATA_MASTER_FST *pst_master;
162 pst_master = &gstSpeedPulseFst_l;
164 /* Store the data master in the specified destination. */
165 pst_data->ul_did = pst_master->ul_did;
166 pst_data->us_size = pst_master->us_size;
167 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
168 pst_data->partition_flg = pst_master->partition_flg;
169 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size); /* Ignore->MISRA-C++:2008 Rule 5-0-5 */