2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /*******************************************************************************
18 * File name :DeadReckoning_DeliveryCtrl.cpp
20 * Subsystem name :Vehicle sensor process
21 * Program name :Vehicle Sensor Destination Management(
22 * Module configuration DeadReckoningInitDeliveryCtrlTbl() Vehicle sensor delivery destination management table initialization function
23 * DeadReckoningInitDeliveryCtrlTblMng() Vehicle sensor delivery destination management table management area initialization function
24 * DeadReckoningEntryDeliveryCtrl() Vehicle sensor delivery destination management registration function
25 * :DeadReckoningAddDeliveryCtrlTbl() Vehicle sensor delivery destination management table addition function
26 * :DeadReckoningUpdateDeliveryCtrlTbl() Vehicle sensor delivery destination management table update function
27 * :DeadReckoning_DeliveryEntry_Delete() Vehicle sensor delivery destination management table deletion function
28 * :DeadReckoningAddDeliveryCtrlTblMng() Vehicle sensor delivery destination management table management addition function
29 * :DeadReckoningUpdateDeliveryCtrlTblMng() Vehicle sensor delivery destination management table management update function
30 * :DeadReckoning_DeleteDeliveryCtrlTblMng_Touch() Vehicle sensor delivery destination management table management deletion (touch panel) function
31 * DeadReckoningMakeDeliveryPnoTbl() Vehicle Sensor Destination PNO Table Creation Function
32 * :DeadReckoningAddPnoTbl() Vehicle Sensor Destination PNO Table Addition Function
33 * :DeadReckoningDeliveryProc() Vehicle Sensor Data Delivery Process
34 ******************************************************************************/
36 #include <vehicle_service/positioning_base_library.h>
37 #include "DeadReckoning_DeliveryCtrl.h"
38 #include "Vehicle_API.h"
39 #include "Vehicle_API_Dummy.h"
40 #include "Dead_Reckoning_Local_Api.h"
42 /*************************************************/
44 /*************************************************/
45 static DEADRECKONING_DELIVERY_CTRL_TBL g_delivery_dr_ctrltbl;
46 static DEADRECKONING_DELIVERY_CTRL_TBL_MNG g_delivery_dr_ctrltbl_mng;
47 static DEADRECKONING_DELIVERY_PNO_TBL g_delivery_dr_pnotbl;
49 /* Stored data count */
50 int32 g_delivery_dr_ctrl_num = 0;
52 /* PastModel002 support DR */
53 /*******************************************************************************
54 * MODULE : DeadReckoningInitDeliveryCtrlTbl
55 * ABSTRACT : Vehicle sensor delivery destination management table initialization function
56 * FUNCTION : Delivery destination management table initialization processing
60 ******************************************************************************/
61 void DeadReckoningInitDeliveryCtrlTbl(void) { // LCOV_EXCL_START 8: dead code.
62 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
63 memset(&g_delivery_dr_ctrltbl, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL));
66 /*******************************************************************************
67 * MODULE : DeadReckoningInitDeliveryCtrlTblMng
68 * ABSTRACT : Vehicle sensor delivery destination management table management area initialization function
69 * FUNCTION : Delivery destination management table management area initialization processing
73 ******************************************************************************/
74 void DeadReckoningInitDeliveryCtrlTblMng(void) {
75 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
76 memset(&g_delivery_dr_ctrltbl_mng, 0x00, sizeof(DEADRECKONING_DELIVERY_CTRL_TBL_MNG));
79 /*******************************************************************************
80 * MODULE : DeadReckoningEntryDeliveryCtrl
81 * ABSTRACT : Vehicle sensor delivery destination management registration function
82 * FUNCTION : Shipping management table,Update the shipping management table management.
83 * ARGUMENT : p_st_delivery_entry : Pointer to the delivery registration information
85 * RETURN : VEHICLE_RET_NORMAL :Successful registration
86 ******************************************************************************/
87 DEAD_RECKONING_RET_API DeadReckoningEntryDeliveryCtrl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
88 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
90 u_int8 uc_action_type = DEADRECKONING_ACTION_TYPE_ADD;
92 DID ul_entry_did = p_st_delivery_entry->data.did;
93 DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data = NULL;
94 /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
95 DEAD_RECKONING_RET_API ret = DEAD_RECKONING_RET_NORMAL;
97 /* Check if the data ID exists. */
98 uc_did_flag = DeadReckoningCheckDid(ul_entry_did);
99 if (uc_did_flag == 0) {
100 ret = DEADRECKONING_RET_ERROR_DID; /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
103 /* Check the number of registered shipments. */
104 if ((ret == DEAD_RECKONING_RET_NORMAL) &&/* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
105 (g_delivery_dr_ctrltbl.us_num >= DEADRECKONING_DELIVERY_INFO_MAX)) {
106 /* Return the FULL of delivery registrations*/
107 ret = DEADRECKONING_RET_ERROR_BUFFULL; /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
109 /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
110 if (ret == DEAD_RECKONING_RET_NORMAL) {
111 /* By searching for the delivery registration of the relevant DID,Hold the address. */
112 for (i = 0; i < g_delivery_dr_ctrltbl_mng.us_num; i++) {
113 if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_entry_did) {
114 uc_action_type = DEADRECKONING_ACTION_TYPE_UPDATE;
115 p_st_existing_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i];
119 /* Add to the shipping management table.*/
120 DeadReckoningAddDeliveryCtrlTbl(p_st_delivery_entry);
122 /* Processing when updating existing data*/
123 if (uc_action_type == DEADRECKONING_ACTION_TYPE_UPDATE) {
124 /* Update the shipping management table.*/
125 DeadReckoningUpdateDeliveryCtrlTbl(p_st_existing_mng_data);
127 /* Update the shipping destination management table management information.*/
128 DeadReckoningUpdateDeliveryCtrlTblMng(p_st_existing_mng_data);
129 } else { /* Newly added processing*/
130 /* Add to the shipping management table management information.*/
131 DeadReckoningAddDeliveryCtrlTblMng(p_st_delivery_entry);
134 return ret; /* _CWORD71_:QAC++4020:Multiple exit points found. MISRA-C++ Rule 6-6-5 */
137 /*******************************************************************************
138 * MODULE : DeadReckoningAddDeliveryCtrlTbl
139 * ABSTRACT : Vehicle sensor delivery destination management table addition function
140 * FUNCTION : Add to the shipping management table.
141 * ARGUMENT : *p_st_delivery_entry : Pointer to the delivery registration information
144 ******************************************************************************/
145 void DeadReckoningAddDeliveryCtrlTbl(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
146 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
147 DEADRECKONING_DELIVERY_CTRL_TBL_DATA *p_st_ctrl_data;
149 p_st_ctrl_data = &g_delivery_dr_ctrltbl.st_ctrl_data[g_delivery_dr_ctrltbl.us_num];
150 p_st_ctrl_data->ul_did = p_st_delivery_entry->data.did;
151 p_st_ctrl_data->us_pno = p_st_delivery_entry->data.pno;
152 p_st_ctrl_data->uc_chg_type = p_st_delivery_entry->data.delivery_timing;
153 p_st_ctrl_data->uc_ctrl_flg = p_st_delivery_entry->data.ctrl_flg;
154 p_st_ctrl_data->us_link_idx = DEADRECKONING_LINK_INDEX_END;
155 p_st_ctrl_data->uc_method = DEADRECKONING_DELIVERY_METHOD_NORMAL;
157 g_delivery_dr_ctrltbl.us_num = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num + 1);
160 /*******************************************************************************
161 * MODULE : DeadReckoningUpdateDeliveryCtrlTbl
162 * ABSTRACT : Vehicle sensor delivery destination management table update function
163 * FUNCTION : Update the shipping management table.
164 * ARGUMENT : *p_st_existing_mng_data : Pointer to the previous data information with the same data ID
167 ******************************************************************************/
168 void DeadReckoningUpdateDeliveryCtrlTbl(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
169 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
170 /* Update Link Index Only.
171 For the index of the value of us_end_idx that matches the data ID of the distribution target management table management information
172 Make us_link_idx a registered index */
173 g_delivery_dr_ctrltbl.st_ctrl_data[p_st_existing_mng_data->us_end_idx].us_link_idx =
174 static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
177 /*******************************************************************************
178 * MODULE : DeadReckoningAddDeliveryCtrlTblMng
179 * ABSTRACT : Vehicle sensor delivery destination management table management addition function
180 * FUNCTION : Add to the shipping management table management.
181 * ARGUMENT : *p_st_delivery_entry : Pointer to the delivery registration information
184 ******************************************************************************/
185 void DeadReckoningAddDeliveryCtrlTblMng(const DEADRECKONING_MSG_DELIVERY_ENTRY *p_st_delivery_entry) {
186 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
187 DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_ctr_mng_data;
189 p_st_ctr_mng_data = &g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[g_delivery_dr_ctrltbl_mng.us_num];
190 p_st_ctr_mng_data->ul_did = p_st_delivery_entry->data.did;
191 p_st_ctr_mng_data->us_start_idx = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
192 p_st_ctr_mng_data->us_end_idx = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
193 p_st_ctr_mng_data->us_dlvry_entry_num++;
194 g_delivery_dr_ctrltbl_mng.us_num++;
195 g_delivery_dr_ctrl_num++;
198 /*******************************************************************************
199 * MODULE : DeadReckoningUpdateDeliveryCtrlTblMng
200 * ABSTRACT : Vehicle sensor delivery destination management table management update function
201 * FUNCTION : Update the shipping management table management.
202 * ARGUMENT : *p_st_existing_mng_data : Pointer to the previous data information with the same data ID
205 ******************************************************************************/
206 void DeadReckoningUpdateDeliveryCtrlTblMng(DEADRECKONING_DELIVERY_CTRL_TBL_MNG_DATA *p_st_existing_mng_data) {
207 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
208 /* Update only the end index and the number of registered shipping destinations. */
209 p_st_existing_mng_data->us_end_idx = static_cast<u_int16>(g_delivery_dr_ctrltbl.us_num - 1);
210 p_st_existing_mng_data->us_dlvry_entry_num++;
213 /*******************************************************************************
214 * MODULE : DeadReckoningMakeDeliveryPnoTbl
215 * ABSTRACT : Vehicle sensor delivery destination PNO table creation function
216 * FUNCTION : Create the shipping destination PNO table
217 * ARGUMENT : ul_did Data ID
218 * Change_type Delivery Trigger
220 * RETURN : DEADRECKONING_DELIVERY_PNO_TBL* Pointer to the shipping PNO table
221 ******************************************************************************/
222 DEADRECKONING_DELIVERY_PNO_TBL* DeadReckoningMakeDeliveryPnoTbl(DID ul_did, u_int8 change_type) {
223 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
225 u_int16 us_index = 0;
228 /* Get the start index and count of the corresponding data ID. */
229 for (i = 0; i < g_delivery_dr_ctrl_num; i++) {
230 /* Stores the information of the corresponding DID.. */
231 if (g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].ul_did == ul_did) {
232 us_index = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_start_idx;
233 us_num = g_delivery_dr_ctrltbl_mng.st_ctrl_tbl_mng_data[i].us_dlvry_entry_num;
238 /* Create a PNO list */
239 g_delivery_dr_pnotbl.us_num = 0;
240 if (change_type == DEADRECKONING_CHGTYPE_CHG) {
241 /* Processing when delivery timing is changed*/
242 for (i = 0; i < us_num; i++) {
243 /* Functionalization by Increasing Structure Members */
244 DeadReckoningAddPnoTbl(us_index);
246 us_index = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
249 /* Processing when delivery timing is update */
250 for (i = 0; i < us_num; i++) {
251 if (DEADRECKONING_DELIVERY_TIMING_UPDATE == g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_chg_type) {
252 /* Functionalization by Increasing Structure Members */
253 DeadReckoningAddPnoTbl(us_index);
255 us_index = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_link_idx;
258 return (&g_delivery_dr_pnotbl);
261 /*******************************************************************************
262 * MODULE : DeadReckoningAddPnoTbl
263 * ABSTRACT : Vehicle Sensor Destination PNO Table Addition Function
264 * FUNCTION : Add to the shipping PNO table.
265 * ARGUMENT : us_index : Index of the referenced destination management table
268 ******************************************************************************/
269 void DeadReckoningAddPnoTbl(u_int16 us_index) {
270 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
271 u_int16 us_pno_tbl_idx;
273 us_pno_tbl_idx = g_delivery_dr_pnotbl.us_num;
274 g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_pno = g_delivery_dr_ctrltbl.st_ctrl_data[us_index].us_pno;
275 /* Save the relevant INDEX in the delivery control table */
276 g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].us_index = us_index;
277 g_delivery_dr_pnotbl.st_pno_data[us_pno_tbl_idx].uc_method =
278 g_delivery_dr_ctrltbl.st_ctrl_data[us_index].uc_method;
279 g_delivery_dr_pnotbl.us_num++;
282 /*******************************************************************************
283 * MODULE : DeadReckoningDeliveryProc
284 * ABSTRACT : Vehicle Sensor Data Delivery Process
285 * FUNCTION : Deliver data to a destination.
286 * ARGUMENT : ul_did :Data ID
287 * uc_chg_type :Delivery timing
288 * uc_get_method :Acquisition method
291 ******************************************************************************/
292 void DeadReckoningDeliveryProc(DID ul_did, u_int8 uc_chg_type, u_int8 uc_get_method) {
293 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
294 int32 i; /* Generic counters */
295 DEADRECKONING_DATA_MASTER st_master; /* Data master of normal data */
298 /* Defines the data master for each API. */
299 SENSORLOCATION_MSG_LONLATINFO_DAT st_msg_lonlat_info;
300 SENSORLOCATION_MSG_ALTITUDEINFO_DAT st_msg_altitude_info;
301 SENSORMOTION_MSG_SPEEDINFO_DAT st_msg_speed_info;
302 SENSORMOTION_MSG_HEADINGINFO_DAT st_msg_heading_info;
305 const DEADRECKONING_DELIVERY_PNO_TBL *p_st_pno_tbl; /* Vehicle Sensor Destination PNO Table Pointer */
308 st_msg_lonlat_info.reserve[0] = 0;
309 st_msg_lonlat_info.reserve[1] = 0;
310 st_msg_lonlat_info.reserve[2] = 0;
311 st_msg_altitude_info.reserve[0] = 0;
312 st_msg_altitude_info.reserve[1] = 0;
313 st_msg_altitude_info.reserve[2] = 0;
314 st_msg_speed_info.reserve = 0;
315 st_msg_heading_info.reserve = 0;
317 /* Obtain the shipping destination PNO */
319 reinterpret_cast<DEADRECKONING_DELIVERY_PNO_TBL*>(DeadReckoningMakeDeliveryPnoTbl(ul_did, uc_chg_type));
321 if ((p_st_pno_tbl->us_num) > 0) {
322 /* When there is a shipping destination PNO registration */
323 /* Vehicle sensor information notification transmission process */
324 for (i = 0; i < (p_st_pno_tbl->us_num); i++) {
325 /* Acquire the applicable data information from the data master..*/
326 DeadReckoningGetDataMaster(ul_did, &st_master);
328 /* Align data from the data master for API I/F */
330 /* Describes the process for each DID. */
331 case VEHICLE_DID_DR_LATITUDE:
333 /* Size storage(LONLAT) */
334 st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);
336 /* DR status setting */
337 st_msg_lonlat_info.dr_status = st_master.dr_status;
339 /* The DR enable flag is set to enabled. */
340 st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
342 /* Set the Latitude */
343 (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.latitude)),
344 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
346 /* Obtain the data master Longitude */
347 DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);
349 /* Set the Longitude */
350 (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.longitude)),
351 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
353 /* Acquire data master SensorCnt */
354 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
356 /* Set the SensorCnt */
357 (void)memcpy(reinterpret_cast<void *>(&(st_msg_lonlat_info.sensor_cnt)),
358 (const void *)(&( st_master.uc_data[0])), (size_t)(st_master.us_size));
360 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
361 p_st_pno_tbl->st_pno_data[i].us_pno,
362 CID_VEHICLE_SENSORLOCATION_LONLAT,
363 sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
364 (const void *)&st_msg_lonlat_info);
367 case VEHICLE_DID_DR_ALTITUDE:
369 /* Size storage(ALTITUDE) */
370 st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);
372 /* The DR enable flag is set to enabled. */
373 st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
375 /* DR status setting */
376 st_msg_altitude_info.dr_status = st_master.dr_status;
379 /* Set the Altitude */
380 (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.altitude)),
381 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
383 /* Acquire data master SensorCnt */
384 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
386 /* Set the SensorCnt */
387 (void)memcpy(reinterpret_cast<void *>(&(st_msg_altitude_info.sensor_cnt)),
388 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
390 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
391 p_st_pno_tbl->st_pno_data[i].us_pno,
392 CID_VEHICLE_SENSORLOCATION_ALTITUDE,
393 sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
394 (const void *)&st_msg_altitude_info);
398 case VEHICLE_DID_DR_SPEED:
400 /* Size storage(SPEED) */
401 st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);
403 /* The DR enable flag is set to enabled. */
404 st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
406 /* DR status setting */
407 st_msg_speed_info.dr_status = st_master.dr_status;
411 (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.speed)),
412 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
414 /* Acquire data master SensorCnt */
415 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
416 /* Set the SensorCnt */
417 (void)memcpy(reinterpret_cast<void *>(&(st_msg_speed_info.sensor_cnt)),
418 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
420 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
421 p_st_pno_tbl->st_pno_data[i].us_pno,
422 CID_VEHICLE_SENSORMOTION_SPEED,
423 sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
424 (const void *)&st_msg_speed_info);
427 case VEHICLE_DID_DR_HEADING:
429 /* Size storage(HEADING) */
430 st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);
432 /* The DR enable flag is set to enabled. */
433 st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
435 /* DR status setting */
436 st_msg_heading_info.dr_status = st_master.dr_status;
438 /* Set the Heading */
439 (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
440 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
442 /* Acquire data master SensorCnt */
443 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
444 /* Set the SensorCnt */
445 (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
446 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
448 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
449 p_st_pno_tbl->st_pno_data[i].us_pno,
450 CID_VEHICLE_SENSORMOTION_HEADING,
451 sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
452 (const void *)&st_msg_heading_info);
455 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
457 SENSORMOTION_MSG_GYROPARAMETERINFO_DAT stMsgGyroParameterInfo;
459 stMsgGyroParameterInfo.reserve[0] = 0;
460 stMsgGyroParameterInfo.reserve[1] = 0;
462 /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master */
463 /* setup must be completed before data delivery of this DID */
464 /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing */
466 /* Size storage(GYROPARAMETER) */
467 stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);
469 /* GyroOffset acuisition/setting */
470 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);
472 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
473 reinterpret_cast<void *>(&(st_master.uc_data[0])),
474 sizeof(stMsgGyroParameterInfo.gyro_offset));
476 /* GyroScaleFactor acuisition/setting */
477 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);
479 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
480 reinterpret_cast<void *>(&(st_master.uc_data[0])),
481 sizeof(stMsgGyroParameterInfo.gyro_scale_factor));
483 /* GyroScaleFactorLevel acuisition/setting */
484 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);
486 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
487 reinterpret_cast<void *>(&(st_master.uc_data[0])),
488 sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));
490 /* Data transmission */
491 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
492 p_st_pno_tbl->st_pno_data[i].us_pno,
493 CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
494 sizeof(stMsgGyroParameterInfo),
495 (const void *)&stMsgGyroParameterInfo);
498 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
500 SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT stMsgSpeedPulseParameterInfo;
503 stMsgSpeedPulseParameterInfo.reserve[0] = 0;
504 stMsgSpeedPulseParameterInfo.reserve[1] = 0;
505 stMsgSpeedPulseParameterInfo.reserve[2] = 0;
507 /* GyroOffset/GyroScaleFactor/GyroScaleFactorLevel data master */
508 /* setup must be completed before data delivery of this DID */
509 /* The order of processing is defined by DeadReckoning_RcvMsg().,Be careful when changing */
511 /* Size storage(SPEEDPULSEPARAMETER) */
512 stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);
514 /* SpeedPulseScaleFactor acuisition/setting */
515 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);
517 (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
518 reinterpret_cast<void *>(&(st_master.uc_data[0])),
519 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));
521 /* SpeedPulseScaleFactorLevel acuisition/setting */
522 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);
524 (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
525 reinterpret_cast<void *>(&(st_master.uc_data[0])),
526 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));
528 /* Data transmission */
529 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
530 p_st_pno_tbl->st_pno_data[i].us_pno,
531 CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
532 sizeof(stMsgSpeedPulseParameterInfo),
533 (const void *)&stMsgSpeedPulseParameterInfo);
536 /* Other than the above */
545 /*******************************************************************************
546 * MODULE : DRManagerSndMsg
547 * ABSTRACT : Message transmission processing
548 * FUNCTION : Send a message to the specified PNO
549 * ARGUMENT : us_pno_src : Source PNO
550 * : us_pno_dest : Destination PNO
551 * : us_cid : Command ID
552 * : us_msg_len : Message data body length
553 * : *p_msg_data : Pointer to message data
555 * RETURN : RET_NORMAL : Normal completion
556 * : RET_ERRNOTRDY : Destination process is not wakeup
557 * : RET_ERRMSGFULL : Message queue overflows
558 * : RET_ERRPARAM : Buffer size error
559 ******************************************************************************/
560 RET_API DRManagerSndMsg(PNO us_pno_src, PNO us_pno_dest, CID us_cid, u_int16 us_msg_len, const void *p_msg_data) {
561 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
562 DEADRECKONING_MSG_BUF st_msg_buf; /* message buffer */
563 T_APIMSG_MSGBUF_HEADER *p_st_msg_hdr; /* Pointer to the message header */
564 RET_API l_ret_api; /* Return value */
566 /* Message buffer initialization */
567 memset(reinterpret_cast<void *>(&st_msg_buf), 0, sizeof(DEADRECKONING_MSG_BUF));
569 /* Get pointer to send buffer */
570 p_st_msg_hdr = reinterpret_cast<T_APIMSG_MSGBUF_HEADER *>(reinterpret_cast<void *>(&st_msg_buf));
572 /*--------------------------------------------------------------*
573 * Create message headers *
574 *--------------------------------------------------------------*/
575 p_st_msg_hdr->hdr.sndpno = us_pno_src; /* Source PNO */
576 p_st_msg_hdr->hdr.cid = us_cid; /* Command ID */
577 p_st_msg_hdr->hdr.msgbodysize = us_msg_len; /* Message data body length */
579 /*--------------------------------------------------------------*
580 * Create message data *
581 *--------------------------------------------------------------*/
582 if ((0 != p_msg_data) && (0 != us_msg_len)) {
583 /* Set the message data */
584 memcpy(reinterpret_cast<void *>(st_msg_buf.data), p_msg_data, (size_t)us_msg_len);
586 /*--------------------------------------------------------------*
588 *--------------------------------------------------------------*/
589 l_ret_api = _pb_SndMsg(us_pno_dest,
590 (u_int16)(sizeof(T_APIMSG_MSGBUF_HEADER) + us_msg_len),
591 reinterpret_cast<void *>(&st_msg_buf),
597 /*******************************************************************************
598 * MODULE : DeadReckoningFirstDelivery
599 * ABSTRACT : Vehicle Sensor Initial Data Delivery Process
600 * FUNCTION : Deliver the initial data to the destination.
601 * ARGUMENT : us_pno :Addresses for delivery NO
605 ******************************************************************************/
606 void DeadReckoningFirstDelivery(PNO us_pno, DID ul_did) {
607 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
608 DEADRECKONING_DATA_MASTER st_master; /* Data master of normal data */
610 /* Defines the data master for each API. */
611 SENSORLOCATION_MSG_LONLATINFO_DAT st_msg_lonlat_info;
612 SENSORLOCATION_MSG_ALTITUDEINFO_DAT st_msg_altitude_info;
613 SENSORMOTION_MSG_SPEEDINFO_DAT st_msg_speed_info;
614 SENSORMOTION_MSG_HEADINGINFO_DAT st_msg_heading_info;
617 st_msg_lonlat_info.reserve[0] = 0;
618 st_msg_lonlat_info.reserve[1] = 0;
619 st_msg_lonlat_info.reserve[2] = 0;
620 st_msg_altitude_info.reserve[0] = 0;
621 st_msg_altitude_info.reserve[1] = 0;
622 st_msg_altitude_info.reserve[2] = 0;
623 st_msg_speed_info.reserve = 0;
624 st_msg_heading_info.reserve = 0;
626 /* Align data from the data master for API I/F */
628 /* Describes the process for each DID. */
629 case VEHICLE_DID_DR_LATITUDE:
631 DeadReckoningGetDataMaster(ul_did, &st_master);
633 /* Size storage(LONLAT) */
634 st_msg_lonlat_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT);
636 /* DR status setting */
637 st_msg_lonlat_info.dr_status = st_master.dr_status;
639 /* The DR enable flag is set to enabled. */
640 st_msg_lonlat_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
642 /* Set the Latitude */
643 memcpy(&(st_msg_lonlat_info.latitude), &(st_master.uc_data[0]), st_master.us_size);
645 /* Obtain the data master Longitude */
646 DeadReckoningGetDataMaster(VEHICLE_DID_DR_LONGITUDE, &st_master);
648 /* Set the Longitude */
649 memcpy(&(st_msg_lonlat_info.longitude), &(st_master.uc_data[0]), st_master.us_size);
651 /* Acquire data master SensorCnt */
652 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
654 /* Set the SensorCnt */
655 memcpy(&(st_msg_lonlat_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
657 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
659 CID_VEHICLE_SENSORLOCATION_LONLAT,
660 sizeof(SENSORLOCATION_MSG_LONLATINFO_DAT),
661 (const void *)&st_msg_lonlat_info);
664 case VEHICLE_DID_DR_ALTITUDE:
666 DeadReckoningGetDataMaster(ul_did, &st_master);
668 /* Size storage(ALTITUDE) */
669 st_msg_altitude_info.size = (u_int16)sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT);
671 /* The DR enable flag is set to enabled. */
672 st_msg_altitude_info.is_exist_dr = SENSORLOCATION_EXISTDR_DR;
674 /* DR status setting */
675 st_msg_altitude_info.dr_status = st_master.dr_status;
678 /* Set the Altitude */
679 memcpy(&(st_msg_altitude_info.altitude), &(st_master.uc_data[0]), st_master.us_size);
681 /* Acquire data master SensorCnt */
682 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
684 /* Set the SensorCnt */
685 memcpy(&(st_msg_altitude_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
687 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
689 CID_VEHICLE_SENSORLOCATION_ALTITUDE,
690 sizeof(SENSORLOCATION_MSG_ALTITUDEINFO_DAT),
691 (const void *)&st_msg_altitude_info);
695 case VEHICLE_DID_DR_SPEED:
697 DeadReckoningGetDataMaster(ul_did, &st_master);
699 /* Size storage(SPEED) */
700 st_msg_speed_info.size = (u_int16)sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT);
702 /* The DR enable flag is set to enabled. */
703 st_msg_speed_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
705 /* DR status setting */
706 st_msg_speed_info.dr_status = st_master.dr_status;
710 memcpy(&(st_msg_speed_info.speed), &(st_master.uc_data[0]), st_master.us_size);
712 /* Acquire data master SensorCnt */
713 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
714 /* Set the SensorCnt */
715 memcpy(&(st_msg_speed_info.sensor_cnt), &(st_master.uc_data[0]), st_master.us_size);
717 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
719 CID_VEHICLE_SENSORMOTION_SPEED,
720 sizeof(SENSORMOTION_MSG_SPEEDINFO_DAT),
721 (const void *)&st_msg_speed_info);
724 case VEHICLE_DID_DR_HEADING:
726 DeadReckoningGetDataMaster(ul_did, &st_master);
728 /* Size storage(HEADING) */
729 st_msg_heading_info.size = (u_int16)sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT);
731 /* The DR enable flag is set to enabled. */
732 st_msg_heading_info.is_exist_dr = SENSORMOTION_EXISTDR_DR;
734 /* DR status setting */
735 st_msg_heading_info.dr_status = st_master.dr_status;
738 /* Set the Heading */
739 (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.heading)),
740 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
742 /* Acquire data master SensorCnt */
743 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SNS_COUNTER, &st_master);
744 /* Set the SensorCnt */
745 (void)memcpy(reinterpret_cast<void *>(&(st_msg_heading_info.sensor_cnt)),
746 (const void *)(&(st_master.uc_data[0])), (size_t)(st_master.us_size));
748 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
750 CID_VEHICLE_SENSORMOTION_HEADING,
751 sizeof(SENSORMOTION_MSG_HEADINGINFO_DAT),
752 (const void *)&st_msg_heading_info);
755 case VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL:
757 SENSORMOTION_MSG_GYROPARAMETERINFO_DAT stMsgGyroParameterInfo;
760 stMsgGyroParameterInfo.reserve[0] = 0;
761 stMsgGyroParameterInfo.reserve[1] = 0;
763 /* Size storage(GYROPARAMETER) */
764 stMsgGyroParameterInfo.size = (u_int16)sizeof(stMsgGyroParameterInfo);
766 /* GyroOffset acuisition/setting */
767 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_OFFSET, &st_master);
769 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_offset)),
770 reinterpret_cast<void *>(&(st_master.uc_data[0])),
771 sizeof( stMsgGyroParameterInfo.gyro_offset));
773 /* GyroScaleFactor acuisition/setting */
774 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR, &st_master);
776 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor)),
777 reinterpret_cast<void *>(&(st_master.uc_data[0])),
778 sizeof(stMsgGyroParameterInfo.gyro_scale_factor));
780 /* GyroScaleFactorLevel acuisition/setting */
781 DeadReckoningGetDataMaster(VEHICLE_DID_DR_GYRO_SCALE_FACTOR_LEVEL, &st_master);
783 (void)memcpy(reinterpret_cast<void *>(&(stMsgGyroParameterInfo.gyro_scale_factor_level)),
784 reinterpret_cast<void *>(&(st_master.uc_data[0])),
785 sizeof(stMsgGyroParameterInfo.gyro_scale_factor_level));
787 /* Data transmission */
788 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
790 CID_VEHICLE_SENSORMOTION_GYROPARAMETER,
791 sizeof(stMsgGyroParameterInfo),
792 (const void *)&stMsgGyroParameterInfo);
795 case VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL:
797 SENSORMOTION_MSG_SPEEDPULSEPARAMETERINFO_DAT stMsgSpeedPulseParameterInfo;
800 stMsgSpeedPulseParameterInfo.reserve[0] = 0;
801 stMsgSpeedPulseParameterInfo.reserve[1] = 0;
802 stMsgSpeedPulseParameterInfo.reserve[2] = 0;
804 /* Size storage(SPEEDPULSEPARAMETER) */
805 stMsgSpeedPulseParameterInfo.size = (u_int16)sizeof(stMsgSpeedPulseParameterInfo);
807 /* SpeedPulseScaleFactor acuisition/setting */
808 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR, &st_master);
810 (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor)),
811 reinterpret_cast<void *>(&(st_master.uc_data[0])),
812 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor));
814 /* SpeedPulseScaleFactorLevel acuisition/setting */
815 DeadReckoningGetDataMaster(VEHICLE_DID_DR_SPEED_PULSE_SCALE_FACTOR_LEVEL, &st_master);
817 (void)memcpy(reinterpret_cast<void *>(&(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level)),
818 reinterpret_cast<void *>(&(st_master.uc_data[0])),
819 sizeof(stMsgSpeedPulseParameterInfo.speed_pulse_scale_factor_level));
821 /* Data transmission */
822 (void)DRManagerSndMsg(PNO_VEHICLE_SENSOR,
824 CID_VEHICLE_SENSORMOTION_SPEEDPULSEPARAMETER,
825 sizeof(stMsgSpeedPulseParameterInfo),
826 (const void *)&stMsgSpeedPulseParameterInfo);
829 /* Other than the above */