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_SnsCounterExt_l.cpp
19 * System name :_CWORD107_
20 * Subsystem name :Vehicle sensor process
21 * Program name :Vehicle sensor data master(POSHAL_DID_SNS_COUNTER)
22 * Module configuration :VehicleSensInitSnsCounterl() Vehicle sensor SNS_COUNTER initialization function
23 * :VehicleSensSetSnsCounterl() Vehicle sensor SNS_COUNTER SET function
24 * :VehicleSensGetSnsCounterl() Vehicle sensor SNS_COUNTER GET function
25 ******************************************************************************/
27 #include <vehicle_service/positioning_base_library.h>
28 #include "VehicleSens_DataMaster.h"
30 /* Ignore->MISRA-C++:2008 Rule 2-7-2 */
31 #if CONFIG_SENSOR_EXT_VALID /* Initial Sensor Response */
32 /*************************************************/
34 /*************************************************/
35 static VEHICLESENS_DATA_MASTER_EXT gstSnsCounterExt_l; // NOLINT(readability/nolint)
37 /*******************************************************************************
38 * MODULE : VehicleSensInitSnsCounterExtl
39 * ABSTRACT : Vehicle sensor SNS_COUNTER initialization function
40 * FUNCTION : SNS_COUNTER data master initialization processing
44 ******************************************************************************/
45 void VehicleSensInitSnsCounterExtl(void) {
48 memset(&gstSnsCounterExt_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_EXT));
49 gstSnsCounterExt_l.ul_did = POSHAL_DID_SNS_COUNTER;
50 gstSnsCounterExt_l.us_size = VEHICLE_DSIZE_SNS_COUNTER_EXT_INIT;
51 pus = reinterpret_cast<u_int16 *>(gstSnsCounterExt_l.uc_data);
52 memset(reinterpret_cast<void*>(pus), VEHICLE_DINIT_SNS_COUNTER, VEHICLE_DSIZE_SNS_COUNTER_EXT);
54 /* Initializing Initial Delivery Internal Information */
55 memset(&gstPkgTempExt, 0x00, sizeof(VEHICLESENS_PKG_DELIVERY_TEMP_EXT));
58 /*******************************************************************************
59 * MODULE : VehicleSensSetSnsCounterExtl
60 * ABSTRACT : Vehicle sensor SNS_COUNTER SET function
61 * FUNCTION : Update the SNS_COUNTER data master
62 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
65 ******************************************************************************/
66 void VehicleSensSetSnsCounterExtl(const LSDRV_LSDATA *pst_data) { // LCOV_EXCL_START 8: dead code
67 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
72 /*******************************************************************************
73 * MODULE : VehicleSensSetSnsCounterExtlG
74 * ABSTRACT : Vehicle sensor SNS_COUNTER SET function
75 * FUNCTION : Update the SNS_COUNTER data master
76 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
79 ******************************************************************************/
80 void VehicleSensSetSnsCounterExtlG(const LSDRV_LSDATA_G *pst_data) {
81 VEHICLESENS_DATA_MASTER_EXT *pst_master;
84 pst_master = &gstSnsCounterExt_l;
86 /* Retrieve the location where the received one is stored */
87 us_start = gstPkgTempExt.start_point[SNSCounter];
89 /* Stored in data master(Order of reception)*/
90 if (us_start >= VEHICLE_DKEEP_MAX) {
91 /* Store the latest one at position 0 */
92 us_start = VEHICLE_DATA_POS_00;
93 /* If you are discarding old data,,Set a flag */
94 gstPkgTempExt.data_break = VEHICLE_SNS_BREAK;
96 pst_master->ul_did = pst_data->ul_did;
97 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
98 pst_master->uc_data[us_start] = pst_data->uc_data[0];
100 /* Update next storage start position and latest data storage position */
102 gstPkgTempExt.start_point[SNSCounter] = us_start;
104 /* Update data master size */
105 if (gstPkgTempExt.data_break == VEHICLE_SNS_BREAK) {
106 /* Make the size of all extended data masters */
107 pst_master->us_size = VEHICLE_DSIZE_SNS_COUNTER_EXT;
109 /* Add the size of one received data item */
110 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + sizeof(u_int8));
114 /*******************************************************************************
115 * MODULE : VehicleSensGetSnsCounterExtl
116 * ABSTRACT : Vehicle sensor SNS_COUNTER GET function
117 * FUNCTION : Provide the SNS_COUNTER data master
118 * ARGUMENT : *pst_data : Pointer to the data master acquisition destination
121 ******************************************************************************/
122 void VehicleSensGetSnsCounterExtl(VEHICLESENS_DATA_MASTER_EXT *pst_data) {
123 const VEHICLESENS_DATA_MASTER_EXT *pst_master;
124 uint16_t us_data_cnt = 0; // Number of data contained
125 uint16_t us_loop_cnt = 0; // 64 over index
127 /* Store the data master in the specified destination. */
128 pst_master = &gstSnsCounterExt_l;
129 pst_data->ul_did = pst_master->ul_did;
130 pst_data->us_size = pst_master->us_size;
131 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
133 /* Checking whether the number of stored entries is looped */
134 if (gstPkgTempExt.data_break == VEHICLE_SNS_BREAK) {
135 us_data_cnt = VEHICLE_DKEEP_MAX;
137 us_data_cnt = gstPkgTempExt.start_point[SNSCounter];
140 /* Acquire data from the newest data master */
141 for (uint16_t us_cnt = 0; us_cnt < us_data_cnt; us_cnt++) {
142 if (gstPkgTempExt.data_break == VEHICLE_SNS_BREAK) {
143 /* Get information before loop */
144 if (gstPkgTempExt.start_point[SNSCounter] + us_cnt < VEHICLE_DKEEP_MAX) {
145 pst_data->uc_data[us_cnt] = pst_master->uc_data[(gstPkgTempExt.start_point[SNSCounter] + us_cnt)];
147 pst_data->uc_data[us_cnt] = pst_master->uc_data[us_loop_cnt];
151 pst_data->uc_data[us_cnt] = pst_master->uc_data[us_cnt];