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 :Sensor_API.cpp
20 * Subsystem name :Sensor I/F library
21 * Program name :SensorI/F API
22 ******************************************************************************/
25 #include <vehicle_service/POS_sensor_API.h>
26 #include <vehicle_service/POS_define.h>
27 #include <vehicle_service/POS_sensor_API.h>
28 #include <vehicle_service/positioning_base_library.h>
29 #include "POS_sensor_private.h"
30 #include "Sensor_Common_API.h"
31 #include "Sensor_API_private.h"
32 #include "Sensor_Common_API.h"
33 #include "Vehicle_API_Dummy.h"
34 #include "Vehicle_API_private.h"
35 #include "Naviinfo_API.h"
36 #include "POS_private.h"
38 /*************************************************/
40 /*************************************************/
41 /********************************************************************************
42 * TAG :TG_GPS_REQ_RESET
43 * ABSTRACT :GPS reset request
44 * NOTE :I/F information between host applications(Reset mode)
45 ********************************************************************************/
47 * @brief POS_RegisterListenerPkgSensData Return code list
49 static const SENSOR_RET_PKG g_ret_list_reg_lis_pkg_sens_data[SENSOR_PUBLIC_DID_NUM] = {
50 /* GRADE2 GRADE1 DID (Key) */
51 {TRUE, TRUE, POS_DID_SPEED_PULSE },
52 {FALSE, TRUE, POS_DID_SPEED_KMPH },
53 {TRUE, TRUE, POS_DID_GYRO_X },
54 {TRUE, TRUE, POS_DID_GYRO_Y },
55 {TRUE, TRUE, POS_DID_GYRO_Z },
56 {TRUE, TRUE, POS_DID_GSNS_X },
57 {TRUE, TRUE, POS_DID_GSNS_Y },
58 {TRUE, TRUE, POS_DID_GSNS_Z },
59 {FALSE, TRUE, POS_DID_GPS_ANTENNA },
60 {TRUE, TRUE, POS_DID_SNS_COUNTER },
61 {FALSE, TRUE, POS_DID_SPEED_PULSE_FST },
62 {FALSE, TRUE, POS_DID_GYRO_X_FST },
63 {FALSE, TRUE, POS_DID_GYRO_Y_FST },
64 {FALSE, TRUE, POS_DID_GYRO_Z_FST },
65 {FALSE, TRUE, POS_DID_GPS__CWORD82__NMEA },
66 {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 },
67 {FALSE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY },
68 {FALSE, TRUE, POS_DID_GPS_NMEA },
69 {TRUE, TRUE, POS_DID_REV },
70 {FALSE, TRUE, POS_DID_REV_FST },
71 {TRUE, TRUE, POS_DID_GYRO_TEMP },
72 {FALSE, TRUE, POS_DID_GYRO_TEMP_FST },
73 {FALSE, TRUE, POS_DID_GSNS_X_FST },
74 {FALSE, TRUE, POS_DID_GSNS_Y_FST },
75 {FALSE, TRUE, POS_DID_GSNS_Z_FST },
76 {TRUE, TRUE, POS_DID_PULSE_TIME },
77 {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT },
78 {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ },
79 {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */
80 {FALSE, TRUE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */
81 {FALSE, TRUE, VEHICLE_DID_GPS_WKNROLLOVER} /* For local use */
85 * @brief POS_RegisterListenerSensData Return code list
87 static const SENSOR_RET_PKG g_ret_list_reg_lis_sens_data[SENSOR_PUBLIC_DID_NUM] = {
88 /* GRADE2 GRADE1 DID (Key) */
89 {TRUE, TRUE, POS_DID_SPEED_PULSE },
90 {FALSE, TRUE, POS_DID_SPEED_KMPH },
91 {TRUE, TRUE, POS_DID_GYRO_X },
92 {TRUE, TRUE, POS_DID_GYRO_Y },
93 {TRUE, TRUE, POS_DID_GYRO_Z },
94 {TRUE, TRUE, POS_DID_GSNS_X },
95 {TRUE, TRUE, POS_DID_GSNS_Y },
96 {TRUE, TRUE, POS_DID_GSNS_Z },
97 {TRUE, TRUE, POS_DID_GPS_ANTENNA },
98 {FALSE, TRUE, POS_DID_SNS_COUNTER },
99 {TRUE, TRUE, POS_DID_SPEED_PULSE_FST },
100 {TRUE, TRUE, POS_DID_GYRO_X_FST },
101 {TRUE, TRUE, POS_DID_GYRO_Y_FST },
102 {TRUE, TRUE, POS_DID_GYRO_Z_FST },
103 {TRUE, TRUE, POS_DID_GPS__CWORD82__NMEA },
104 {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 },
105 {TRUE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY },
106 {FALSE, TRUE, POS_DID_GPS_NMEA },
107 {FALSE, TRUE, POS_DID_REV },
108 {TRUE, TRUE, POS_DID_REV_FST },
109 {TRUE, TRUE, POS_DID_GYRO_TEMP },
110 {TRUE, TRUE, POS_DID_GYRO_TEMP_FST },
111 {TRUE, TRUE, POS_DID_GSNS_X_FST },
112 {TRUE, TRUE, POS_DID_GSNS_Y_FST },
113 {TRUE, TRUE, POS_DID_GSNS_Z_FST },
114 {FALSE, TRUE, POS_DID_PULSE_TIME },
115 {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT },
116 {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ },
117 {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */
118 {FALSE, TRUE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */
119 {FALSE, TRUE, VEHICLE_DID_GPS_WKNROLLOVER } /* For local use */
123 * @brief POS_GetSensData Return code list
125 static const SENSOR_RET_PKG g_ret_list_get_sens_data[SENSOR_PUBLIC_DID_NUM] = {
126 /* GRADE2 GRADE1 DID (Key) */
127 {TRUE, TRUE, POS_DID_SPEED_PULSE },
128 {FALSE, TRUE, POS_DID_SPEED_KMPH },
129 {TRUE, TRUE, POS_DID_GYRO_X },
130 {TRUE, TRUE, POS_DID_GYRO_Y },
131 {TRUE, TRUE, POS_DID_GYRO_Z },
132 {TRUE, TRUE, POS_DID_GSNS_X },
133 {TRUE, TRUE, POS_DID_GSNS_Y },
134 {TRUE, TRUE, POS_DID_GSNS_Z },
135 {TRUE, TRUE, POS_DID_GPS_ANTENNA },
136 {FALSE, TRUE, POS_DID_SNS_COUNTER },
137 {FALSE, TRUE, POS_DID_SPEED_PULSE_FST },
138 {FALSE, TRUE, POS_DID_GYRO_X_FST },
139 {FALSE, TRUE, POS_DID_GYRO_Y_FST },
140 {FALSE, TRUE, POS_DID_GYRO_Z_FST },
141 {TRUE, TRUE, POS_DID_GPS__CWORD82__NMEA },
142 {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 },
143 {TRUE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY },
144 {FALSE, TRUE, POS_DID_GPS_NMEA },
145 {FALSE, TRUE, POS_DID_REV },
146 {FALSE, TRUE, POS_DID_REV_FST },
147 {TRUE, TRUE, POS_DID_GYRO_TEMP },
148 {FALSE, TRUE, POS_DID_GYRO_TEMP_FST },
149 {FALSE, TRUE, POS_DID_GSNS_X_FST },
150 {FALSE, TRUE, POS_DID_GSNS_Y_FST },
151 {FALSE, TRUE, POS_DID_GSNS_Z_FST },
152 {FALSE, TRUE, POS_DID_PULSE_TIME },
153 {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT },
154 {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ },
155 {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */
156 {FALSE, TRUE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */
157 {FALSE, TRUE, VEHICLE_DID_GPS_WKNROLLOVER } /* For local use */
162 * DID-decision functions for Sensor API
164 * Determines whether or not the DID specified by the public API corresponds to the DID.
166 * @param[in] did Data ID
167 * @param[in] mode Operation mode 1:For Package Delivery Registration API<br>
168 * 2:For Sensor Data Delivery Registration API<br>
169 * 3:For Sensor Data Acquisition API
171 * @return TRUE Be supported
172 * FALSE Not supported
174 BOOL SensorJudgeDid(DID did, uint8_t mode) {
177 const SENSOR_RET_PKG *pkg_list = NULL;
180 /* Set Return pakage list */
182 case MODE_REGISTER_LISTENER_PKG_SENS_DATA: /* POS_RegisterListenerPkgSensData */
184 pkg_list = g_ret_list_reg_lis_pkg_sens_data;
187 case MODE_REGISTER_LISTENER_SENSDATA: /* POS_RegisterListenerSensData */
189 pkg_list = g_ret_list_reg_lis_sens_data;
192 case MODE_GET_SENSDATA: /* POS_GetSensData */
194 pkg_list = g_ret_list_get_sens_data;
199 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [mode = %d]", mode);
203 if (pkg_list != NULL) {
204 /* Search Return code list for DID */
205 for (i = 0; i < SENSOR_PUBLIC_DID_NUM; i++) {
206 if (did == pkg_list[i].did) {
211 if (i != SENSOR_PUBLIC_DID_NUM) {
213 type = GetEnvSupportInfo();
215 case UNIT_TYPE_GRADE1:
217 ret = pkg_list[i].GRADE1_ret;
220 case UNIT_TYPE_GRADE2:
224 * This feature branches processing depending on the unit type.
226 ret = pkg_list[i].GRADE2_ret;
231 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
232 "GetEnvSupportInfo ERROR [type = %d]", type);
237 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [did = %d]", did);
246 * Vehicle Sensor Information Extended Package Delivery Registration
247 * Sensor information is delivered for the first time.,Extension Packaging and Registering for Delivery.
249 * @param[in] hApp Application handle
250 * @param[in] notifyName Destination thread name
251 * @param[in] ucPkgNum Number of package data(1 to 16)
252 * @param[in] *pulDid Pointer to an array of data IDs for vehicle information
253 * @param[in] ucCtrlFlg Delivery control<br>
254 * Delivery registration: SENSOR_DELIVERY_REGIST<br>
255 * Delivery stop: SENSOR_DELIVERY_STOP (Note: Not mounted)<br>
256 * Resume delivery: SENSOR_DELIVERY_RESTART (Note: Not mounted)
257 * @param[in] ucDeliveryTiming Delivery timing<br>
258 * Updating : SENSOR_DELIVERY_TIMING_UPDATE<br>
259 * Changing : SENSOR_DELIVERY_TIMING_CHANGE
261 * @return SENSOR_RET_NORMAL Successful registration<br>
262 * SENSOR_RET_ERROR_CREATE_EVENT Event generation failure<br>
263 * SENSOR_RET_ERROR_PARAM Parameter error<br>
264 * SENSOR_RET_ERROR_DID Unregistered ID<br>
265 * SENSOR_RET_ERROR_BUFFULL FULL of delivery registers<br>
266 * SENSOR_RET_ERROR_NOSUPPORT Unsupported environment<br>
267 * SENSOR_RET_ERROR_INNER Internal abnormality
270 SENSOR_RET_API POS_RegisterListenerPkgSensData(HANDLE hApp,
273 DID *pulDid, uint8_t ucCtrlFlg, uint8_t ucDeliveryTiming) {
274 SENSOR_RET_API ret; /* Return value */
276 RET_API ret_api; /* System API return value */
277 EventID event_id; /* Event ID */
278 int32_t event_val; /* Event value */
279 SENSOR_MSG_DELIVERY_ENTRY_DAT data; /* Message data */
280 int32_t i; /* Generic counters */
281 PNO ch_pno; /* Converted internal PNO */
282 UNIT_TYPE type; /* Supported HW Configuration Type */
284 /* Internal debug log output */
285 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
287 ret = SENSOR_RET_NORMAL;
290 /* NULL terminates with an abnormal parameter */
291 ret = SENSOR_RET_ERROR_PARAM;
294 if (ret == SENSOR_RET_NORMAL) {
295 /* Positioning Base API initialization */
296 _pb_Setup_CWORD64_API(hApp);
298 /* Supported HW Configuration Check */
299 type = GetEnvSupportInfo();
300 if (UNIT_TYPE_GRADE1 == type) {
302 ret = SENSOR_RET_NORMAL;
303 } else if (UNIT_TYPE_GRADE2 == type) {
306 * This feature branches processing depending on the unit type.
308 ret = SENSOR_RET_ERROR_NOSUPPORT;
310 /* Environment error */
311 ret = SENSOR_RET_ERROR_NOSUPPORT;
315 if (ret == SENSOR_RET_NORMAL) {
316 /* Check Delivery Control Designation */
317 if (SENSOR_DELIVERY_REGIST != ucCtrlFlg) {
318 /* Parameters other than delivery registration terminated abnormally. */
319 ret = SENSOR_RET_ERROR_PARAM;
320 } else if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
321 (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
322 /* Check delivery timing */
323 /* Change delivery timing,Terminate as a parameter error except update */
324 ret = SENSOR_RET_ERROR_PARAM;
325 } else if (notifyName == NULL) {
326 /* Check Thread Name */
327 /* NULL terminates with an abnormal parameter */
328 ret = SENSOR_RET_ERROR_PARAM;
329 } else if ((0 == ucPkgNum) || (SENSOR_PKG_DELIVERY_MAX < ucPkgNum)) {
330 /* Check Package Data Count */
331 /* Out-of-range is terminated as a parameter error. */
332 ret = SENSOR_RET_ERROR_PARAM;
333 } else if (pulDid == NULL) {
335 /* NULL terminates with an abnormal parameter */
336 ret = SENSOR_RET_ERROR_PARAM;
338 /* Check if data ID is acceptable */
339 for (i = 0; i < ucPkgNum; i++) {
341 ret_b = SENSOR_DID_JUDGE_REGLIS_PKG(pulDid[i]);
342 if (ret_b == FALSE) {
343 /* An unacceptable ID terminates with an abnormal parameter. */
344 ret = SENSOR_RET_ERROR_PARAM;
347 ret = SENSOR_RET_NORMAL;
353 if (ret == SENSOR_RET_NORMAL) {
354 /* Resource acquisition */
355 if (VehicleGetResource() == TRUE) {
360 memset(reinterpret_cast<void *>(&data), 0, sizeof(SENSOR_MSG_DELIVERY_ENTRY_DAT));
362 /* Get PNO from Thread Name */
363 ch_pno = _pb_CnvName2Pno(notifyName);
365 /* Event Generation */
366 event_id = PosCreateEvent(ch_pno);
369 /* Successful event generation */
371 /*--------------------------------------------------------------*
372 * Send Vehicle Sensor Information Delivery Registration Message *
373 *--------------------------------------------------------------*/
374 /* Create Message Data */
376 data.pkg_num = ucPkgNum;
377 data.delivery_timing = ucDeliveryTiming;
378 data.ctrl_flg = ucCtrlFlg;
379 data.event_id = event_id;
380 for (i = 0; i < ucPkgNum; i++) {
381 data.did[i] = pulDid[i];
385 ret_api = PosSndMsg(ch_pno,
387 CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT,
388 (uint16_t)sizeof(SENSOR_MSG_DELIVERY_ENTRY_DAT),
389 (const void *)&data);
391 if (RET_NORMAL == ret_api) {
392 /* Message transmission processing is successful */
393 /* Wait for completion event from vehicle sensor thread */
394 ret_api = _pb_WaitEvent(event_id,
396 SENSOR_RET_ERROR_MIN,
399 POS_API_TIME_OUT_MS);
400 if (RET_NORMAL != ret_api) {
401 /* Return an internal error */
402 ret = SENSOR_RET_ERROR_INNER;
404 /* Return from Event Wait */
405 /* Set event value (processing result) as return value */
406 ret = (SENSOR_RET_API)event_val;
409 /* Message transmission processing failed */
410 /* Return an internal error */
411 ret = SENSOR_RET_ERROR_INNER;
415 ret_api = PosDeleteEvent(event_id);
417 /* Event generation failure */
418 ret = SENSOR_RET_ERROR_CREATE_EVENT;
421 /* When resource shortage occurs, the system terminates with an insufficient resource error. */
422 ret = SENSOR_RET_ERROR_RESOURCE;
424 /* Resource release */
425 VehicleReleaseResource();
428 /* Internal debug log output */
429 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
434 /*******************************************************************************
435 * MODULE : PosCreateEvent
436 * ABSTRACT : Event creation process
437 * FUNCTION : Generate an event
438 * ARGUMENT : pno : Thread ID
440 * RETURN : Non-zero : Event ID
441 * : Zero : Event generation failure
442 ******************************************************************************/
443 EventID PosCreateEvent(PNO pno) {
444 EventID event_id; /* Event ID */
445 char event_name[32]; /* Event name character string buffer */
446 RET_API ret_api; /* System API return value */
448 /* Initialization of event name character string buffer */
449 (void)memset(reinterpret_cast<void *>(event_name), 0, sizeof(event_name));
451 /* Event name creation */
452 snprintf(event_name, sizeof(event_name), "SENSOR_%X", pno); /* Ignore->MISRA-C++:2008 Rule 5-2-12 */
454 /* Event Generation */
455 event_id = _pb_CreateEvent(FALSE , 0, event_name); /* Ignore->MISRA-C++:2008 Rule 5-2-12 */
458 /* For successful event generation */
460 /* Initialize the event */
461 ret_api = _pb_SetEvent(event_id, SAPI_EVSET_ABSOLUTE, SENSOR_EVENT_VAL_INIT);
462 if (RET_NORMAL != ret_api) {
463 /* Event initialization failed */
465 /* Delete Event and Return Event Generation Failed */
466 ret_api = PosDeleteEvent(event_id);
474 /*******************************************************************************
475 * MODULE : PosDeleteEvent
476 * ABSTRACT : Event deletion processing
477 * FUNCTION : Delete events
478 * ARGUMENT : event_id : Event ID of the event to delete
480 * RETURN : RET_NORMAL : Normal completion
481 * : RET_EV_NONE : Specified event does not exist
482 ******************************************************************************/
483 RET_API PosDeleteEvent(EventID event_id) {
484 return(_pb_DeleteEvent(event_id));
487 /*******************************************************************************
488 * MODULE : SensorLinkShareData
489 * ABSTRACT : Link to shared memory
490 * FUNCTION : Link to shared memory
491 * ARGUMENT : **share_top : Storage destination of shared memory top address
492 * : *share_size : Storage destination of shared memory area size
493 * : *offset : Offset storage destination to free shared memory area
495 * RETURN : RET_NORMAL : Normal completion
496 * : RET_ERROR : There is no shared memory area.
497 ******************************************************************************/
498 RET_API SensorLinkShareData(void **share_top, uint32_t *share_size, uint16_t *offset) { // LCOV_EXCL_START 8:dead code
499 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
500 RET_API ret_api; /* System API return value */
501 SemID sem_id; /* Semaphore ID */
502 SENSOR_SHARE *share_top_tmp;
508 /* Create Semaphore */
509 sem_id = _pb_CreateSemaphore(const_cast<char *>(SENSOR_SEMAPHO_NAME));
512 ret_api = _pb_SemLock(sem_id);
513 if (RET_NORMAL == ret_api) {
514 /* Link to shared memory */
515 ret_api = _pb_LinkShareData(const_cast<char *>(SENSOR_SHARE_NAME), share_top, share_size);
516 if (RET_NORMAL == ret_api) {
517 /* By searching the free shared memory area,Offset is calculated if there is free space. */
518 share_top_tmp = reinterpret_cast<SENSOR_SHARE *>(*share_top);
520 /* Because the first block of the shared memory area is the control area,Loop from i = 1 */
521 for (i = 1; i < SENSOR_SHARE_BLOCK_NUM; i++) {
522 if (SENSOR_SHARE_UNLOCK == share_top_tmp->mng.lock_info[i]) {
526 if (i < SENSOR_SHARE_BLOCK_NUM) {
529 share_top_tmp->mng.lock_info[i] = SENSOR_SHARE_LOCK;
531 /* Calculate the offset to the block */
532 *offset = static_cast<uint16_t>(i * SENSOR_SHARE_BLOCK_SIZE);
534 /* Normal completion */
535 ret_api = RET_NORMAL;
541 /* Failed link to shared memory */
544 /* Semaphore unlock */
545 _pb_SemUnlock(sem_id);
547 /* Semaphore lock failed */
551 /* Semaphore creation failed */
559 /*******************************************************************************
560 * MODULE : SensorUnLinkShareData
561 * ABSTRACT : Unlinking shared memory
562 * FUNCTION : Unlink shared memory
563 * ARGUMENT : *share_top : Start address of shared memory
564 * : offset : Offset to shared memory free area
566 * RETURN : RET_NORMAL : Normal completion
567 * : RET_ERROR : There is no shared memory area./semaphore error
568 ******************************************************************************/
569 RET_API SensorUnLinkShareData(SENSOR_SHARE *share_top, uint16_t offset) { // LCOV_EXCL_START 8:dead code
570 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
571 RET_API ret_api; /* System API return value */
572 SemID sem_id; /* Semaphore ID */
578 /* Create Semaphore */
579 sem_id = _pb_CreateSemaphore(const_cast<char *>(SENSOR_SEMAPHO_NAME));
582 ret_api = _pb_SemLock(sem_id);
583 if (RET_NORMAL == ret_api) {
584 /* Unlock the block */
585 i = static_cast<int32>(offset) / SENSOR_SHARE_BLOCK_SIZE;
586 share_top->mng.lock_info[i] = SENSOR_SHARE_UNLOCK;
588 /* Semaphore unlock */
589 _pb_SemUnlock(sem_id);
591 /* Normal completion */
592 ret_api = RET_NORMAL;
594 /* Semaphore lock failed */
598 /* Semaphore creation failed */
606 /*******************************************************************************
607 * MODULE : SensorSetShareData
608 * ABSTRACT : Write processing to shared memory
609 * FUNCTION : Write shared memory
610 * ARGUMENT : *share_top : Start address of shared memory
611 * : offset : Offsets to shared memory write destination
616 ******************************************************************************/
617 void SensorSetShareData(void *share_top, uint16_t offset, const void *data_src, uint16_t size_src) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length)
618 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
619 SENSOR_SHARE_BLOCK_DAT *share_dat;
621 /* Calculate Shared Memory Write Address */
622 share_dat = reinterpret_cast<SENSOR_SHARE_BLOCK_DAT *>(reinterpret_cast<uint8_t *>(share_top) + offset);
623 /* #QAC confirmation Rule11.4 Use structure for member reference(Cast according to shared memory link IF) */
625 /* Clear Shared Memory */
626 memset(reinterpret_cast<void *>(share_dat), 0, sizeof(SENSOR_SHARE_BLOCK_DAT));
628 /* Set write size to shared memory */
629 share_dat->size = size_src;
631 /* Set specified data in shared memory */
632 memcpy(reinterpret_cast<void *>(&share_dat->data), data_src, (size_t)size_src);
636 /*******************************************************************************
638 * ABSTRACT : Message transmission processing
639 * FUNCTION : Send a message to the specified PNO
640 * ARGUMENT : pno_src : Source PNO
641 * : pno_dest : Destination PNO
643 * : msg_len : Message data body length
644 * : *msg_len : Pointer to message data
646 * RETURN : RET_NORMAL : Normal completion
647 * : RET_ERRNOTRDY : Destination process is not wakeup
648 * : RET_ERRMSGFULL : Message queue overflows
649 * : RET_ERRPARAM : Buffer size error
650 ******************************************************************************/
651 RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, uint16_t msg_len, const void *msg_data) {
652 SENSOR_INTERNAL_MSG_BUF msg_buf; /* message buffer */
653 T_APIMSG_MSGBUF_HEADER *msg_hdr; /* Pointer to the message header */
654 RET_API ret_api; /* Return value */
655 PCSTR thread_name; /* Destination thread name */
657 /* Internal debug log output */
658 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
660 /* _CWORD71_ processing speed(Memset modification) */
661 /* Initializing the header of the message buffer */
662 memset(reinterpret_cast<void *>(&msg_buf.hdr), 0, sizeof(T_APIMSG_MSGBUF_HEADER));
664 /* Get pointer to send buffer */
665 msg_hdr = reinterpret_cast<T_APIMSG_MSGBUF_HEADER *>(reinterpret_cast<void *>(&msg_buf));
667 /*--------------------------------------------------------------*
668 * Create message headers *
669 *--------------------------------------------------------------*/
670 msg_hdr->hdr.sndpno = pno_src; /* Source PNO */
671 msg_hdr->hdr.cid = cid; /* Command ID */
672 msg_hdr->hdr.msgbodysize = msg_len; /* Message data body length */
674 /*--------------------------------------------------------------*
675 * Create message data *
676 *--------------------------------------------------------------*/
677 if ((0 != msg_data) && (0 != msg_len)) { /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
678 /* Set the message data */
679 memcpy(reinterpret_cast<void *>(msg_buf.data), msg_data, (size_t)msg_len);
681 /*--------------------------------------------------------------*
683 *--------------------------------------------------------------*/
684 /* Get Thread Name from PNO */
685 if (pno_dest <= SYS_PNO_MAX) {
686 thread_name = POS_THREAD_NAME;
688 thread_name = _pb_CnvPno2Name(pno_dest);
691 if ((pno_dest <= SYS_PNO_MAX) && (pno_src <= SYS_PNO_MAX)) {
692 /* Internal debug log output */
693 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "[LOG pno_dest = 0x%x]", pno_dest);
695 /* Internal Process Transmission and Reception Messages */
696 ret_api = _pb_SndMsg(pno_dest,
697 (uint16_t)(sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len),/* Ignore->MISRA-C++:2008 Rule 5-0-5 */
698 reinterpret_cast<void *>(&msg_buf), 0);
700 /* Internal debug log output */
701 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__,
702 "[LOG thread_name = %s, cid = 0x%x]", thread_name, cid);
704 /* External Process Transmission and Reception Messages */
705 ret_api = _pb_SndMsg_Ext(thread_name,
707 (uint16_t)(msg_len), /* Ignore->MISRA-C++:2008 Rule 5-0-5 */
708 reinterpret_cast<void *>(&(msg_buf.data)), 0);
710 /* If RET_ERROR,Register a dialog if called from a Vehicle related thread */ /* Task_30332 */
711 if (ret_api == RET_ERROR) {
712 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "[ERROR]");
715 /* Internal debug log output */
716 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret_api);
723 * Sensor information acquisition
725 * Obtain sensor information
727 * @param[in] hApp HANDLE - Application handle
728 * @param[in] did DID - Data ID for vehicle information
729 * @param[in] dest_data void* - Pointer representing the storage destination of vehicle sensor information
730 * @param[in] dest_size uint16_t - Storage destination size of vehicle sensor information(byte)
732 * @return 0 or more Stored data size(Include illegal)<br>
733 * POS_RET_ERROR_CREATE_EVENT Event generation failure<br>
734 * POS_RET_ERROR_OUTOF_MEMORY Shared memory allocation failed<br>
735 * POS_RET_ERROR_SIZE Storage destination size error<br>
736 * POS_RET_ERROR_DID Unregistered ID<br>
737 * POS_RET_ERROR_NOSUPPORT Unsupported environment
740 POS_RET_API POS_GetSensData(HANDLE hApp, DID did, void *dest_data, uint16_t dest_size)
742 POS_RET_API ret; /* Return value */
743 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
747 if ((hApp == NULL) || (dest_data == NULL)) {
748 /** Parameter error */
749 ret = POS_RET_ERROR_PARAM;
751 /* Positioning Base API initialization */
752 _pb_Setup_CWORD64_API(hApp);
754 /* Supported HW Configuration Check */
755 type = GetEnvSupportInfo();
756 if (UNIT_TYPE_GRADE1 == type) {
758 ret = POS_RET_NORMAL;
759 } else if (UNIT_TYPE_GRADE2 == type) {
762 * This feature branches processing depending on the unit type.
764 ret = POS_RET_ERROR_NOSUPPORT;
766 /* Environment error */
767 ret = POS_RET_ERROR_NOSUPPORT;
771 if (ret == NAVIINFO_RET_NORMAL) {
773 ret_b = SENSOR_DID_JUDGE_GET(did);
774 if (ret_b == FALSE) {
775 /* An unacceptable ID is regarded as a parameter error. */
776 ret = POS_RET_ERROR_PARAM;
778 /* Data acquisition process */
779 ret = PosGetProc(did, dest_data, dest_size);