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