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.
19 * positioning_application.cpp
21 * Module : POSITIONING
22 * Implements Vehicle service functionality
25 /*---------------------------------------------------------------------------------*
27 *---------------------------------------------------------------------------------*/
28 #include <native_service/frameworkunified_application.h>
29 #include <native_service/frameworkunified_framework_if.h>
30 #include <native_service/frameworkunified_multithreading.h>
31 #include <native_service/frameworkunified_service_protocol.h>
32 #include <native_service/frameworkunified_types.h>
33 #include <native_service/ns_message_center_if.h>
34 #include <peripheral_service/ps_services.h>
35 #include <vehicle_service/POS_sensor_API.h>
36 #include <vehicle_service/POS_gps_API.h>
37 #include <system_service/ss_sm_client_if.h>
38 #include <vehicle_service/positioning_base_library.h>
39 #include <stub/vehicle_notifications.h>
40 #include <peripheral_service/communication_notifications.h>
41 #include <other_service/VP_GetEnv.h>
45 #include "SensorLog.h"
46 #include "positioning_common.h"
47 #include "POS_private.h"
48 #include "Gps_API_private.h"
49 #include "POS_common_private.h"
50 #include "Vehicle_API.h"
51 #include "Vehicle_API_private.h"
52 #include "Sensor_API_private.h"
53 #include "Naviinfo_API.h"
54 #include "VehicleSensor_Thread.h"
55 #include "ClockGPS_Process_Proto.h"
56 #include "VehicleSens_Common.h"
57 #include "VehicleSens_DataMaster.h"
58 #include "VehicleSens_DeliveryCtrl.h"
59 #include "VehicleUtility.h"
60 #include "BackupMgrIf.h"
62 #include "CommUsbIf.h"
63 #include "DevDetectSrvIf.h"
64 #include "DiagSrvIf.h"
65 #include "PSMShadowIf.h"
66 #include "VehicleIf.h"
67 #include "positioning_hal.h"
69 #include "CommonDefine.h"
71 #include "VehicleIf.h"
73 /*---------------------------------------------------------------------------------*
75 *---------------------------------------------------------------------------------*/
76 #define DATMOD_RETRY (3) /* Number of shared memory generation retries */
77 #define DATMOD_PREINIT (0) /* Shared Memory State Before Initialization */
78 #define PRIM_NAME_MAX (32) /* Maximum Name Size */
80 /* Mask for managing various notification reception conditions */
81 #define NTFY_MSK_NONE (0x00)
82 /* Service availability notification */
83 #define NTFY_MSK_COMMUNICATION_AVAILABILITY (0x01)
84 #define NTFY_MSK_PS_COMMUSB_AVAILABILITY (0x02)
85 #define NTFY_MSK_PS_PSMSHADOW_AVAILABILITY (0x04)
86 #define NTFY_MSK_CLOCK_AVAILABILITY (0x08)
87 #define NTFY_MSK_NS_BACKUPMGR_AVAILABILITY (0x10)
88 #define NTFY_MSK_SS_DEVDETSRV_AVAILABILITY (0x20)
89 #define NTFY_MSK_VS_VEHICLE_AVAILABILITY (0x40)
91 #define NTFY_MSK_PS_PSMSHADOW_INIT_COMP (0x01) /* PSMShadow startup completion notice */
94 #define THREAD_STS_NOEXIST (0x00)
95 #define THREAD_STS_CREATING (0x01)
96 #define THREAD_STS_CREATED (0x02)
98 #define POS_SNDMSG_DTSIZE_1 1 /* SndMSG data size 1Byte */
99 #define POS_SNDMSG_DTSIZE_2 2 /* SndMSG data size 2Byte */
100 #define POS_SNDMSG_DTSIZE_20 20 /* SndMSG data size of 20 bytes */
101 #define POS_SNDMSG_DTSIZE_132 132 /* SndMSG data size: 132 bytes */
103 /* PositioningLogFlag */
104 #define POSITIONINGLOG_FLAG_NAVI 9
106 /* Definition for thinning out sensor log at anomaly */
107 #define POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM 3
108 #define POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM 4
109 #define POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM 4
110 #define POSITIONINGLOG_SYS_4_ABNORMAL_DATA_NUM 129
111 #define POSITIONINGLOG_SYS_ABNORMAL_DATA_NUM (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + \
112 POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM + \
113 POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM + \
114 POSITIONINGLOG_SYS_4_ABNORMAL_DATA_NUM)
115 #define POSITIONINGLOG_SYS_1_ABNORMAL_DATA_OFFSET 11
116 #define POSITIONINGLOG_SYS_2_ABNORMAL_DATA_OFFSET 32
117 #define POSITIONINGLOG_SYS_3_ABNORMAL_DATA_OFFSET 54
118 #define POSITIONINGLOG_SYS_4_ABNORMAL_DATA_OFFSET 114
119 #define POSITIONINGLOG_SYS_1_ABNORMAL_SET_DATA_OFFSET 0
120 #define POSITIONINGLOG_SYS_2_ABNORMAL_SET_DATA_OFFSET POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM
121 #define POSITIONINGLOG_SYS_3_ABNORMAL_SET_DATA_OFFSET (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM)
122 #define POSITIONINGLOG_SYS_4_ABNORMAL_SET_DATA_OFFSET (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + \
123 POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM + \
124 POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM)
125 #define POSITIONINGLOG_SYS_OPC_OFFSET 9
126 #define POSITIONINGLOG_SYS_PULSE_TIME_NUM_OFFSET 114
127 #define POSITIONINGLOG_SYS_NORMAL_DATA 0xC1
128 #define POSITIONINGLOG_SYS_FST_DATA 0xF4
129 #define _pb_strcat(pdest, psrc, size) (strncat(pdest, psrc, size) , (0))
131 // Vehicle sensor information notification message
133 uint32_t did; // Data ID corresponding to vehicle sensor information
134 uint16_t size; // Data size of vehicle sensor information
135 uint8_t rcv_flag; // Vehicle sensor information reception flag
136 uint8_t reserve; // Reserved
137 uint8_t data[VEHICLE_VSINFO_DSIZE]; // Vehicle sensor information
138 } VEHICLE_UNIT_MSG_VSINFO_DAT;
140 // Vehicle sensor information notification message
142 VEHICLE_UNIT_MSG_VSINFO_DAT data; // Message data
143 } VEHICLE_UNIT_MSG_VSINFO;
144 /*---------------------------------------------------------------------------------*
146 *---------------------------------------------------------------------------------*/
148 @brief Structure to create shared data
151 char share_data_name[PRIM_NAME_MAX]; /**< Shared data name */
152 u_int32 data_size; /**< Shared data size */
156 @brief Thread management information
159 EnumTID_POS id; /**< Thread ID */
160 const int8_t* p_name; /**< Thread name */
161 PNO pno; /**< Process number */
162 CbFuncPtr routine; /**< Start Routine */
163 uint8_t msk_available; /**< Dependent services Availability */
164 uint8_t msk_ntfy; /**< Dependency notification */
165 uint8_t msk_thread; /**< Dependent threads */
166 BOOL is_depended; /**< Positioning/Availability->TRUE change dependency */
167 uint8_t status; /**< Thread activation state */
168 uint8_t order; /**< Boot Sequence(Performance) */
170 } ST_THREAD_CREATE_INFO;
173 /* GPS fix count information */
175 uint32_t ul3d; /* 3D */
176 uint32_t ul2d; /* 2D */
177 uint32_t ul_else; /* Not fix */
178 uint8_t dummy[4]; /* Dummy */
182 @brief Structure that stores the time set by the time setting or the time updated(For GRADE1)
185 u_int16 year; /* Year */
186 u_int8 month; /* Month */
187 u_int8 date; /* Day */
188 u_int8 hour; /* Hour */
189 u_int8 minute;/* Minutes */
190 u_int8 second;/* Minutes */
191 u_int8 flag; /* Whether or not the time is set */
194 /*---------------------------------------------------------------------------------*
195 * Local Function Prototype *
196 *---------------------------------------------------------------------------------*/
197 static EFrameworkunifiedStatus PositioningOnStartImpl(const HANDLE hApp, const EPWR_SC_WAKEUP_TYPE wakeupType,
198 const ESMDataResetModeInfo dataResetMode);
199 static EFrameworkunifiedStatus PosNotifyCommunicationAvailability(HANDLE h_app);
200 static EFrameworkunifiedStatus PosNotifyCommUSBAvailability(HANDLE h_app);
201 static EFrameworkunifiedStatus PosNotifyPSMShadowAvailability(HANDLE h_app);
202 static EFrameworkunifiedStatus PosNotifyPSMShadowInitComp(HANDLE h_app);
203 static EFrameworkunifiedStatus PosNotifyClockAvailability(HANDLE h_app);
204 static EFrameworkunifiedStatus PosNotifyNSBackupMgrAvailability(HANDLE h_app);
205 static EFrameworkunifiedStatus PosNotifyDevDetectSrvAvailability(HANDLE h_app);
206 static EFrameworkunifiedStatus PosNotifyVehicleAvailability(HANDLE h_app);
208 static EFrameworkunifiedStatus PosStopThreadDummy(HANDLE h_app);
209 static void PosCreateSharedMemory(void);
210 static void PosCreateThread(HANDLE h_app);
211 static void PosStopThread(void);
212 static void PosBackupDataInit(void);
214 /* Message Dispatching Functions */
215 static EFrameworkunifiedStatus PosThreadCreateComp(HANDLE h_app);
216 static EFrameworkunifiedStatus PosThreadStopComp(HANDLE h_app);
217 static EFrameworkunifiedStatus PosPosifRegisterListenerPkgSensorData(HANDLE h_app);
218 static EFrameworkunifiedStatus PosPosifRegisterListenerSensorData(HANDLE h_app);
219 static EFrameworkunifiedStatus PosPosifReqGpsSetting(HANDLE h_app);
220 static EFrameworkunifiedStatus PosPosifSetGpsInfo(HANDLE h_app);
221 static EFrameworkunifiedStatus PosPosifGetGpsInfo(HANDLE h_app);
222 static EFrameworkunifiedStatus PosPosifSetData(HANDLE h_app);
223 static EFrameworkunifiedStatus PosPosifReqGpsReset(HANDLE h_app);
224 static EFrameworkunifiedStatus PosVehicleInfoRcv(HANDLE h_app);
225 static uint32_t PosGetMsg(HANDLE h_app, void** p_buf, uint32_t size);
226 static RET_API PosSndMsg(PNO pno, CID cid, void* p_msg_body, uint32_t size);
227 static void PosOutputDebugDumpLog(uint8_t* p_buf);
229 /* Function scan for device insertion detection */
230 static EFrameworkunifiedStatus PosOnDevDetectOpenSessionAck(HANDLE h_app);
231 static EFrameworkunifiedStatus PosOnDevDetectCloseSessionAck(HANDLE h_app);
232 static EFrameworkunifiedStatus PosOnDevDetectEvent(HANDLE h_app);
234 /*---------------------------------------------------------------------------------*
236 *---------------------------------------------------------------------------------*/
238 static const int8_t kThreadNamePosMain[15] = "POS_Main";
239 static const int8_t kThreadNamePosSens[15] = "POS_Sens";
240 static const int8_t kThreadNamePosGps[15] = "POS_Gps";
241 static const int8_t kThreadNamePosGpsRecv[15] = "POS_Gps_Recv";
242 static const int8_t kThreadNamePosGpsRollover[15] = "POS_Gps_Rolovr";
244 /** Shared memory generation table */
245 static ST_SHAREDATA g_sharedata_tbl[] = {
246 /* Shared data name to be generated, Shared data size */
247 { {VEHICLE_SHARE_NAME}, 512 * 11 }, /* Vehicle sensor information acquisition */
248 #if 0 /* Less than 0.1 SBU,Not used in _CWORD71_ */
249 { {"SENSOR_SHARE_MEMORY"}, 512 * 11 }, /* Vehicle sensor information Pkg acquisition */
250 { {"GPS_INT_SIGNAL_SHARE_MEMORY"}, 4 }, /* GPS Interrupt Signal Acquisition */
251 { {"LOG_SETTING_SHARE_MEMORY"}, 36 }, /* DR feature log acquisition */
252 { {"GYRO_CONNECT_STTS_SHARE_MEMORY"}, 4 }, /* Get Gyro Connection Status */
253 { {"EPHEMERIS_NUM_SHARE_MEMORY"}, 4 }, /* For acquiring effective ephemeris count at shutdown */
254 { {"LOCALTIME_SHARE_MEMORY"}, 12 }, /* Local time acquisition at shutdown */
255 { {"LONLAT_SHARE_MEMORY"}, 8 }, /* Location acquisition at shutdown */
257 { {'\0'}, 0 } /* Termination */
260 /** Sub-thread creation table
261 (1) Thread ID (Locally defined Enumeration)
265 (5) Dependent Availability
266 (6) Dependency notification
267 (7) Dependent threads * If there are dependent threads, do not create them until those threads are created.
268 (8) Positioning/Availability->TRUE depending on change
269 (9) Thread activation state (THREAD_STS_NOEXIST:Not started,THREAD_STS_CREATING:Starting,THREAD_STS_CREATED:Completion of the activation)
270 (10) Boot Sequence(Performance) (0,1,2, ... Note : 0 = Initial value(Not started)) Time of termination,Be destroyed in the reverse order of startup
272 static ST_THREAD_CREATE_INFO g_pos_thread_create_info_Grade1[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
274 ETID_POS_MAIN, /* (1) */
275 kThreadNamePosMain, /* (2) */
276 PNO_VEHICLE_SENSOR, /* (3) */
277 &VehicleSensThread, /* (4) */
278 (NTFY_MSK_NONE), /* (5) */
279 (NTFY_MSK_NONE), /* (6) */
282 THREAD_STS_NOEXIST, /* (9) */
286 ETID_POS_SENS, /* (1) */
287 kThreadNamePosSens, /* (2) */
288 PNO_LINE_SENS_DRV, /* (3) */
289 &StartLineSensorThreadPositioning, /* (4) */
290 (NTFY_MSK_PS_PSMSHADOW_AVAILABILITY), /* (5) */
291 (NTFY_MSK_NONE), /* (6) */
292 THREAD_STS_MSK_POS_MAIN, /* (7) */
294 THREAD_STS_NOEXIST, /* (9) */
298 ETID_POS_GPS, /* (1) */
299 kThreadNamePosGps, /* (2) */
300 PNO_NAVI_GPS_MAIN, /* (3) */
301 &StartGpsMainThreadPositioning, /* (4) */
302 (NTFY_MSK_NONE), /* (5) */
303 (NTFY_MSK_NONE), /* (6) */
304 THREAD_STS_MSK_POS_MAIN, /* (7) */
306 THREAD_STS_NOEXIST, /* (9) */
310 ETID_POS_GPS_RECV, /* (1) */
311 kThreadNamePosGpsRecv, /* (2) */
312 PNO_NAVI_GPS_RCV, /* (3) */
313 &StartGpsRecvThreadPositioning, /* (4) */
314 (NTFY_MSK_NONE), /* (5) */
315 (NTFY_MSK_NONE), /* (6) */
316 THREAD_STS_MSK_POS_GPS, /* (7) */
318 THREAD_STS_NOEXIST, /* (9) */
321 { /* Pos_gps_rollover */
322 ETID_POS_GPS_ROLLOVER, /* (1) */
323 kThreadNamePosGpsRollover, /* (2) */
324 PNO_CLK_GPS, /* (3) */
325 &StartGpsRolloverThreadPositioning, /* (4) */
326 (NTFY_MSK_NS_BACKUPMGR_AVAILABILITY), /* (5) */
327 (NTFY_MSK_NONE), /* (6) */
328 THREAD_STS_MSK_POS_GPS, /* (7) */
330 THREAD_STS_NOEXIST, /* (9) */
334 ETID_POS_MAX, NULL, 0, NULL, NTFY_MSK_NONE, NTFY_MSK_NONE, 0, FALSE, THREAD_STS_NOEXIST, 0
338 /* State Management Variables */
339 static bool g_start_flg = false; /** Start Processed Flag */
340 static EnumExeSts_POS g_exe_sts; /** Positioning running status */
341 static EnumSetupMode_POS g_setup_mode; /** Thread activation mode */
342 static uint8_t g_last_thread_sts; /** Latest internal thread activation state */
343 static uint8_t g_last_srv_sts; /** Latest service availability */
344 static uint8_t g_last_ntfy_sts; /** Receive state of latest notification */
345 static uint8_t g_last_num_of_thread; /** Number of Current Startup Threads */
347 /** Sub-thread creation table */
348 static ST_THREAD_CREATE_INFO* g_pos_thread_create_info;
350 /** Interprocess message receive buffer */
351 static uint8_t g_rcv_msg_buf[MAX_MSG_BUF_SIZE];
353 /** Dispatcher Registration Callback Table */
354 static const FrameworkunifiedProtocolCallbackHandler kPositioningPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
355 {CID_THREAD_CREATE_COMP, &PosThreadCreateComp }, /* Thread start completion notification */
356 {CID_THREAD_STOP_COMP, &PosThreadStopComp }, /* Thread stop completion notice */
357 {CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT, &PosPosifRegisterListenerPkgSensorData},
358 {CID_VEHICLEIF_DELIVERY_ENTRY, &PosPosifRegisterListenerSensorData },
359 {CID_SENSORIF__CWORD82__REQUEST, &PosPosifReqGpsSetting },
360 {CID_NAVIINFO_DELIVER, &PosPosifSetGpsInfo },
361 {CID_VEHICLEIF_GET_VEHICLE_DATA, &PosPosifGetGpsInfo },
362 {CID_POSIF_SET_DATA, &PosPosifSetData },
363 {CID_GPS_REQRESET, &PosPosifReqGpsReset },
366 static const FrameworkunifiedProtocolCallbackHandler kPositioningPcbhsVehicle[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
367 {CID_VEHICLESENS_VEHICLE_INFO, &PosVehicleInfoRcv},
370 /** Dispatcher unregister command ID table */
371 static uint32_t g_positioning_cids[] = {
372 CID_THREAD_CREATE_COMP,
373 CID_THREAD_STOP_COMP,
374 CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT,
375 CID_VEHICLEIF_DELIVERY_ENTRY,
376 CID_SENSORIF__CWORD82__REQUEST,
377 CID_NAVIINFO_DELIVER,
378 CID_VEHICLEIF_GET_VEHICLE_DATA,
383 static uint32_t g_positioning_cids_vehicle[] = {
384 CID_VEHICLESENS_VEHICLE_INFO,
389 /** Stop request flag for GPS reception thread */
390 BOOL g_thread_stop_req;
392 /*---------------------------------------------------------------------------------*
394 *---------------------------------------------------------------------------------*/
397 * FrameworkunifiedOnInitialization<br>
398 * Sends message to Notification Service
400 * Mm 21 API perform initialization.<br>
401 * Generatings shared memories used by Vehicle function block..<br>
402 * Creates a sub-thread of the Vehicle feature block..
404 * @param[in] h_app Application handle
406 * @return eFrameworkunifiedStatusOK Normal completion
407 * eFrameworkunifiedStatusFail ABENDs
409 EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
411 EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
412 uint8_t* p_last_srv_sts = &g_last_srv_sts;
413 uint8_t* p_last_thread_sts = &g_last_thread_sts;
414 uint8_t* p_last_ntfy_sts = &g_last_ntfy_sts;
415 ST_THREAD_CREATE_INFO** pp_thr_cre_info = &g_pos_thread_create_info;
416 uint8_t* p_last_num_thr = &g_last_num_of_thread;
417 BOOL* p_thr_stop_req = &g_thread_stop_req;
418 EnumExeSts_POS* p_exe_sts = &g_exe_sts;
419 EnumSetupMode_POS* pe_mode = &g_setup_mode;
421 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
423 /* Global variable initialization */
425 *p_last_thread_sts = 0;
426 *p_last_ntfy_sts = 0;
427 *pp_thr_cre_info = g_pos_thread_create_info_Grade1;
429 *p_thr_stop_req = FALSE;
430 *p_exe_sts = EPOS_EXE_STS_STOP;
431 *pe_mode = EPOS_SETUP_MODE_NORMAL;
434 if (h_app == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
435 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "h_app is NULL");
436 e_status = eFrameworkunifiedStatusFail;
438 /* Positioning Base API initialization */
439 ret_api = _pb_Setup_CWORD64_API(h_app);
440 if (ret_api != RET_NORMAL) { // LCOV_EXCL_BR_LINE 4: can not return error
441 // LCOV_EXCL_START 8: invalid
442 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
443 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
444 "_pb_Setup_CWORD64_API ERROR!! [ret_api = %d]",
447 e_status = eFrameworkunifiedStatusFail;
450 /* Availability at Positioning startup,Set internal thread activation state */
451 if (ChkUnitType(UNIT_TYPE_GRADE1) == true) { /* GRADE1 environment */
452 *pp_thr_cre_info = g_pos_thread_create_info_Grade1;
453 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__,
454 "*pp_thr_cre_info = g_pos_thread_create_info_Grade1");
455 } else if (ChkUnitType(UNIT_TYPE_GRADE2) == true) {
458 * This feature branches processing depending on the unit type.
461 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "_pb_ChkUnitType UNKNOWN!!");
464 /* Shared Memory Creation */
465 PosCreateSharedMemory();
467 if (e_status == eFrameworkunifiedStatusOK) {
468 /* Register callback functions for Positioning internals */
469 e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app,
472 _countof(kPositioningPcbhs)); // LCOV_EXCL_BR_LINE 4:nsfw error
473 if (e_status != eFrameworkunifiedStatusOK) {
474 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
475 "FrameworkunifiedAttachCallbacksToDispatcher ERROR!! [e_status = %d]", e_status);
478 (void)VehicleIfAttachCallbacksToDispatcher(kPositioningPcbhsVehicle,
479 _countof(kPositioningPcbhsVehicle));
482 if (e_status == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
483 /* Positioning/Availability registration */
484 e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, POS_AVAILABILITY);
485 if (eFrameworkunifiedStatusOK != e_status) {
486 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
487 "FrameworkunifiedRegisterServiceAvailabilityNotification ERROR!! [e_status = %d]", e_status);
491 if (e_status == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
492 /* Positioning/Availability -> FALSE */
493 e_status = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
494 if (eFrameworkunifiedStatusOK != e_status) {
495 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
496 "FrameworkunifiedPublishServiceAvailability ERROR!! [e_status = %d]", e_status);
498 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> FALSE");
502 /* Communication/Availability Changing notification registration */
503 FrameworkunifiedSubscribeNotificationWithCallback(h_app, NTFY_Communication_Availability, &PosNotifyCommunicationAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
505 /* PS_CommUSB/Availability Changing notification registration */
506 (void)CommUsbIfNotifyOnCommUSBAvailability(&PosNotifyCommUSBAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
508 /* PS_PSMShadow/Availability Changing notification registration */
509 (void)PSMShadowIfNotifyOnPSMShadowAvailability(&PosNotifyPSMShadowAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
510 /* PS_PSMShadow Startup completion notification registration */
511 (void)PSMShadowIfNotifyOnPSMShadowInitComp(&PosNotifyPSMShadowInitComp); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
513 /* Clock/Availability Changing notification registration */
514 (void)ClockIfNotifyOnClockAvailability(&PosNotifyClockAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
516 /* NS_BackupMgr/Availability Changing notification registration */
517 (void)BackupMgrIfNotifyOnBackupMgrAvailability(&PosNotifyNSBackupMgrAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
519 /* Regist Vehilce Availability Notification */
520 (void)VehicleIfNotifyOnVehicleAvailability(&PosNotifyVehicleAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
522 /* DeviceDetectionServiceIf initialization */
523 if (DevDetectSrvIfInitialize() == eFrameworkunifiedStatusOK) {
524 /* SS_DevDetectSrv/Availability Changing notification registration */
525 (void)DevDetectSrvIfNotifyOnDeviceDetectionAvailability(&PosNotifyDevDetectSrvAvailability); // LCOV_EXCL_BR_LINE 6: not a branch // NOLINT(whitespace/line_length)
530 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
537 * PositioningOnStartImpl
539 static EFrameworkunifiedStatus PositioningOnStartImpl(const HANDLE hApp, const EPWR_SC_WAKEUP_TYPE wakeupType,
540 const ESMDataResetModeInfo dataResetMode) {
541 EnumExeSts_POS* p_exe_sts = &g_exe_sts;
542 EnumSetupMode_POS* pe_mode = &g_setup_mode;
544 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
546 if (g_start_flg == false) {
550 *p_exe_sts = EPOS_EXE_STS_RUNNING;
553 if (wakeupType == epsstCOLDSTART) {
554 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "wakeupType:COLDSTART");
556 *p_exe_sts = EPOS_EXE_STS_RUNNING_COLDSTART;
558 /* Initialize GPS time setting information */
560 } else { /* Time of warm start */
561 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "wakeupType:WARMSTART");
564 /* Time of factory initialization */
565 if (dataResetMode == e_SS_SM_DATA_RESET_MODE_FACTORY) {
566 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "dataResetMode:FACTORYRESET");
568 /* Set thread start mode to ""data reset start"" */
569 *pe_mode = EPOS_SETUP_MODE_DATA_RESET;
571 /* Initialize GPS time setting information */
575 PosCreateThread(hApp);
578 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
579 return eFrameworkunifiedStatusOK;
584 * FrameworkunifiedOnStart
586 EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
587 EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
590 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
592 size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
594 T_SS_SM_START_DataStructType* p_start_data;
595 p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);
597 ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
600 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
606 * FrameworkunifiedOnStop
608 * @param[in] h_app Application handle
610 * @return eFrameworkunifiedStatusOK Normal completion
611 * eFrameworkunifiedStatusFail ABENDs
613 EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
614 EFrameworkunifiedStatus e_status;
615 EnumExeSts_POS* p_exe_sts = &g_exe_sts;
617 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
620 if (h_app == NULL) { // LCOV_EXCL_BR_LINE 200: can not NULL
621 // LCOV_EXCL_START 8: invalid
622 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
623 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "h_app is NULL");
626 *p_exe_sts = EPOS_EXE_STS_STOP;
628 e_status = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
629 if (eFrameworkunifiedStatusOK != e_status) {
630 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
631 "FrameworkunifiedPublishServiceAvailability ERROR!! [e_status = %d]",
634 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> FALSE");
642 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
644 /* Return end response to SM at timing after completion of internal thread stop */
645 return eFrameworkunifiedStatusFail;
650 * FrameworkunifiedOnPreStart
652 EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
653 EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
656 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
658 size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
660 T_SS_SM_START_DataStructType* p_start_data;
661 p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);
663 ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
666 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
672 * FrameworkunifiedOnPreStop
674 EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
675 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
676 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
677 return eFrameworkunifiedStatusOK;
682 * FrameworkunifiedOnBackgroundStart
684 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
685 EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
688 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
690 size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
692 T_SS_SM_START_DataStructType* p_start_data;
693 p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);
695 ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
698 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
704 * FrameworkunifiedOnBackgroundStop
706 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
707 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
708 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
709 return eFrameworkunifiedStatusOK;
714 * FrameworkunifiedOnDestroy (Not mounted)
716 * @param[in] h_app Application handle
718 * @return eFrameworkunifiedStatusOK Normal completion
719 * eFrameworkunifiedStatusFail ABENDs
721 EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) { // LCOV_EXCL_START 14 Resident process, not called by NSFW
722 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
723 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
724 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
725 return eFrameworkunifiedStatusOK;
731 * FrameworkunifiedOnDebugDump
733 * @param[in] h_app Application handle
735 * @return eFrameworkunifiedStatusOK Normal completion
736 * eFrameworkunifiedStatusFail ABENDs
738 EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7: debug code
739 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
740 static uint8_t buf_tmp[256];
741 static uint8_t buf_proc[128];
742 static uint8_t buf_thread[512];
743 static uint8_t buf_message[4][DEBUG_DUMP_MAX_SIZE];
744 static uint8_t buf_mutex[3][DEBUG_DUMP_MAX_SIZE];
745 static uint8_t buf_timer[DEBUG_DUMP_MAX_SIZE];
746 static uint8_t buf_event[9][DEBUG_DUMP_MAX_SIZE];
747 static uint8_t buf_memory[DEBUG_DUMP_MAX_SIZE];
748 static uint8_t buf_other[DEBUG_DUMP_MAX_SIZE];
749 static uint8_t buf_nand[256];
750 static uint8_t buf_ram[256];
751 static uint8_t buf_gps_format_fail[512];
752 static uint8_t buf_antenna[256];
753 static uint8_t buf_gps_info[DEBUG_DUMP_MAX_SIZE];
754 static uint8_t buf_navi_info[DEBUG_DUMP_MAX_SIZE];
755 static uint8_t buf_deli_ctrl_tbl[DEBUG_DUMP_MAX_SIZE];
756 static uint8_t buf_deli_ctrl_tbl_mng[DEBUG_DUMP_MAX_SIZE];
757 static uint8_t buf_pkg_deli_tbl_mng[DEBUG_DUMP_MAX_SIZE];
758 static uint8_t buf_deli_pno_tbl[DEBUG_DUMP_MAX_SIZE];
759 static uint8_t buf_sys[128];
761 ST_THREAD_CREATE_INFO* p_thr_cre_info = g_pos_thread_create_info;
762 ST_GPS_FIX_CNT st_gps_fix_cnt;
763 ST_GPS_SET_TIME st_gps_set_time;
767 EFrameworkunifiedStatus e_status;
769 UNIT_TYPE e_type = UNIT_TYPE_NONE;
771 uint16_t wkn_rollover;
773 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
775 memset(&buf_proc[0], 0x00, sizeof(buf_proc));
776 memset(&buf_thread[0], 0x00, sizeof(buf_thread));
777 memset(&buf_nand[0], 0x00, sizeof(buf_nand));
778 memset(&buf_ram[0], 0x00, sizeof(buf_ram));
779 memset(&buf_gps_format_fail[0], 0x00, sizeof(buf_gps_format_fail));
780 memset(&buf_antenna[0], 0x00, sizeof(buf_antenna));
781 memset(&buf_gps_info[0], 0x00, sizeof(buf_gps_info));
782 memset(&buf_navi_info[0], 0x00, sizeof(buf_navi_info));
783 memset(&buf_deli_ctrl_tbl[0], 0x00, sizeof(buf_deli_ctrl_tbl));
784 memset(&buf_deli_ctrl_tbl_mng[0], 0x00, sizeof(buf_deli_ctrl_tbl_mng));
785 memset(&buf_pkg_deli_tbl_mng[0], 0x00, sizeof(buf_pkg_deli_tbl_mng));
786 memset(&buf_deli_pno_tbl[0], 0x00, sizeof(buf_deli_pno_tbl));
787 memset(&buf_sys[0], 0x00, sizeof(buf_sys));
789 for (i = 0; i < len_msg; i++) {
790 memset(&buf_message[i][0], 0x00, sizeof(buf_message[i]));
792 for (i = 0; i < len_mtx; i++) {
793 memset(&buf_mutex[i][0], 0x00, sizeof(buf_mutex[i]));
795 memset(&buf_timer[0], 0x00, sizeof(buf_timer));
796 for (i = 0; i < len_evt; i++) {
797 memset(&buf_event[i][0], 0x00, sizeof(buf_event[i]));
799 memset(&buf_memory[0], 0x00, sizeof(buf_memory));
800 memset(&buf_other[0], 0x00, sizeof(buf_other));
801 e_type = GetEnvSupportInfo();
803 /* Availability status of related processes */
804 snprintf(reinterpret_cast<char *>(&buf_proc[0]), sizeof(buf_proc),
805 "Availability\n thread:0x%02x, srv:0x%02x, ntfy:0x%02x",
806 g_last_thread_sts, /* Latest internal thread activation state */
807 g_last_srv_sts, /* Latest service availability */
808 g_last_ntfy_sts); /* Receive state of latest notification */
810 /* Internal thread activation state */
811 snprintf(reinterpret_cast<char *>(&buf_thread[0]), sizeof(buf_thread), "Thread");
812 for (i = 0; i < ETID_POS_MAX; i++) {
813 memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
814 snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
815 "\n [%d]id:%d, pno:0x%04x, name:%16s, sts:0x%02x, order:%d",
817 p_thr_cre_info->id, /* Thread ID */
818 p_thr_cre_info->pno, /* Process number */
819 p_thr_cre_info->p_name, /* Thread name */
820 p_thr_cre_info->status, /* Thread activation state */
821 p_thr_cre_info->order); /* Boot Sequence */
822 _pb_strcat(reinterpret_cast<char *>(&buf_thread[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));
826 /* BASE API control data */
828 (void)_pb_GetDebugMsgMngTbl(&buf_message[0][0], &len_msg);
830 (void)_pb_GetDebugMutexMngTbl(&buf_mutex[0][0], &len_mtx);
832 (void)_pb_GetDebugTimerMngTbl(&buf_timer[0]);
834 (void)_pb_GetDebugEventMngTbl(&buf_event[0][0], &len_evt);
836 (void)_pb_GetDebugMemoryMngTbl(&buf_memory[0]);
838 (void)_pb_GetDebugOtherMngTbl(&buf_other[0]);
841 snprintf(reinterpret_cast<char *>(&buf_nand[0]), sizeof(buf_nand), "NAND");
843 memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
844 memset(&st_gps_fix_cnt, 0x00, sizeof(st_gps_fix_cnt));
846 e_status = BackupMgrIfBackupDataRd(D_BK_ID_POS_GPS_FIX_CNT,
849 sizeof(st_gps_fix_cnt), &b_is_available);
850 snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
851 "\n %20s rd:0x%08x av:%d, 3d:%d, 2d:%d, else:%d, dmy:0x%02x%02x%02x%02x",
857 st_gps_fix_cnt.ul_else,
858 st_gps_fix_cnt.dummy[0], st_gps_fix_cnt.dummy[1], st_gps_fix_cnt.dummy[2], st_gps_fix_cnt.dummy[3]);
859 _pb_strcat(reinterpret_cast<char *>(&buf_nand[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));
861 /* Data of the backup RAM */
862 snprintf(reinterpret_cast<char *>(&buf_ram[0]), sizeof(buf_ram), "BackupRAM");
863 /* Set GPS date and time(Information) */
864 memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
865 (void)memset( reinterpret_cast<void *>(&st_gps_set_time), 0, (size_t)sizeof(st_gps_set_time) );
867 e_status = BackupMgrIfBackupDataRd(D_BK_ID_POS_GPS_TIME_SET_INFO,
870 sizeof(st_gps_set_time),
872 snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
873 "\n %20s rd:0x%08x av:%d, %d/%d/%d %d:%d:%d flag:0x%02x",
877 st_gps_set_time.year,
878 st_gps_set_time.month,
879 st_gps_set_time.date,
880 st_gps_set_time.hour,
881 st_gps_set_time.minute,
882 st_gps_set_time.second,
883 st_gps_set_time.flag);
884 _pb_strcat(reinterpret_cast<char *>(&buf_ram[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));
886 if (e_type == UNIT_TYPE_GRADE1) {
887 /* GPS format anomaly counter */ /* There is no lock control. */
888 (void)DEVGpsGetDebugGpsFormatFailCnt(&buf_gps_format_fail[0]);
890 /* GPS antenna connection status */ /* There is no lock control. */
891 VEHICLESENS_DATA_MASTER st_sns_data = {0};
892 (void)VehicleSensGetGpsAntenna(&st_sns_data, VEHICLESENS_GETMETHOD_LINE);
893 snprintf(reinterpret_cast<char *>(&buf_antenna[0]), sizeof(buf_antenna),
894 "Antenna\n sts:0x%02x",
895 st_sns_data.uc_data[0]);
897 /* GPS position time */ /* There is no lock control. */
898 (void)VehicleSensGetDebugPosDate(&buf_gps_info[0], VEHICLESENS_GETMETHOD_GPS);
901 if (e_type == UNIT_TYPE_GRADE1) {
902 /* Navigation position time */ /* There is no lock control. */
903 (void)VehicleSensGetDebugPosDate(&buf_navi_info[0], VEHICLESENS_GETMETHOD_NAVI);
906 /* Delivery table */ /* There is no lock control. */
907 (void)VehicleSensGetDebugDeliveryCtrlTbl(&buf_deli_ctrl_tbl[0]);
908 (void)VehicleSensGetDebugDeliveryCtrlTblMng(&buf_deli_ctrl_tbl_mng[0]);
909 (void)VehicleSensGetDebugPkgDeliveryTblMng(&buf_pkg_deli_tbl_mng[0]);
910 (void)VehicleSensGetDebugDeliveryPnoTbl(&buf_deli_pno_tbl[0]);
912 /* Initial Sensor Data Status from Sys */
913 sys_recv_flg = LineSensDrvGetSysRecvFlag();
914 snprintf(reinterpret_cast<char *>(&buf_sys[0]), sizeof(buf_sys),
915 "Rx 1st Sensor Data %d\n", sys_recv_flg);
917 /* Dump Information Out */
918 PosOutputDebugDumpLog(&buf_proc[0]);
919 PosOutputDebugDumpLog(&buf_thread[0]);
920 for (i = 0; i < len_msg; i++) {
921 PosOutputDebugDumpLog(&buf_message[i][0]);
923 for (i = 0; i < len_mtx; i++) {
924 PosOutputDebugDumpLog(&buf_mutex[i][0]);
926 PosOutputDebugDumpLog(&buf_timer[0]);
927 for (i = 0; i < len_evt; i++) {
928 PosOutputDebugDumpLog(&buf_event[i][0]);
930 PosOutputDebugDumpLog(&buf_memory[0]);
931 PosOutputDebugDumpLog(&buf_other[0]);
932 PosOutputDebugDumpLog(&buf_nand[0]);
933 PosOutputDebugDumpLog(&buf_ram[0]);
934 if (e_type == UNIT_TYPE_GRADE1) {
935 PosOutputDebugDumpLog(&buf_gps_format_fail[0]);
936 PosOutputDebugDumpLog(&buf_antenna[0]);
937 PosOutputDebugDumpLog(&buf_gps_info[0]);
939 if (e_type == UNIT_TYPE_GRADE1) {
940 PosOutputDebugDumpLog(&buf_navi_info[0]);
942 PosOutputDebugDumpLog(&buf_deli_ctrl_tbl[0]);
943 PosOutputDebugDumpLog(&buf_deli_ctrl_tbl_mng[0]);
944 PosOutputDebugDumpLog(&buf_pkg_deli_tbl_mng[0]);
945 PosOutputDebugDumpLog(&buf_deli_pno_tbl[0]);
946 PosOutputDebugDumpLog(&buf_sys[0]);
948 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
949 return eFrameworkunifiedStatusOK;
955 * FrameworkunifiedCreateStateMachine (Not mounted)
957 * @param[in] h_app Application handle
959 * @return eFrameworkunifiedStatusOK Normal completion
960 * eFrameworkunifiedStatusFail ABENDs
962 EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) { // LCOV_EXCL_START 8 : dead code
963 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
964 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
965 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
966 return eFrameworkunifiedStatusOK;
975 * Common processing after thread startup
977 * Thread naming,Create Message Queue,Thread activation response
979 * @param[in] h_app Application handle
980 * @param[in] e_tid Thread ID
982 * @return Thread activation mode
984 EnumSetupMode_POS PosSetupThread(HANDLE h_app, EnumTID_POS e_tid) {
986 ST_THREAD_CREATE_INFO* p_thr_cre_info = g_pos_thread_create_info;
987 ST_THREAD_CREATE_INFO* p_info;
988 ST_THREAD_SETUP_INFO st_setup_info;
989 ST_THREAD_SETUP_INFO* pst_setup_info = &st_setup_info;
991 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
993 p_info = p_thr_cre_info + e_tid;
995 /* Application handle setting */
996 _pb_SetAppHandle(h_app);
998 /* Create Message Queue */
999 _pb_CreateMsg(p_info->pno);
1001 /* Get Thread Startup Information */
1002 pst_setup_info->e_mode = EPOS_SETUP_MODE_NORMAL;
1003 (void)PosGetMsg(h_app, reinterpret_cast<void**>(&pst_setup_info), sizeof(ST_THREAD_SETUP_INFO));
1004 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "[e_mode = %d]", pst_setup_info->e_mode);
1006 /* Issue thread creation completion notice */
1007 ret = _pb_SndMsg_Ext(POS_THREAD_NAME, CID_THREAD_CREATE_COMP, sizeof(EnumTID_POS), (const void*)&e_tid, 0);
1008 if (ret != RET_NORMAL) {
1009 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg_Ext ERROR!! [ret = %d]", ret);
1012 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1014 return pst_setup_info->e_mode;
1019 * Common Processing at Thread Stop
1021 * Thread stop response,Thread destruction
1023 * @param[in] e_tid Thread ID
1025 void PosTeardownThread(EnumTID_POS e_tid) {
1028 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1030 /* Issue thread stop completion notice */
1031 ret = _pb_SndMsg_Ext(POS_THREAD_NAME, CID_THREAD_STOP_COMP, sizeof(EnumTID_POS), (const void*)&e_tid, 0);
1032 if (ret != RET_NORMAL) {
1033 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg_Ext ERROR!! [ret = %d]", ret);
1036 /* Thread destruction */
1037 _pb_ExitThread((DWORD)0);
1039 /* don't arrive here */
1040 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1042 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1043 return; // LCOV_EXCL_LINE 8 : cannot reach here
1052 * FrameworkunifiedCreateChildThread dummy functions
1054 * @param[in] Application handle
1056 * @return eFrameworkunifiedStatusOK successful completion
1058 static EFrameworkunifiedStatus PosStopThreadDummy(HANDLE h_app) { // LCOV_EXCL_START 8 : dead code
1059 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1060 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1061 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1062 return eFrameworkunifiedStatusOK;
1066 /*---------------------------------------------------------------------------------*
1068 *---------------------------------------------------------------------------------*/
1071 * Communication services Availability notification callback functions
1073 * @param[in] h_app Application handle
1075 * @return eFrameworkunifiedStatusOK Normal completion
1077 static EFrameworkunifiedStatus PosNotifyCommunicationAvailability(HANDLE h_app) {
1079 uint8_t* pLastSrvSts = &g_last_srv_sts;
1081 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1083 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1084 if (isAvailable == TRUE) { // LCOV_EXCL_BR_LINE 4: nsfw error
1085 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Communication/Availability -> TRUE");
1087 *pLastSrvSts |= NTFY_MSK_COMMUNICATION_AVAILABILITY;
1089 PosCreateThread(h_app);
1091 /* Sensor Log Initial Processing(First)*/
1092 SensLogInitialize(NULL);
1094 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Communication/Availability -> FALSE");
1096 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_COMMUNICATION_AVAILABILITY);
1099 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1101 return eFrameworkunifiedStatusOK;
1106 * CommUSB services Availability notification callback functions
1108 * @param[in] h_app Application handle
1110 * @return eFrameworkunifiedStatusOK Normal completion
1112 static EFrameworkunifiedStatus PosNotifyCommUSBAvailability(HANDLE h_app) {
1114 uint8_t* pLastSrvSts = &g_last_srv_sts;
1116 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1118 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1119 if (isAvailable == TRUE) {
1120 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_CommUSB/Availability -> TRUE");
1122 *pLastSrvSts |= NTFY_MSK_PS_COMMUSB_AVAILABILITY;
1124 PosCreateThread(h_app);
1126 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_CommUSB/Availability -> FALSE");
1128 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_PS_COMMUSB_AVAILABILITY);
1131 /* Update CommUSB I/F availability */
1132 CommUsbIfSetAvailability(isAvailable);
1134 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1136 return eFrameworkunifiedStatusOK;
1141 * PSMShadow services Availability notification callback functions
1143 * @param[in] h_app Application handle
1145 * @return eFrameworkunifiedStatusOK Normal completion
1147 static EFrameworkunifiedStatus PosNotifyPSMShadowAvailability(HANDLE h_app) {
1149 uint8_t* pLastSrvSts = &g_last_srv_sts;
1151 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1153 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1154 if (isAvailable == TRUE) {
1155 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_PSMShadow/Availability -> TRUE");
1157 *pLastSrvSts |= NTFY_MSK_PS_PSMSHADOW_AVAILABILITY;
1159 PosCreateThread(h_app);
1161 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_PSMShadow/Availability -> FALSE");
1163 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_PS_PSMSHADOW_AVAILABILITY);
1166 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1168 return eFrameworkunifiedStatusOK;
1173 * PSMShadow services Callback function for notifying completion of startup
1175 * @param[in] h_app Application handle
1177 * @return eFrameworkunifiedStatusOK Normal completion
1179 static EFrameworkunifiedStatus PosNotifyPSMShadowInitComp(HANDLE h_app) {
1180 uint8_t* pLastNtfySts = &g_last_ntfy_sts;
1181 ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
1183 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1185 *pLastNtfySts |= NTFY_MSK_PS_PSMSHADOW_INIT_COMP;
1187 /* When the Pos_Sens thread is started */
1188 if (((pThrCreInfo + ETID_POS_SENS)->status) == THREAD_STS_CREATED) {
1189 /* External pin status request */
1190 LineSensDrvExtTermStsReq();
1193 PosCreateThread(h_app);
1195 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1197 return eFrameworkunifiedStatusOK;
1202 * Clock Services Availability Notification Callback Functions
1204 * @param[in] h_app Application handle
1206 * @return eFrameworkunifiedStatusOK successful completion
1208 static EFrameworkunifiedStatus PosNotifyClockAvailability(HANDLE h_app) {
1210 uint8_t* pLastSrvSts = &g_last_srv_sts;
1212 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1214 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1215 if (isAvailable == TRUE) {
1216 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Clock/Availability -> TRUE");
1218 *pLastSrvSts |= NTFY_MSK_CLOCK_AVAILABILITY;
1220 PosCreateThread(h_app);
1222 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Clock/Availability -> FALSE");
1224 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_CLOCK_AVAILABILITY);
1227 /* Update Clock I/F availability */
1228 ClockIfSetAvailability(isAvailable);
1230 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1232 return eFrameworkunifiedStatusOK;
1237 * NS_BackupMgr service Availability notification callback function
1239 * @param[in] h_app Application handle
1241 * @return eFrameworkunifiedStatusOK successful completion
1243 static EFrameworkunifiedStatus PosNotifyNSBackupMgrAvailability(HANDLE h_app) {
1244 EnumExeSts_POS* pExeSts = &g_exe_sts;
1245 uint8_t* pLastSrvSts = &g_last_srv_sts;
1246 ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
1247 EnumSetupMode_POS* peMode = &g_setup_mode;
1250 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1252 bIsAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1254 /* Update BackupMgr I/F availability */
1255 BackupMgrIfSetAvailability(bIsAvailable);
1257 if (bIsAvailable == TRUE) {
1258 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "NS_BackupMgr/Availability -> TRUE");
1260 *pLastSrvSts |= NTFY_MSK_NS_BACKUPMGR_AVAILABILITY;
1262 /* Executing after cold start or during factory initialization*/
1263 if ((*pExeSts == EPOS_EXE_STS_RUNNING_COLDSTART) ||
1264 (*peMode == EPOS_SETUP_MODE_DATA_RESET)) {
1265 /* Backup RAM initialization */
1266 PosBackupDataInit();
1269 /* When the GPS management thread is started */
1270 if (((pThrCreInfo + ETID_POS_GPS)->status) == THREAD_STS_CREATED) {
1271 if ((*pExeSts == EPOS_EXE_STS_RUNNING_COLDSTART) ||
1272 (*peMode == EPOS_SETUP_MODE_DATA_RESET)) {
1273 // GPS reset request.
1274 SENSOR_INTERNAL_MSG_BUF msg_buf = {};
1275 T_APIMSG_MSGBUF_HEADER *msg_hdr = &msg_buf.hdr;
1276 msg_hdr->hdr.cid = CID_GPS_REQRESET;
1277 msg_hdr->hdr.msgbodysize = sizeof(POS_RESETINFO);
1278 POS_RESETINFO *msg_data = reinterpret_cast<POS_RESETINFO *>(&msg_buf.data);
1279 msg_data->mode = GPS_RST_COLDSTART;
1281 RET_API ret = _pb_SndMsg(PNO_NAVI_GPS_MAIN, sizeof(msg_buf), &msg_buf, 0);
1282 if (ret != RET_NORMAL) {
1283 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "_pb_SndMsg ERROR!! [ret=%d]", ret);
1287 /* Backup data read request to GSP management thread */
1288 (void)DEVGpsSndBackupDataLoadReq();
1290 /* Enable Diag Code Writing */
1291 DiagSrvIfSetRegistrationPermission(TRUE);
1293 PosCreateThread(h_app);
1295 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "NS_BackupMgr/Availability -> FALSE");
1297 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_NS_BACKUPMGR_AVAILABILITY);
1298 /* Write prohibited dialog code */
1299 DiagSrvIfSetRegistrationPermission(FALSE);
1302 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1304 return eFrameworkunifiedStatusOK;
1309 * SS_DevDetectSrv service Availability Callback Functions
1311 * @param[in] h_app Application handle
1313 * @return eFrameworkunifiedStatusOK successful completion
1315 static EFrameworkunifiedStatus PosNotifyDevDetectSrvAvailability(HANDLE h_app) {
1316 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1319 uint8_t* pLastSrvSts = &g_last_srv_sts;
1321 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1323 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1325 /* Update DevDetectSrv I/F availability */
1326 DevDetectSrvIfSetAvailability(isAvailable);
1328 if (isAvailable == TRUE) {
1329 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SS_DevDetectSrv/Availability -> TRUE");
1330 *pLastSrvSts |= NTFY_MSK_SS_DEVDETSRV_AVAILABILITY;
1332 eStatus = DevDetectSrvIfOpenSessionRequest(&bDummy);
1333 if (eFrameworkunifiedStatusOK != eStatus) {
1334 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1335 "DeviceDetectionServiceIf OpenSession ERROR!! [eStatus = %d]", eStatus);
1337 eStatus = DevDetectSrvIfNotifyOnOpenSessionAck(&PosOnDevDetectOpenSessionAck, &bDummy);
1338 if (eFrameworkunifiedStatusOK != eStatus) {
1339 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1340 "DeviceDetectionServiceIf NotifyOnOpenSessionAck ERROR!! [eStatus = %d]", eStatus);
1344 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SS_DevDetectSrv/Availability -> FALSE");
1345 *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_SS_DEVDETSRV_AVAILABILITY);
1348 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1350 return eFrameworkunifiedStatusOK;
1356 * Vehicle Availability notification callback functions
1358 * @param[in] h_app Application handle
1360 * @return eFrameworkunifiedStatusOK Normal completion
1363 static EFrameworkunifiedStatus PosNotifyVehicleAvailability(HANDLE h_app) {
1365 uint8_t* pLastSrvSts = &g_last_srv_sts;
1367 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
1369 isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
1371 /* Update Vechile I/F Abailability */
1372 VehicleIf_SetAvailability(isAvailable);
1374 if (isAvailable == TRUE) {
1375 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Vehicle/Availability -> TRUE");
1377 *pLastSrvSts |= NTFY_MSK_VS_VEHICLE_AVAILABILITY;
1379 if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_SPEED)) {
1380 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry SPEED ERROR");
1383 if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_REV)) {
1384 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry REV ERROR");
1387 if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_SPEED_PULSE_VEHICLE)) {
1388 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry SPEED PULSE ERROR");
1391 PosCreateThread(h_app);
1394 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Vehicle/Availability -> FALSE");
1396 *pLastSrvSts &= ~NTFY_MSK_VS_VEHICLE_AVAILABILITY;
1399 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
1401 return eFrameworkunifiedStatusOK;
1406 * Shared Memory Creation for Positioning Function
1408 * @return RET_NORMAL Normal completion
1411 static void PosCreateSharedMemory(void) {
1412 RET_API ret_api = RET_NORMAL;
1413 void *mod_exec_dmy; /* Module data pointer(dummy) */
1414 int retry; /* Retry counter */
1415 ST_SHAREDATA *p_shm_tbl;
1417 /* Configure Shared Data Generating Tables */
1418 p_shm_tbl = g_sharedata_tbl;
1420 while ( *(p_shm_tbl->share_data_name) != '\0' ) {
1421 for ( retry = 0; retry < DATMOD_RETRY; retry++ ) {
1422 /* Shared Memory Generation */
1423 ret_api = _pb_CreateShareData(p_shm_tbl->share_data_name, p_shm_tbl->data_size, &mod_exec_dmy);
1424 if (ret_api == RET_NORMAL) { /* If successful */
1425 /* Set the shared memory status flag to ""Before initialization (0)"" */
1426 *reinterpret_cast<u_int32 *>(mod_exec_dmy) = DATMOD_PREINIT;
1429 } else { /* In the event of failure */
1430 /* Error Handling */
1431 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1432 "_pb_CreateShareData ERROR [ret_api:%d]",
1437 if (retry >= DATMOD_RETRY) {
1438 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_CreateShareData failed more %d times.",
1442 /* don't arrive here. */
1445 /* Next shared memory generation */
1454 * Positioning in-process thread creation
1456 * @param[in] hApp application handles
1458 static void PosCreateThread(HANDLE h_app) {
1459 HANDLE threadHandle;
1460 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1461 EnumSetupMode_POS* peMode = &g_setup_mode;
1463 uint8_t* pLastSrvSts = &g_last_srv_sts;
1464 uint8_t* pLastThreadSts = &g_last_thread_sts;
1465 uint8_t* pLastNtfySts = &g_last_ntfy_sts;
1466 EnumExeSts_POS* pExeSts = &g_exe_sts;
1467 ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
1469 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1471 for (i = 0; i < ETID_POS_MAX; i++) {
1472 if ((pThrCreInfo->status == THREAD_STS_NOEXIST) && (pThrCreInfo->routine != NULL)) {
1473 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__,
1474 "i=%d, mskThread=0x%02x, *pLastThreadSts=0x%02x,"\
1475 "mskAvailable=0x%02x, *pLastSrvSts=0x%02x, mskNtfy=0x%02x, *pLastNtfySts=0x%02x",
1477 pThrCreInfo->msk_thread,
1479 pThrCreInfo->msk_available,
1481 pThrCreInfo->msk_ntfy,
1484 if ((*pExeSts != EPOS_EXE_STS_STOP)
1485 && ((((pThrCreInfo->msk_thread) & (*pLastThreadSts)) == pThrCreInfo->msk_thread)
1486 || (pThrCreInfo->msk_thread == 0))
1487 && ((((pThrCreInfo->msk_available) & (*pLastSrvSts)) == pThrCreInfo->msk_available)
1488 || (pThrCreInfo->msk_available == NTFY_MSK_NONE))
1489 && ((((pThrCreInfo->msk_ntfy) & (*pLastNtfySts)) == pThrCreInfo->msk_ntfy)
1490 || (pThrCreInfo->msk_ntfy == NTFY_MSK_NONE))) {
1491 if (pThrCreInfo->pno == PNO_LINE_SENS_DRV || \
1492 pThrCreInfo->pno == PNO_NAVI_GPS_MAIN || \
1493 pThrCreInfo->pno == PNO_NAVI_GPS_RCV ||
1494 pThrCreInfo->pno == PNO_CLK_GPS) {
1495 (pThrCreInfo->routine)(h_app);
1497 /* Thread creation */
1498 threadHandle = FrameworkunifiedCreateChildThread(h_app,
1499 (PCSTR)(pThrCreInfo->p_name),
1500 pThrCreInfo->routine,
1501 &PosStopThreadDummy);
1502 if (threadHandle == NULL) { /* If the thread creation fails */
1503 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1504 "FrameworkunifiedCreateChildThread ERROR!! [tHandle=%p]",
1507 /* don't arrive here. */
1509 /* Thread activation (Notify the startup mode) */
1510 eStatus = FrameworkunifiedStartChildThread(h_app,
1512 sizeof(EnumSetupMode_POS),
1513 reinterpret_cast<void*>(peMode));
1514 if (eStatus != eFrameworkunifiedStatusOK) {
1515 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1516 "FrameworkunifiedStartChildThread ERROR!! [eStatus=%d, name=%s]",
1518 pThrCreInfo->p_name);
1520 pThrCreInfo->status = THREAD_STS_CREATING;
1521 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "name=%s", pThrCreInfo->p_name);
1531 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1539 * Termination of Positioning in-process threads
1541 static void PosStopThread(void) {
1543 ST_THREAD_CREATE_INFO* p_thr_cre_info = g_pos_thread_create_info;
1544 BOOL *p_thr_stop_req = &g_thread_stop_req;
1546 uint8_t uc_order = 0;
1550 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1552 for (i = 0; i < ETID_POS_MAX; i++) {
1553 if (uc_order < p_thr_cre_info->order) {
1554 uc_order = p_thr_cre_info->order;
1555 us_pno = p_thr_cre_info->pno;
1560 if (uc_order != 0) {
1561 /* Send Thread Termination Request */
1562 if (us_pno == PNO_NAVI_GPS_RCV) {
1563 /* Pos_gps_recv Only thread flag control */
1564 *p_thr_stop_req = TRUE;
1566 ret = PosSndMsg(us_pno, CID_THREAD_STOP_REQ, &uc_msg, sizeof(uc_msg));
1567 if (ret != RET_NORMAL) {
1568 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1569 "PosSndMsg ERROR!! [ret = %d]",
1575 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1582 * Backup RAM initialization
1584 static void PosBackupDataInit(void) {
1585 UNIT_TYPE e_type = UNIT_TYPE_NONE;
1586 EFrameworkunifiedStatus e_status;
1587 BOOL b_is_available;
1588 ST_GPS_SET_TIME st_gps_set_time;
1590 (void)memset( reinterpret_cast<void *>(&st_gps_set_time), 0, (size_t)sizeof(st_gps_set_time) );
1592 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1594 e_type = GetEnvSupportInfo();
1595 if (e_type == UNIT_TYPE_GRADE1) {
1596 /* Set GPS date and time */
1597 e_status = BackupMgrIfBackupDataWt(D_BK_ID_POS_GPS_TIME_SET_INFO,
1600 sizeof(st_gps_set_time),
1602 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "D_BK_ID_POS_GPS_TIME_SET_INFO:W:Clear");
1603 if (e_status != eFrameworkunifiedStatusOK) {
1604 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1605 "BackupMgrIfBackupDataWt ERROR!! [e_status=%d, b_is_available=%d]",
1609 } else if (e_type == UNIT_TYPE_GRADE2) {
1612 * This feature branches processing depending on the unit type.
1618 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1625 * Callback function for registering the dispatcher()
1627 * @param[in] h_app Application handle
1629 * @return eFrameworkunifiedStatusOK Normal completion
1631 static EFrameworkunifiedStatus PosThreadCreateComp(HANDLE h_app) {
1632 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
1635 uint8_t* pLastThreadSts = &g_last_thread_sts;
1636 ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
1637 uint8_t* pLastNumThr = &g_last_num_of_thread;
1638 uint8_t* pLastSrvSts = &g_last_srv_sts;
1639 uint8_t* pLastNtfySts = &g_last_ntfy_sts;
1642 static BOOL isSetAvailable = FALSE;
1644 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1646 pRcvMsg = g_rcv_msg_buf;
1648 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1649 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1652 eTid = *(reinterpret_cast<EnumTID_POS*>(pRcvMsg));
1654 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1655 "Get message = [Sender:%s][CID:0x%X]",
1656 (pThrCreInfo + eTid)->p_name,
1657 CID_THREAD_CREATE_COMP);
1659 /* Thread Management Variable Updates */
1660 *pLastThreadSts = static_cast<uint8_t>(*pLastThreadSts | (0x1u << eTid));
1661 (pThrCreInfo + eTid)->status = THREAD_STS_CREATED;
1662 (pThrCreInfo + eTid)->order = *pLastNumThr;
1664 /* Individual processing of started threads */
1666 case ETID_POS_SENS: /* When sensor driver thread startup is completed */
1668 /* When PSMShadow startup completion notice has been received */
1669 if (((NTFY_MSK_PS_PSMSHADOW_INIT_COMP) & (*pLastNtfySts)) == NTFY_MSK_PS_PSMSHADOW_INIT_COMP) {
1670 /* External pin status request */
1671 LineSensDrvExtTermStsReq();
1675 case ETID_POS_GPS: /* When the GPS management thread has started */
1677 /* NSBackupMgr/Availability=When TRUE notification has been received */
1678 if (((NTFY_MSK_NS_BACKUPMGR_AVAILABILITY) & (*pLastSrvSts)) == NTFY_MSK_NS_BACKUPMGR_AVAILABILITY) {
1679 /* Backup data read request to GSP management thread */
1680 (void)DEVGpsSndBackupDataLoadReq();
1684 default: /* Other thread startup completion time */
1688 PosCreateThread(h_app);
1690 for (i = 0; i < ETID_POS_MAX; i++) {
1691 if ((pThrCreInfo->is_depended == TRUE) && (pThrCreInfo->status != THREAD_STS_CREATED)) {
1692 break; /* Positioning/Availability->TRUE condition does not meet */
1697 if ((i == ETID_POS_MAX) && (isSetAvailable == FALSE)) {
1698 /* Positionig/Availability -> TRUE */
1699 eStatus = FrameworkunifiedPublishServiceAvailability(h_app, TRUE);
1700 if (eFrameworkunifiedStatusOK != eStatus) {
1701 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1702 "FrameworkunifiedPublishServiceAvailability ERROR!! [eStatus = %d]",
1705 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> TRUE");
1706 isSetAvailable = TRUE;
1711 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1713 return eFrameworkunifiedStatusOK;
1719 * Callback function for registering the dispatcher()
1721 * @param[in] h_app Application handle
1723 * @return eFrameworkunifiedStatusOK Normal completion
1725 static EFrameworkunifiedStatus PosThreadStopComp(HANDLE h_app) {
1726 EFrameworkunifiedStatus eStatus;
1731 uint8_t* pLastThreadSts = &g_last_thread_sts;
1732 ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
1733 uint8_t* pLastNumThr = &g_last_num_of_thread;
1734 BOOL *pThrStopReq = &g_thread_stop_req;
1737 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
1739 pRcvMsg = g_rcv_msg_buf;
1741 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1742 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1745 eTid = *(reinterpret_cast<EnumTID_POS*>(pRcvMsg));
1747 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1748 "Get message = [Sender:%s][CID:0x%X]",
1749 (pThrCreInfo + eTid)->p_name,
1750 CID_THREAD_STOP_COMP);
1752 *pLastThreadSts = static_cast<uint8_t>(*pLastThreadSts & ~(0x1u << eTid));
1754 (pThrCreInfo + eTid)->status = THREAD_STS_NOEXIST;
1755 (pThrCreInfo + eTid)->order = 0;
1757 if ((pThrCreInfo + eTid)->pno == PNO_NAVI_GPS_RCV) {
1758 *pThrStopReq = FALSE;
1764 /* When all threads have stopped */
1765 if (*pLastThreadSts == 0) {
1766 /* Unregister callback function */
1767 eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(h_app,
1769 (const PUI_32)g_positioning_cids,
1770 _countof(g_positioning_cids), NULL);
1771 if (eStatus != eFrameworkunifiedStatusOK) { /* In the event of failure */
1772 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1773 "PositioningDetachCallbacksToDispatcher Failed in FrameworkunifiedOnStop [eStatus:%d]",
1777 /* Sensor log stop processing */
1780 /* DeviceDetectionServiceIf termination process */
1781 eStatus = DevDetectSrvIfUnRegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV, &bIsAvailable);
1782 if (eStatus != eFrameworkunifiedStatusOK) {
1783 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1784 "DeviceDetectionServiceIf UnRegisterEvent ERROR!! [sts:%d, ava:%d]",
1788 eStatus = DevDetectSrvIfCloseSessionRequest(&bIsAvailable);
1789 if (eFrameworkunifiedStatusOK != eStatus) {
1790 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1791 "DeviceDetectionServiceIf CloseSession ERROR!! [sts=%d, ava:%d]",
1797 (void)VehicleIfDetachCallbacksFromDispatcher((const PUI_32)g_positioning_cids_vehicle,
1798 _countof(g_positioning_cids_vehicle));
1800 /* Releasing Base API Resources */
1801 _pb_Teardown_CWORD64_API();
1803 /* Stop processing completion response */
1804 SendInterfaceunifiedOnStopResponseToSystemManager(eFrameworkunifiedStatusOK);
1807 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
1809 return eFrameworkunifiedStatusOK;
1814 * Callback function for registering the dispatcher(POS_RegisterListenerPkgSensData)
1816 * Send a message to an internal thread.
1818 * @param[in] h_app Application handle
1820 * @return eFrameworkunifiedStatusOK Normal completion
1822 static EFrameworkunifiedStatus PosPosifRegisterListenerPkgSensorData(HANDLE h_app) {
1828 static const PCSTR pNone = "-";
1830 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
1832 pRcvMsg = g_rcv_msg_buf;
1834 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1835 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1836 pName = _pb_CnvPno2Name((reinterpret_cast<SENSOR_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
1837 if (pName == NULL) {
1840 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1841 "Get message = [Sender:%s][CID:0x%X",
1843 CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT);
1845 /* Send Messages to Internal Thread */
1846 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT, pRcvMsg, size);
1847 if (ret != RET_NORMAL) {
1848 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
1849 /* Event Generation */
1850 ulEventId = PosCreateEvent((reinterpret_cast<SENSOR_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
1851 if (ulEventId != 0) {
1852 /* Event publishing */
1853 ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, SENSOR_RET_ERROR_INNER);
1854 if (ret != RET_NORMAL) {
1855 /* Event issuance failure */
1856 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SetEvent ERROR!! [ret = %d]", ret);
1858 /* Event deletion */
1859 (void)PosDeleteEvent(ulEventId);
1861 /* Event generation failure */
1862 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosCreateEvent ERROR!!");
1867 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
1869 return eFrameworkunifiedStatusOK;
1874 * Callback function for registering the dispatcher(POS_RegisterListenerSensData)
1876 * Send a message to an internal thread.
1878 * @param[in] h_app Application handle
1880 * @return eFrameworkunifiedStatusOK Normal completion
1882 static EFrameworkunifiedStatus PosPosifRegisterListenerSensorData(HANDLE h_app) {
1888 static const PCSTR pNone = "-";
1890 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
1892 pRcvMsg = g_rcv_msg_buf;
1894 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1895 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1896 pName = _pb_CnvPno2Name((reinterpret_cast<VEHICLE_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
1897 if (pName == NULL) {
1900 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1901 "Get message = [Sender:%s][CID:0x%X]",
1903 CID_VEHICLEIF_DELIVERY_ENTRY);
1905 /* Send Messages to Internal Thread */
1906 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_VEHICLEIF_DELIVERY_ENTRY, pRcvMsg, size);
1907 if (ret != RET_NORMAL) {
1908 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
1909 /* Event Generation */
1910 ulEventId = VehicleCreateEvent((reinterpret_cast<VEHICLE_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
1911 if (ulEventId != 0) {
1912 /* Event publishing */
1913 ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, SENSOR_RET_ERROR_INNER);
1914 if (ret != RET_NORMAL) {
1915 /* Event issuance failure */
1916 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SetEvent ERROR!! [ret = %d]", ret);
1918 /* Event deletion */
1919 (void)VehicleDeleteEvent(ulEventId);
1921 /* Event generation failure */
1922 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
1927 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
1929 return eFrameworkunifiedStatusOK;
1934 * Callback function for registering the dispatcher(POS_ReqGPSSetting)
1936 * Send a message to an internal thread.
1938 * @param[in] h_app Application handle
1940 * @return eFrameworkunifiedStatusOK Normal completion
1942 static EFrameworkunifiedStatus PosPosifReqGpsSetting(HANDLE h_app) {
1946 uint8_t ucResult = SENSLOG_RES_FAIL;
1948 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
1950 pRcvMsg = g_rcv_msg_buf;
1952 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1953 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1954 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1955 "Get message = [Sender:-][CID:0x%X]",
1956 CID_SENSORIF__CWORD82__REQUEST);
1957 ucResult = SENSLOG_RES_SUCCESS;
1959 /* Send Messages to Internal Thread */
1960 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_SENSORIF__CWORD82__REQUEST, pRcvMsg, size);
1961 if (ret != RET_NORMAL) {
1962 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
1966 SensLogWriteInputData(SENSLOG_DATA_I_GPSSET, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
1967 ucResult, SENSLOG_ON, SENSLOG_ON);
1968 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
1970 return eFrameworkunifiedStatusOK;
1975 * Callback function for registering the dispatcher(POS_SetGPSInfo)
1977 * Send a message to an internal thread.
1979 * @param[in] h_app Application handle
1981 * @return eFrameworkunifiedStatusOK Normal completion
1983 static EFrameworkunifiedStatus PosPosifSetGpsInfo(HANDLE h_app) {
1987 uint8_t ucResult = SENSLOG_RES_FAIL;
1989 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
1991 pRcvMsg = g_rcv_msg_buf;
1993 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
1994 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
1995 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
1996 "Get message = [Sender:-][CID:0x%X]",
1997 CID_NAVIINFO_DELIVER);
1998 ucResult = SENSLOG_RES_SUCCESS;
2000 /* Send Messages to Internal Thread */
2001 ret = PosSndMsg(PNO_NAVI_GPS_MAIN, CID_NAVIINFO_DELIVER, pRcvMsg, size);
2002 if (ret != RET_NORMAL) {
2003 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
2006 SensLogWriteInputData(SENSLOG_DATA_I_GPSINF, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
2007 ucResult, SENSLOG_ON, SENSLOG_ON);
2008 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
2010 return eFrameworkunifiedStatusOK;
2015 * Callback function for registering the dispatcher(POS_GetGPSInfo)
2017 * Send a message to an internal thread.
2019 * @param[in] h_app Application handle
2021 * @return eFrameworkunifiedStatusOK Normal completion
2023 static EFrameworkunifiedStatus PosPosifGetGpsInfo(HANDLE h_app) {
2029 static const PCSTR pNone = "-";
2031 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
2033 pRcvMsg = g_rcv_msg_buf;
2035 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
2036 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
2037 pName = _pb_CnvPno2Name((reinterpret_cast<VEHICLE_MSG_GET_VEHICLE_DATA_DAT*>(pRcvMsg))->pno);
2038 if (pName == NULL) {
2041 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
2042 "Get message = [Sender:%s][CID:0x%X]",
2044 CID_VEHICLEIF_GET_VEHICLE_DATA);
2046 /* Send Messages to Internal Thread */
2047 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_VEHICLEIF_GET_VEHICLE_DATA, pRcvMsg, size);
2048 if (ret != RET_NORMAL) {
2049 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
2050 /* Event Generation */
2051 ulEventId = VehicleCreateEvent((reinterpret_cast<VEHICLE_MSG_GET_VEHICLE_DATA_DAT*>(pRcvMsg))->pno);
2052 if (ulEventId != 0) {
2053 /* Event publishing */
2054 ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
2055 if (ret != RET_NORMAL) {
2056 /* Event issuance failure */
2057 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2058 "_pb_SetEvent ERROR!! [ret = %d]",
2061 /* Event deletion */
2062 (void)VehicleDeleteEvent(ulEventId);
2064 /* Event generation failure */
2065 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
2070 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
2072 return eFrameworkunifiedStatusOK;
2077 * Callback function for registering the dispatcher(CID_POSIF_SET_DATA)
2079 * Send a message to an internal thread.
2081 * @param[in] h_app Application handle
2083 * @return eFrameworkunifiedStatusOK Normal completion
2085 static EFrameworkunifiedStatus PosPosifSetData(HANDLE h_app) {
2091 static const PCSTR pNone = "-";
2092 uint8_t ucResult = SENSLOG_RES_FAIL;
2094 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
2096 pRcvMsg = g_rcv_msg_buf;
2098 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
2099 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
2100 ucResult = SENSLOG_RES_SUCCESS;
2102 pName = _pb_CnvPno2Name((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->pno);
2103 if (pName == NULL) {
2106 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
2107 "Get message = [Sender:%s][CID:0x%X][DID:0x%X]",
2110 (reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did);
2112 /* Send Messages to Internal Thread */
2113 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_POSIF_SET_DATA, pRcvMsg, size);
2114 if (ret != RET_NORMAL) {
2115 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
2116 if ((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did == VEHICLE_DID_SETTINGTIME) {
2117 /* GPS time setting(When waiting for completion of an event, an event is issued. */
2118 /* Event Generation */
2119 ulEventId = VehicleCreateEvent((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->pno);
2120 if (ulEventId != 0) {
2121 /* Event publishing */
2122 ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
2123 if (ret != RET_NORMAL) {
2124 /* Event issuance failure */
2125 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2126 "_pb_SetEvent ERROR!! [ret = %d]",
2129 /* Event deletion */
2130 (void)VehicleDeleteEvent(ulEventId);
2132 /* Event generation failure */
2133 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
2138 SensLogWriteInputData(SENSLOG_DATA_I_UNSPECIFIED,
2139 (reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did,
2142 static_cast<uint16_t>(size),
2146 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
2148 return eFrameworkunifiedStatusOK;
2153 * Callback function for registering the dispatcher(CID_GPS_REQRESET)
2155 * Send a message to an internal thread.
2157 * @param[in] h_app Application handle
2159 * @return eFrameworkunifiedStatusOK Normal completion
2161 static EFrameworkunifiedStatus PosPosifReqGpsReset(HANDLE h_app) {
2167 static const PCSTR pNone = "-";
2168 uint8_t ucResult = SENSLOG_RES_FAIL;
2170 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");
2172 pRcvMsg = g_rcv_msg_buf;
2174 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
2175 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
2176 ucResult = SENSLOG_RES_SUCCESS;
2178 pName = _pb_CnvPno2Name((reinterpret_cast<POS_RESETINFO*>(pRcvMsg))->snd_pno);
2179 if (pName == NULL) {
2182 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__,
2183 "Get message = [Sender:%s][CID:0x%X]",
2187 /* Send Messages to Internal Thread */
2188 ret = PosSndMsg(PNO_NAVI_GPS_MAIN, CID_GPS_REQRESET, pRcvMsg, size);
2189 if (ret != RET_NORMAL) {
2190 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
2192 /* Event Generation */
2193 ulEventId = VehicleCreateEvent((reinterpret_cast<POS_RESETINFO*>(pRcvMsg))->snd_pno);
2194 if (0 != ulEventId) {
2195 /* Event publishing */
2196 ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
2197 if (ret != RET_NORMAL) {
2198 /* Event issuance failure */
2199 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2200 "_pb_SetEvent ERROR!! [ret = %d]",
2203 /* Event deletion */
2204 (void)VehicleDeleteEvent(ulEventId);
2206 /* Event generation failure */
2207 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
2212 SensLogWriteInputData(SENSLOG_DATA_I_GPSRST, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
2213 ucResult, SENSLOG_ON, SENSLOG_ON);
2214 FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");
2216 return eFrameworkunifiedStatusOK;
2221 * Callback function for registering the dispatcher(CID_VEHICLESENS_VEHICLE_INFO)
2223 * Send a message to an internal thread.
2225 * @param[in] h_app Application handle
2227 * @return eFrameworkunifiedStatusOK Normal completion
2229 static EFrameworkunifiedStatus PosVehicleInfoRcv(HANDLE h_app) {
2230 LSDRV_MSG_LSDATA_DAT_G line_sns_data;
2231 RET_API ret = RET_NORMAL;
2233 memset(&line_sns_data, 0, sizeof(line_sns_data));
2234 LSDRV_MSG_LSDATA_DAT_G *p_line_sns_data = &line_sns_data;
2235 VEHICLE_UNIT_MSG_VSINFO *p_vehicle_msg = NULL;
2237 uint16_t us_speed = 0;
2239 uint8_t* pRcvMsg = g_rcv_msg_buf;
2241 size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
2242 if (size != 0) { // LCOV_EXCL_BR_LINE 4: nsfw error
2243 memset(p_line_sns_data, 0x00, sizeof(line_sns_data));
2244 p_vehicle_msg = (reinterpret_cast<VEHICLE_UNIT_MSG_VSINFO*>(pRcvMsg));
2245 switch (p_vehicle_msg->data.did) {
2247 case VEHICLE_DID_SPEED:
2249 p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
2250 p_line_sns_data->st_data[LSDRV_SPEED_KMPH].ul_did = POSHAL_DID_SPEED_KMPH;
2251 p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_size = POS_SNDMSG_DTSIZE_2;
2252 p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_sns_cnt = 0;
2254 char p_env_variable[VP_MAX_LENGTH];
2256 VP_GetEnv("VP__CWORD31__SPEED", p_env_variable);
2257 if (0 == strcmp(p_env_variable, "direct")) {
2259 // To obtain the vehicle speed from Direct lanes,1 to 2 bytes of received data
2260 memcpy(&speed, &p_vehicle_msg->data.data[0], sizeof(speed));
2261 us_speed = static_cast<uint16_t>(abs(speed));
2262 // Unit conversion [km/h] -> [0.01km/h]
2263 us_speed = static_cast<uint16_t>(us_speed * 100);
2264 } else if (0 == strcmp(p_env_variable, "CAN")) {
2266 // To obtain the vehicle speed from CAN,2 to 3 bytes of received data
2267 memcpy(&speed, &p_vehicle_msg->data.data[1], sizeof(speed));
2268 us_speed = static_cast<uint16_t>(abs(speed));
2269 // Unit conversion [km/h] -> [0.01km/h]
2270 us_speed = static_cast<uint16_t>(us_speed * 100);
2272 // In case of invalid value, the vehicle speed is acquired by CAN.
2274 memcpy(&speed, &p_vehicle_msg->data.data[1], sizeof(speed));
2275 us_speed = static_cast<uint16_t>(abs(speed));
2276 // Unit conversion [km/h] -> [0.01km/h]
2277 us_speed = static_cast<uint16_t>(us_speed * 100);
2280 memcpy(&p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_data[0], &us_speed, sizeof(us_speed));
2282 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
2283 reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));
2288 case VEHICLE_DID_REV:
2290 p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
2291 p_line_sns_data->st_data[LSDRV_REV].ul_did = VEHICLE_DID_REV;
2292 p_line_sns_data->st_data[LSDRV_REV].uc_size = POS_SNDMSG_DTSIZE_1;
2293 p_line_sns_data->st_data[LSDRV_REV].uc_sns_cnt = 0;
2294 p_line_sns_data->st_data[LSDRV_REV].uc_data[0] = p_vehicle_msg->data.data[0];
2296 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
2297 reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));
2301 // Speed Pulse information
2302 case VEHICLE_DID_SPEED_PULSE_VEHICLE:
2304 p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
2305 p_line_sns_data->st_data[LSDRV_SPEED_PULSE].ul_did = POSHAL_DID_SPEED_PULSE;
2306 p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_size = sizeof(float);
2307 p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_sns_cnt = 0;
2309 memcpy(&p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_data[0],
2310 &p_vehicle_msg->data.data[0], sizeof(float));
2312 p_line_sns_data->st_data[LSDRV_PULSE_TIME].ul_did = POSHAL_DID_PULSE_TIME;
2313 p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_size = sizeof(float);
2314 p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_sns_cnt = 0;
2316 memcpy(&p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_data[0],
2317 &p_vehicle_msg->data.data[sizeof(float)], sizeof(float));
2319 ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
2320 reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));
2328 if (ret != RET_NORMAL) {
2329 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
2332 return eFrameworkunifiedStatusOK;
2339 * Get messages received by the dispatcher
2341 * @param[in] h_app Application handle
2342 * @param[out] p_buf Pointer to receive data storage buffer
2343 * @param[in] Sizes of size receive data storage buffers
2345 * @return Received data size(0:Receiving error)
2347 static uint32_t PosGetMsg(HANDLE h_app, void** p_buf, uint32_t size) {
2348 EFrameworkunifiedStatus eStatus;
2349 uint32_t ulSize = 0;
2353 if ((h_app == NULL) || (p_buf == NULL)) { // LCOV_EXCL_BR_LINE 200: can not NULL
2354 // LCOV_EXCL_START 8: invalid
2355 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2356 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2357 "Argument ERROR!! [h_app = %p, p_buf = %p]",
2362 /* Check the size of received data */
2363 ulSize = FrameworkunifiedGetMsgLength(h_app);
2364 if (ulSize > size) {
2365 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2366 "Message size ERROR!! [ulSize = %d, maxsize = %d]",
2372 eStatus = FrameworkunifiedGetDataPointer(h_app, &pRcvBuf);
2373 if (eStatus == eFrameworkunifiedStatusOK) {
2375 } else if (eStatus == eFrameworkunifiedStatusInvldBufSize) {
2376 eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, *p_buf, ulSize);
2377 /* When acquisition fails */
2378 if (eStatus != eFrameworkunifiedStatusOK) {
2379 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2380 "FrameworkunifiedGetMsgDataOfSize ERROR [eStatus:%d]",
2385 /* When acquisition fails */
2386 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2387 "FrameworkunifiedGetDataPointer ERROR [eStatus:%d]",
2399 * Sending Messages for Internal Threads
2401 * Adds a header to the message received by the dispatcher and sends it to the internal thread..
2403 * @param[in] pno PNO
2404 * @param[in] cid Command ID
2405 * @param[in] p_msg_body Sent message body
2406 * @param[in] size Send message size
2408 * @return RET_NORAML Normal completion
2411 static RET_API PosSndMsg(PNO pno, CID cid, void* p_msg_body, uint32_t size) {
2412 RET_API ret = RET_NORMAL;
2413 T_APIMSG_MSGBUF_HEADER* p;
2414 static u_int8 sndMsgBuf[MAX_MSG_BUF_SIZE + sizeof(T_APIMSG_MSGBUF_HEADER)];
2416 if ((p_msg_body == NULL) || (size > MAX_MSG_BUF_SIZE)) {
2417 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR!! [p_msg_body = %p, size = %d]", p_msg_body, size);
2420 p = reinterpret_cast<T_APIMSG_MSGBUF_HEADER*>(sndMsgBuf);
2422 /* Message header addition */
2424 p->hdr.msgbodysize = static_cast<uint16_t>(size);
2426 /* Copy of the data section */
2427 memcpy((p + 1), p_msg_body, size);
2429 /* Send a message to an internal thread */
2430 ret = _pb_SndMsg(pno, static_cast<uint16_t>(size + sizeof(T_APIMSG_MSGBUF_HEADER)), p, 0);
2431 /* When transmission fails */
2432 if (ret != RET_NORMAL) {
2433 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg ERROR [ret = %d]", ret);
2443 * SS_DevDetectSrv service OpenSessionAck Callback Functions
2447 * @return eFrameworkunifiedStatusOK successful completion
2449 static EFrameworkunifiedStatus PosOnDevDetectOpenSessionAck(HANDLE h_app) {
2450 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
2453 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
2455 eStatus = DevDetectSrvIfDecodeOpenSessionResponse(&bIsAvailable);
2456 if (eFrameworkunifiedStatusOK != eStatus) {
2457 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2458 "DeviceDetectionServiceIf OpenSession ERROR!! [sts=%d, ava=%d]", eStatus, bIsAvailable);
2460 eStatus = DevDetectSrvIfRegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV,
2461 &PosOnDevDetectEvent,
2464 if (eFrameworkunifiedStatusOK != eStatus) {
2465 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2466 "DeviceDetectionServiceIf RegisterEvent ERROR!! [sts=%d, ava=%d]", eStatus, bIsAvailable);
2468 eStatus = DevDetectSrvIfNotifyOnCloseSessionAck(&PosOnDevDetectCloseSessionAck, &bIsAvailable);
2469 if (eFrameworkunifiedStatusOK != eStatus) {
2470 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2471 "DeviceDetectionServiceIf CloseSessionAck ERROR!! [sts=%d, ava=%d]",
2478 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
2479 return eFrameworkunifiedStatusOK;
2484 * SS_DevDetectSrv service CloseSessionAck Callback Functions
2488 * @return eFrameworkunifiedStatusOK successful completion
2490 static EFrameworkunifiedStatus PosOnDevDetectCloseSessionAck(HANDLE h_app) {
2491 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
2493 /* Sensor log stop processing */
2496 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
2497 return eFrameworkunifiedStatusOK;
2502 * SS_DevDetectSrv service Event Callback Functions
2506 * @return eFrameworkunifiedStatusOK successful completion
2508 static EFrameworkunifiedStatus PosOnDevDetectEvent(HANDLE h_app) {
2509 SS_MediaDetectInfo stMedia;
2510 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
2511 uint32_t ulSize = 0;
2514 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
2516 /* Check the size of received data */
2517 ulSize = FrameworkunifiedGetMsgLength(h_app);
2518 if (ulSize > sizeof(SS_MediaDetectInfo)) {
2519 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Message size ERROR!! [ulSize = %d, maxsize = %ld]",
2520 ulSize, sizeof(SS_MediaDetectInfo));
2524 eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, &stMedia, ulSize);
2525 /* When acquisition fails */
2526 if (eStatus != eFrameworkunifiedStatusOK) {
2527 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2528 "FrameworkunifiedGetMsgDataOfSize ERROR [eStatus:%d]", eStatus);
2531 if (eUSB == stMedia.dev_type) {
2532 if (TRUE == stMedia.bIsDeviceAvailable) {
2533 /* Mount detection */
2534 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__,
2535 "USB mounted sts=[%d] path=[%s] fusedav=[%d]",
2536 stMedia.bIsDeviceAvailable, stMedia.deviceMountpath, stMedia.bIsFuseDav);
2538 /* NOTE: bIsFuseDav -> From the _CWORD80_'s point of view, */
2539 /* TRUE(With a USB flash drive inserted into the _CWORD84_,Be synchronized on the FuseDav)*/
2540 /* FALSE(USB memory is inserted into the _CWORD80_.) */
2542 if (stMedia.bIsFuseDav == FALSE) {
2543 /* Inserted into your USB port */
2544 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SensLog Initialize start.");
2545 /* Get Debug/Release setting */
2546 eStatus = NsLogGetFrameworkunifiedLogFlag(POSITIONINGLOG_FLAG_NAVI, &mode);
2547 /* When acquisition fails */
2548 if (eStatus != eFrameworkunifiedStatusOK) {
2549 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2550 "NsLogGetFrameworkunifiedLogFlag ERROR [eStatus:%d]", eStatus);
2552 if (mode == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG) {
2553 /* Sensor Log Initial Processing(Normal)*/
2554 SensLogInitialize(reinterpret_cast<uint8_t *>(stMedia.deviceMountpath));
2558 /* TODO: Mounts (FuseDav synchronized) that are not inserted into your device's USB port are not supported. */
2559 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Don't output SensLog.");
2562 /* Unmount detection */
2563 if (stMedia.bIsFuseDav == FALSE) {
2564 /* When it is unmounted to its own USB */
2565 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__,
2566 "USB umounted sts=[%d] fusedav=[%d]",
2567 stMedia.bIsDeviceAvailable, stMedia.bIsFuseDav);
2569 /* Sensor log stop processing */
2577 FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
2582 * @brief Debug dump log output function
2584 * @param[in] *p_buf Pointer to the output string
2586 static void PosOutputDebugDumpLog(uint8_t* p_buf) { // LCOV_EXCL_START 7: uesd only in FrameworkunifiedOnDebugDump
2587 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2588 SSDEBUGDUMP("%s\n", p_buf);