Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_GsnsZ_l.cpp
1 /*
2  * @copyright Copyright (c) 2019-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_GsnsZ_l.cpp
19  *  Subsystem name  :Vehicle sensor process
20  *  Program name  :Vehicle sensor data master(POSHAL_DID_GSNS_Z)
21  *  Module configuration  :VehicleSensInitGsnsZl()    Vehicle sensor GSNS_Z initialization function
22  *                  :VehicleSensSetGsnsZlG()  Vehicle sensor GSNS_Z SET function
23  *                  :VehicleSensGetGsnsZl()    Vehicle sensor GSNS_Z GET function
24  ******************************************************************************/
25
26 #include "VehicleSens_DataMaster.h"
27
28 /*************************************************/
29 /*           Global variable                     */
30 /*************************************************/
31 static  VEHICLESENS_DATA_MASTER  gstGsnsZ_l;    // NOLINT(readability/nolint)
32
33 /*******************************************************************************
34 * MODULE    : VehicleSensInitGsnsZl
35 * ABSTRACT  : Vehicle sensor GSNS_Z initialization function
36 * FUNCTION  : GSNS_Z data master initialization processing
37 * ARGUMENT  : void
38 * NOTE      :
39 * RETURN    : void
40 ******************************************************************************/
41 void VehicleSensInitGsnsZl(void) {
42     memset(&gstGsnsZ_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
43     gstGsnsZ_l.ul_did     = POSHAL_DID_GSNS_Z;
44     gstGsnsZ_l.us_size    = VEHICLE_DSIZE_GSNS_Z;
45     gstGsnsZ_l.uc_rcvflag = VEHICLE_RCVFLAG_OFF;
46 }
47
48 /**
49  * @brief
50  *   Vehicle sensor GSNS_Z SET function
51  *
52  *   Update the GSNS_Z data master
53  *
54  * @param[in]  *pst_data : Pointer to the message data received by the direct line
55  *
56  * @return  VEHICLESENS_EQ  No data change<br>
57  *      VEHICLESENS_NEQ Data change
58  *
59  */
60 u_int8 VehicleSensSetGsnsZlG(const LSDRV_LSDATA_G *pst_data) {
61     u_int8 uc_ret;
62     VEHICLESENS_DATA_MASTER *pst_master;
63
64     pst_master = &gstGsnsZ_l;
65
66     /* Compare data master and received data */
67     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
68
69     /* Received data is set in the data master. */
70     pst_master->ul_did     = pst_data->ul_did;
71     pst_master->us_size    = pst_data->uc_size;
72     pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
73     (void)memcpy(reinterpret_cast<void *>(pst_master->uc_data),
74         (const void *)(pst_data->uc_data), (size_t)(pst_data->uc_size));
75
76     return(uc_ret);
77 }
78
79 /*******************************************************************************
80 * MODULE    : VehicleSensGetGsnsZl
81 * ABSTRACT  : Vehicle sensor GSNS_Z GET function
82 * FUNCTION  : Provide the GSNS_Z data master
83 * ARGUMENT  : *pst_data : Pointer to the data master acquisition destination
84 * NOTE      :
85 * RETURN    : void
86 ******************************************************************************/
87 void VehicleSensGetGsnsZl(VEHICLESENS_DATA_MASTER *pst_data) {
88     const VEHICLESENS_DATA_MASTER *pst_master;
89
90     pst_master = &gstGsnsZ_l;
91
92     /* Store the data master in the specified destination. */
93     pst_data->ul_did     = pst_master->ul_did;
94     pst_data->us_size    = pst_master->us_size;
95     pst_data->uc_rcvflag = pst_master->uc_rcvflag;
96     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
97 }