common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_GyroXFst_l.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /*******************************************************************************
18  *  File name    :VehicleSens_Did_GyroXFst_l.cpp
19  *  System name    :Polaris
20  *  Subsystem name  :Vehicle sensor process
21  *  Program name  :Vehicle sensor data master(POSHAL_DID_GYRO_X_FST)
22  *  Module configuration  :VehicleSensInitGyroXFstl()    Vehicle sensor GYRO (initial sensor) initialization functions
23  *                  :VehicleSensSetGyroXFstl()    Vehicle sensor GYRO (initial sensor) SET-function
24  *                  :VehicleSensSetGyroXFstG()    Vehicle sensor GYRO (initial sensor) SET-function
25  *                  :VehicleSensGetGyroXFstl()    Vehicle sensor GYRO (initial sensor) GET-function
26  ******************************************************************************/
27
28 #include <vehicle_service/positioning_base_library.h>
29 #include "VehicleSens_DataMaster.h"
30
31 #if CONFIG_SENSOR_EXT_VALID        /* Initial Sensor Support */
32 /*************************************************/
33 /*           Global variable                      */
34 /*************************************************/
35 static  VEHICLESENS_DATA_MASTER_FST  gstGyroXFst_l;    // NOLINT(readability/nolint)
36
37 /*******************************************************************************
38 * MODULE    : VehicleSensInitGyroXFstl
39 * ABSTRACT  : Vehicle Sensor GYRO_X Initialization Functions
40 * FUNCTION  : GYRO data master initialization process
41 * ARGUMENT  : void
42 * NOTE      :
43 * RETURN    : void
44 ******************************************************************************/
45 void VehicleSensInitGyroXFstl(void) {
46     u_int16  *pus;
47
48     memset(&gstGyroXFst_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_FST));
49     gstGyroXFst_l.ul_did        = POSHAL_DID_GYRO_X_FST;
50     gstGyroXFst_l.us_size        = 0;
51     gstGyroXFst_l.partition_flg  = 0;
52
53     pus    = reinterpret_cast<u_int16 *>(gstGyroXFst_l.uc_data);
54     memset(reinterpret_cast<void*>(pus), VEHICLE_DINIT_GYRO_X, VEHICLE_DSIZE_GYRO_X_FST);
55 }
56
57 /*******************************************************************************
58 * MODULE    : VehicleSensSetGyroXFstl
59 * ABSTRACT  : Vehicle Sensor GYRO_X SET Functions
60 * FUNCTION  : Update the GYRO data master
61 * ARGUMENT  : *pst_data : Pointer to the message data received by the direct line
62 * NOTE      :
63 * RETURN    : VEHICLESENS_EQ  : No data change
64 *             VEHICLESENS_NEQ  : Data change
65 ******************************************************************************/
66 u_int8 VehicleSensSetGyroXFstl(const LSDRV_LSDATA_FST *pst_data) {  // LCOV_EXCL_START 8: dead code.
67     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
68     u_int8 uc_ret;
69     VEHICLESENS_DATA_MASTER_FST *pst_master;
70
71     pst_master = &gstGyroXFst_l;
72
73     /* Compare data master and received data */
74     uc_ret = VehicleSensmemcmp(pst_master->uc_data,
75             pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
76
77     /* Received data is set in the data master. */
78     pst_master->ul_did      = pst_data->ul_did;
79     pst_master->us_size      = pst_data->uc_size;
80     pst_master->partition_flg  = 0;
81     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
82     memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
83     memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
84
85     return(uc_ret);
86 }
87 // LCOV_EXCL_STOP
88
89 /*******************************************************************************
90 * MODULE    : VehicleSensSetGyroXFstG
91 * ABSTRACT  : Vehicle Sensor GYRO SET Functions
92 * FUNCTION  : Update the GYRO data master
93 * ARGUMENT  : *pst_data : Pointer to the message data received by the direct line
94 * NOTE      :
95 * RETURN    : VEHICLESENS_EQ  : No data change
96 *             VEHICLESENS_NEQ  : Data change
97 ******************************************************************************/
98 u_int8 VehicleSensSetGyroXFstG(const LSDRV_LSDATA_FST_GYRO_X *pst_data) {
99     static u_int8   uc_ret  = VEHICLESENS_EQ;
100     VEHICLESENS_DATA_MASTER_FST *pst_master;
101
102     u_int8  partition_max;    /* Total number of partitions            */
103     u_int8  partition_num;    /* Data number          */
104
105     partition_max = pst_data->uc_partition_max;
106     partition_num = pst_data->uc_partition_num;
107
108     pst_master = &gstGyroXFst_l;
109
110     if (partition_max == 1) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
111         /* Compare data master and received data */
112         uc_ret = VehicleSensmemcmp(pst_master->uc_data,
113                 pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
114
115         /* Received data is set in the data master. */
116         pst_master->ul_did      = pst_data->ul_did;
117         pst_master->us_size      = pst_data->uc_size;
118         pst_master->uc_rcvflag    = VEHICLE_RCVFLAG_ON;
119         pst_master->partition_flg  = 0;
120         memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
121         memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
122     } else if (partition_max == 2) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
123         if (partition_num == 1) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
124             /* Compare data master and received data */
125             /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
126             uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
127
128             /* Received data is set in the data master. */
129             pst_master->ul_did      = pst_data->ul_did;
130             /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
131             pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
132             pst_master->partition_flg  = 1;
133             memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
134         } else if (partition_num == 2) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
135             /* Compare data master and received data */
136             if (uc_ret == VEHICLESENS_EQ) {
137                 uc_ret = VehicleSensmemcmp(&pst_master->uc_data[VEHICLE_DSIZE_GYRO_X_FST],
138                                             pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
139             }
140
141             /* Received data is set in the data master. */
142             pst_master->ul_did      = pst_data->ul_did;
143             /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
144             pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
145             pst_master->uc_rcvflag    = VEHICLE_RCVFLAG_ON;
146             pst_master->partition_flg  = 1;
147             /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
148             memcpy(&pst_master->uc_data[VEHICLE_DSIZE_GYRO_X_FST], pst_data->uc_data, pst_data->uc_size);
149         } else {}
150     } else {}
151
152     return(uc_ret);
153 }
154
155 /*******************************************************************************
156 * MODULE    : VehicleSensGetGyroXFstl
157 * ABSTRACT  : Vehicle Sensor GYRO GET Functions
158 * FUNCTION  : Provide a GYRO data master
159 * ARGUMENT  : *pst_data : Pointer to the data master acquisition destination
160 * NOTE      :
161 * RETURN    : void
162 ******************************************************************************/
163 void VehicleSensGetGyroXFstl(VEHICLESENS_DATA_MASTER_FST *pst_data) {
164     const VEHICLESENS_DATA_MASTER_FST *pst_master;
165
166     pst_master = &gstGyroXFst_l;
167
168     /* Store the data master in the specified destination. */
169     pst_data->ul_did        = pst_master->ul_did;
170     pst_data->us_size        = pst_master->us_size;
171     pst_data->uc_rcvflag      = pst_master->uc_rcvflag;
172     pst_data->partition_flg  = pst_master->partition_flg;
173     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
174 }
175
176 #endif