Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / server / src / Sensor / VehicleSens_Did_Nav_SvInfo_g.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      VehicleSens_Did_Nav_SvInfo_g.cpp
19 @detail      Master vehicle sensor data(VEHICLE_DID_GPS_UBLOX_NAV_SVINFO)
20 *****************************************************************************/
21
22 #include <vehicle_service/positioning_base_library.h>
23 #include "VehicleSens_DataMaster.h"
24
25 /*************************************************/
26 /*           Global variable                      */
27 /*************************************************/
28 static  VEHICLESENS_DATA_MASTER_GPS_UBLOX_FORMAT  gstNavSvInfo_g;    // NOLINT(readability/nolint)
29
30 /***************************************************************************
31 @brief      NAV-SVINFO vehicle sensor initialization function
32 @outline    NAV-SVINFO initialization process data master
33 @type      Completion return type
34 @param[in]    none
35 @threshold    none
36 @return      void
37 @retval      none
38 @trace
39 *****************************************************************************/
40 void VehicleSensInitNavSvInfoG(void) {
41     memset(&gstNavSvInfo_g, 0x00, sizeof(VEHICLESENS_DATA_MASTER_GPS_UBLOX_FORMAT));
42     gstNavSvInfo_g.ul_did    = VEHICLE_DID_GPS_UBLOX_NAV_SVINFO;
43     /* Initially, the maximum storage size is set.(Common header size(8) + NAV-SVINFO fixed-data-size(8) +
44     *(Maximum number of channels(16) + Size of single channel data(12))) */
45     gstNavSvInfo_g.us_size    =  (VEHICLE_DSIZE_GPS_UBLOX_HEADER_SIZE + VEHICLE_DSIZE_GPS_UBLOX_NAV_SVINFO) +
46                                     (VEHICLE_DSIZE_GPS_UBLOX_NAV_SVINFO_CH_MAX * \
47                                         VEHICLE_DSIZE_GPS_UBLOX_NAV_SVINFO_ALONE_MAX);
48     gstNavSvInfo_g.uc_data[0]  = VEHICLE_DINIT_GPS_UBLOX_NAV_SVINFO;
49 }
50
51 /***************************************************************************
52 @brief      NAV-SVINFO SET vehicle sensor function
53 @outline    To update the master data NAV-SVINFO.
54 @type      Completion return type
55 @param[in]    SENSOR_MSG_GPSDATA_DAT *pst_data  :  The pointer to GPS incoming message data
56 @threshold    none
57 @return      u_int8
58 @retval      VEHICLESENS_EQ  :   No data changes
59 @retval      VEHICLESENS_NEQ  :   With data changes
60 @trace
61 *****************************************************************************/
62 u_int8 VehicleSensSetNavSvInfoG(const SENSOR_MSG_GPSDATA_DAT *pst_data) {  // LCOV_EXCL_START 8: dead code
63     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
64     u_int8 uc_ret;
65     VEHICLESENS_DATA_MASTER_GPS_UBLOX_FORMAT *pst_master;
66
67     pst_master = &gstNavSvInfo_g;
68
69     /** Compare data master and received data */
70     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->us_size);
71
72     /** Received data is set in the data master. */
73     pst_master->ul_did    = pst_data->ul_did;
74     pst_master->us_size    = pst_data->us_size;
75     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
76     pst_master->uc_sensor_cnt  = pst_data->uc_sns_cnt;
77     pst_master->uc_gpscnt_flag  = pst_data->uc_gps_cnt_flag;
78
79     memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->us_size);
80
81     return(uc_ret);
82 }
83
84 /***************************************************************************
85 @brief      Vehicle sensor function NAV-SVINFO GET
86 @outline    Master Data provides the NAV-SVINFO
87 @type      Completion return type
88 @param[in]    SENSOR_MSG_GPSDATA_DAT *pst_data  :  Where to get a pointer to the data master
89 @threshold    none
90 @return      void
91 @retval      none
92 @trace
93 *****************************************************************************/
94 void VehicleSensGetNavSvInfoG(SENSOR_MSG_GPSDATA_DAT *pst_data) {
95     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
96     const VEHICLESENS_DATA_MASTER_GPS_UBLOX_FORMAT *pst_master;
97
98     pst_master = &gstNavSvInfo_g;
99
100     /** Store the data master in the specified destination. */
101     pst_data->ul_did      = pst_master->ul_did;
102     pst_data->us_size      = pst_master->us_size;
103     pst_data->uc_rcv_flag    = pst_master->uc_rcvflag;
104     pst_data->uc_sns_cnt    = pst_master->uc_sensor_cnt;
105     pst_data->uc_gps_cnt_flag  = pst_master->uc_gpscnt_flag;
106     memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);
107 }
108 // LCOV_EXCL_STOP