Re-organized sub-directory by category
[staging/basesystem.git] / service / vehicle / positioning / server / src / Sensor / VehicleSens_Did_GpsAntenna_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_GpsAntenna_l.cpp
19  *  System name    :_CWORD107_
20  *  Subsystem name  :Vehicle sensor process
21  *  Program name  :Vehicle sensor data master(VEHICLE_DID_GPS_ANTENNA)
22  *  Module configuration  :VehicleSensInitGpsAntennal()  Vehicle sensor GPS_ANTENNA initialization function
23  *                  :VehicleSensSetGpsAntennal()    Vehicle Sensor GPS_ANTENNA SET Function
24  *                  :VehicleSensGetGpsAntennal()    Vehicle Sensor GPS_ANTENNA 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  gstGpsAntenna_l;    // NOLINT(readability/nolint)
34
35 /*******************************************************************************
36 * MODULE    : VehicleSensInitGpsAntennal
37 * ABSTRACT  : Vehicle sensor GPS_ANTENNA initialization function
38 * FUNCTION  : GPS_ANTENNA data master initialization processing
39 * ARGUMENT  : void
40 * NOTE      :
41 * RETURN    : void
42 ******************************************************************************/
43 void VehicleSensInitGpsAntennal(void) {
44     memset(&gstGpsAntenna_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
45     gstGpsAntenna_l.ul_did    = POSHAL_DID_GPS_ANTENNA;
46     gstGpsAntenna_l.us_size    = VEHICLE_DSIZE_GPS_ANTENNA;
47     gstGpsAntenna_l.uc_data[0]  = VEHICLE_DINIT_GPS_ANTENNA;
48 }
49
50 /*******************************************************************************
51 * MODULE    : VehicleSensSetGpsAntennal
52 * ABSTRACT  : Vehicle Sensor GPS_ANTENNA SET Function
53 * FUNCTION  : Update the GPS_ANTENNA data master
54 * ARGUMENT  : *pst_data : Pointer to the message data received by the direct line
55 * NOTE      :
56 * RETURN    : VEHICLESENS_EQ  : No data change
57 *             VEHICLESENS_NEQ  : Data change
58 ******************************************************************************/
59 u_int8 VehicleSensSetGpsAntennal(const LSDRV_LSDATA *pst_data) {
60     u_int8 uc_ret;
61     VEHICLESENS_DATA_MASTER *pst_master;
62
63     pst_master = &gstGpsAntenna_l;
64
65     /* Compare data master and received data */
66     /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
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;  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
72     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
73     memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
74     memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
75
76     return(uc_ret);
77 }
78
79 /*******************************************************************************
80 * MODULE    : VehicleSensGetGpsAntennal
81 * ABSTRACT  : Vehicle Sensor GPS_ANTENNA GET Function
82 * FUNCTION  : Provide the GPS_ANTENNA data master
83 * ARGUMENT  : *pst_data : Pointer to the data master acquisition destination
84 * NOTE      :
85 * RETURN    : void
86 ******************************************************************************/
87 void VehicleSensGetGpsAntennal(VEHICLESENS_DATA_MASTER *pst_data) {
88     const VEHICLESENS_DATA_MASTER *pst_master;
89
90     pst_master = &gstGpsAntenna_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);  /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
97 }