summaryrefslogtreecommitdiffstats
path: root/positioning/server/src/nsfw/positioning_application.cpp
blob: d23daadaa4d6e41dca3ce3210220cddf458bd2d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file
 *    positioning_application.cpp
 * @brief
 *   Module : POSITIONING
 *   Implements Vehicle service functionality
 */

/*---------------------------------------------------------------------------------*
 * Include Files                                                                   *
 *---------------------------------------------------------------------------------*/
#include <native_service/frameworkunified_application.h>
#include <native_service/frameworkunified_framework_if.h>
#include <native_service/frameworkunified_multithreading.h>
#include <native_service/frameworkunified_service_protocol.h>
#include <native_service/frameworkunified_types.h>
#include <native_service/ns_message_center_if.h>
#include <peripheral_service/ps_services.h>
#include <vehicle_service/POS_sensor_API.h>
#include <vehicle_service/POS_gps_API.h>
#include <system_service/ss_sm_client_if.h>
#include <vehicle_service/positioning_base_library.h>
#include <stub/vehicle_notifications.h>
#include <peripheral_service/communication_notifications.h>
#include <other_service/VP_GetEnv.h>
#include <cstdlib>
#include <iostream>

#include "SensorLog.h"
#include "positioning_common.h"
#include "POS_private.h"
#include "Gps_API_private.h"
#include "POS_common_private.h"
#include "Vehicle_API.h"
#include "Vehicle_API_private.h"
#include "Sensor_API_private.h"
#include "Naviinfo_API.h"
#include "VehicleSensor_Thread.h"
#include "ClockGPS_Process_Proto.h"
#include "VehicleSens_Common.h"
#include "VehicleSens_DataMaster.h"
#include "VehicleSens_DeliveryCtrl.h"
#include "VehicleUtility.h"
#include "BackupMgrIf.h"
#include "ClockIf.h"
#include "CommUsbIf.h"
#include "DevDetectSrvIf.h"
#include "DiagSrvIf.h"
#include "PSMShadowIf.h"
#include "VehicleIf.h"
#include "positioning_hal.h"
#include "gps_hal.h"
#include "CommonDefine.h"

#include "VehicleIf.h"

/*---------------------------------------------------------------------------------*
 * Definition                                                                      *
 *---------------------------------------------------------------------------------*/
#define DATMOD_RETRY    (3) /* Number of shared memory generation retries */
#define DATMOD_PREINIT  (0) /* Shared Memory State Before Initialization */
#define PRIM_NAME_MAX   (32) /* Maximum Name Size */

/* Mask for managing various notification reception conditions */
#define NTFY_MSK_NONE                       (0x00)
/* Service availability notification */
#define NTFY_MSK_COMMUNICATION_AVAILABILITY (0x01)
#define NTFY_MSK_PS_COMMUSB_AVAILABILITY    (0x02)
#define NTFY_MSK_PS_PSMSHADOW_AVAILABILITY  (0x04)
#define NTFY_MSK_CLOCK_AVAILABILITY         (0x08)
#define NTFY_MSK_NS_BACKUPMGR_AVAILABILITY  (0x10)
#define NTFY_MSK_SS_DEVDETSRV_AVAILABILITY  (0x20)
#define NTFY_MSK_VS_VEHICLE_AVAILABILITY    (0x40)
/* Other Notices */
#define NTFY_MSK_PS_PSMSHADOW_INIT_COMP     (0x01) /* PSMShadow startup completion notice           */

/* Thread state */
#define THREAD_STS_NOEXIST                  (0x00)
#define THREAD_STS_CREATING                 (0x01)
#define THREAD_STS_CREATED                  (0x02)

#define POS_SNDMSG_DTSIZE_1     1       /* SndMSG data size 1Byte  */
#define POS_SNDMSG_DTSIZE_2     2       /* SndMSG data size 2Byte  */
#define POS_SNDMSG_DTSIZE_20     20     /* SndMSG data size of 20 bytes  */
#define POS_SNDMSG_DTSIZE_132     132     /* SndMSG data size: 132 bytes  */

/* PositioningLogFlag */
#define POSITIONINGLOG_FLAG_NAVI 9

/* Definition for thinning out sensor log at anomaly */
#define POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM  3
#define POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM  4
#define POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM  4
#define POSITIONINGLOG_SYS_4_ABNORMAL_DATA_NUM 129
#define POSITIONINGLOG_SYS_ABNORMAL_DATA_NUM (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + \
                                      POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM + \
                                      POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM + \
                                      POSITIONINGLOG_SYS_4_ABNORMAL_DATA_NUM)
#define POSITIONINGLOG_SYS_1_ABNORMAL_DATA_OFFSET 11
#define POSITIONINGLOG_SYS_2_ABNORMAL_DATA_OFFSET 32
#define POSITIONINGLOG_SYS_3_ABNORMAL_DATA_OFFSET 54
#define POSITIONINGLOG_SYS_4_ABNORMAL_DATA_OFFSET 114
#define POSITIONINGLOG_SYS_1_ABNORMAL_SET_DATA_OFFSET 0
#define POSITIONINGLOG_SYS_2_ABNORMAL_SET_DATA_OFFSET POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM
#define POSITIONINGLOG_SYS_3_ABNORMAL_SET_DATA_OFFSET (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM)
#define POSITIONINGLOG_SYS_4_ABNORMAL_SET_DATA_OFFSET (POSITIONINGLOG_SYS_1_ABNORMAL_DATA_NUM + \
                                               POSITIONINGLOG_SYS_2_ABNORMAL_DATA_NUM + \
                                               POSITIONINGLOG_SYS_3_ABNORMAL_DATA_NUM)
#define POSITIONINGLOG_SYS_OPC_OFFSET 9
#define POSITIONINGLOG_SYS_PULSE_TIME_NUM_OFFSET 114
#define POSITIONINGLOG_SYS_NORMAL_DATA 0xC1
#define POSITIONINGLOG_SYS_FST_DATA 0xF4
#define _pb_strcat(pdest, psrc, size)   (strncat(pdest, psrc, size) , (0))

// Vehicle sensor information notification message
typedef struct {
  uint32_t did;         // Data ID corresponding to vehicle sensor information
  uint16_t size;        // Data size of vehicle sensor information
  uint8_t rcv_flag;      // Vehicle sensor information reception flag
  uint8_t reserve;      // Reserved
  uint8_t data[VEHICLE_VSINFO_DSIZE];  // Vehicle sensor information
} VEHICLE_UNIT_MSG_VSINFO_DAT;

// Vehicle sensor information notification message
typedef struct {
  VEHICLE_UNIT_MSG_VSINFO_DAT data;  // Message data
} VEHICLE_UNIT_MSG_VSINFO;
/*---------------------------------------------------------------------------------*
 * Structre                                                                        *
 *---------------------------------------------------------------------------------*/
/*!
   @brief   Structure to create shared data
*/
typedef struct {
    char    share_data_name[PRIM_NAME_MAX]; /**< Shared data name         */
    u_int32 data_size;                    /**< Shared data size    */
} ST_SHAREDATA;

/*!
   @brief   Thread management information
*/
typedef struct {
    EnumTID_POS     id;           /**< Thread ID                                  */
    const int8_t*   p_name;        /**< Thread name                                  */
    PNO             pno;          /**< Process number                                */
    CbFuncPtr       routine;      /**< Start Routine                             */
    uint8_t         msk_available; /**< Dependent services Availability                    */
    uint8_t         msk_ntfy;      /**< Dependency notification                                   */
    uint8_t         msk_thread;    /**< Dependent threads                               */
    BOOL            is_depended;   /**< Positioning/Availability->TRUE change dependency */
    uint8_t         status;       /**< Thread activation state                             */
    uint8_t         order;        /**< Boot Sequence(Performance)                              */
    uint8_t         reserve[2];
} ST_THREAD_CREATE_INFO;


/* GPS fix count information */
typedef struct {
  uint32_t ul3d;                    /* 3D */
  uint32_t ul2d;                    /* 2D */
  uint32_t ul_else;                  /* Not fix */
  uint8_t dummy[4];                 /* Dummy */
} ST_GPS_FIX_CNT;

/*!
    @brief Structure that stores the time set by the time setting or the time updated(For GRADE1)
*/
typedef struct {
    u_int16 year; /* Year */
    u_int8 month; /* Month */
    u_int8 date;  /* Day */
    u_int8 hour;  /* Hour */
    u_int8 minute;/* Minutes */
    u_int8 second;/* Minutes */
    u_int8 flag;  /* Whether or not the time is set */
} ST_GPS_SET_TIME;

/*---------------------------------------------------------------------------------*
 * Local Function Prototype                                                        *
 *---------------------------------------------------------------------------------*/
static EFrameworkunifiedStatus PositioningOnStartImpl(const HANDLE hApp, const EPWR_SC_WAKEUP_TYPE wakeupType,
                                 const ESMDataResetModeInfo dataResetMode);
static EFrameworkunifiedStatus PosNotifyCommunicationAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyCommUSBAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyPSMShadowAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyPSMShadowInitComp(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyClockAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyNSBackupMgrAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyDevDetectSrvAvailability(HANDLE h_app);
static EFrameworkunifiedStatus PosNotifyVehicleAvailability(HANDLE h_app);

static EFrameworkunifiedStatus PosStopThreadDummy(HANDLE h_app);
static void PosCreateSharedMemory(void);
static void PosCreateThread(HANDLE h_app);
static void PosStopThread(void);
static void PosBackupDataInit(void);

/* Message Dispatching Functions */
static EFrameworkunifiedStatus PosThreadCreateComp(HANDLE h_app);
static EFrameworkunifiedStatus PosThreadStopComp(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifRegisterListenerPkgSensorData(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifRegisterListenerSensorData(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifReqGpsSetting(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifSetGpsInfo(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifGetGpsInfo(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifSetData(HANDLE h_app);
static EFrameworkunifiedStatus PosPosifReqGpsReset(HANDLE h_app);
static EFrameworkunifiedStatus PosVehicleInfoRcv(HANDLE h_app);
static uint32_t PosGetMsg(HANDLE h_app, void** p_buf, uint32_t size);
static RET_API  PosSndMsg(PNO pno, CID cid, void* p_msg_body, uint32_t size);
static void PosOutputDebugDumpLog(uint8_t* p_buf);

/* Function scan for device insertion detection */
static EFrameworkunifiedStatus PosOnDevDetectOpenSessionAck(HANDLE h_app);
static EFrameworkunifiedStatus PosOnDevDetectCloseSessionAck(HANDLE h_app);
static EFrameworkunifiedStatus PosOnDevDetectEvent(HANDLE h_app);

/*---------------------------------------------------------------------------------*
 * Grobal Value                                                                    *
 *---------------------------------------------------------------------------------*/
/* Thread name */
static const int8_t kThreadNamePosMain[15]         = "POS_Main";
static const int8_t kThreadNamePosSens[15]         = "POS_Sens";
static const int8_t kThreadNamePosGps[15]          = "POS_Gps";
static const int8_t kThreadNamePosGpsRecv[15]     = "POS_Gps_Recv";
static const int8_t kThreadNamePosGpsRollover[15] = "POS_Gps_Rolovr";

/** Shared memory generation table */
static ST_SHAREDATA g_sharedata_tbl[] = {
    /* Shared data name to be generated,            Shared data size */
    { {VEHICLE_SHARE_NAME},                 512 * 11 }, /* Vehicle sensor information acquisition                     */
#if 0 /* Less than 0.1 SBU,Not used in _CWORD71_ */
    { {"SENSOR_SHARE_MEMORY"},              512 * 11 }, /* Vehicle sensor information Pkg acquisition                  */
    { {"GPS_INT_SIGNAL_SHARE_MEMORY"},      4        }, /* GPS Interrupt Signal Acquisition                      */
    { {"LOG_SETTING_SHARE_MEMORY"},         36       }, /* DR feature log acquisition                         */
    { {"GYRO_CONNECT_STTS_SHARE_MEMORY"},   4        }, /* Get Gyro Connection Status                   */
    { {"EPHEMERIS_NUM_SHARE_MEMORY"},       4        }, /* For acquiring effective ephemeris count at shutdown */
    { {"LOCALTIME_SHARE_MEMORY"},            12         }, /* Local time acquisition at shutdown     */
    { {"LONLAT_SHARE_MEMORY"},                8         }, /* Location acquisition at shutdown               */
#endif
    { {'\0'},                                  0         }  /* Termination */
};

/** Sub-thread creation table
   (1) Thread ID (Locally defined Enumeration)
   (2) Thread name
   (3) Process number
   (4) Start Routine
   (5) Dependent Availability
   (6) Dependency notification
   (7) Dependent threads * If there are dependent threads, do not create them until those threads are created.
   (8) Positioning/Availability->TRUE depending on change
   (9) Thread activation state (THREAD_STS_NOEXIST:Not started,THREAD_STS_CREATING:Starting,THREAD_STS_CREATED:Completion of the activation)
  (10) Boot Sequence(Performance) (0,1,2, ... Note : 0 = Initial value(Not started)) Time of termination,Be destroyed in the reverse order of startup
 */
static ST_THREAD_CREATE_INFO g_pos_thread_create_info_Grade1[] = {  // LCOV_EXCL_BR_LINE 11: unexpected branch
    {    /* Pos_main */
        ETID_POS_MAIN, /* (1) */
        kThreadNamePosMain, /* (2) */
        PNO_VEHICLE_SENSOR, /* (3) */
        &VehicleSensThread, /* (4) */
        (NTFY_MSK_NONE), /* (5) */
        (NTFY_MSK_NONE), /* (6) */
        0, /* (7) */
        TRUE, /* (8) */
        THREAD_STS_NOEXIST, /* (9) */
        0 /* (10) */
    },
    {    /* Pos_sens */
        ETID_POS_SENS, /* (1) */
        kThreadNamePosSens, /* (2) */
        PNO_LINE_SENS_DRV, /* (3) */
        &StartLineSensorThreadPositioning, /* (4) */
        (NTFY_MSK_PS_PSMSHADOW_AVAILABILITY), /* (5) */
        (NTFY_MSK_NONE), /* (6) */
        THREAD_STS_MSK_POS_MAIN, /* (7) */
        FALSE, /* (8) */
        THREAD_STS_NOEXIST, /* (9) */
        0 /* (10) */
    },
    {    /* Pos_gps */
        ETID_POS_GPS, /* (1) */
        kThreadNamePosGps, /* (2) */
        PNO_NAVI_GPS_MAIN, /* (3) */
        &StartGpsMainThreadPositioning, /* (4) */
        (NTFY_MSK_NONE), /* (5) */
        (NTFY_MSK_NONE), /* (6) */
        THREAD_STS_MSK_POS_MAIN, /* (7) */
        TRUE, /* (8) */
        THREAD_STS_NOEXIST, /* (9) */
        0 /* (10) */
    },
    {    /* Pos_gps_recv */
        ETID_POS_GPS_RECV, /* (1) */
        kThreadNamePosGpsRecv, /* (2) */
        PNO_NAVI_GPS_RCV, /* (3) */
        &StartGpsRecvThreadPositioning, /* (4) */
        (NTFY_MSK_NONE), /* (5) */
        (NTFY_MSK_NONE), /* (6) */
        THREAD_STS_MSK_POS_GPS, /* (7) */
        FALSE, /* (8) */
        THREAD_STS_NOEXIST, /* (9) */
        0 /* (10) */
    },
    {    /* Pos_gps_rollover */
        ETID_POS_GPS_ROLLOVER, /* (1) */
        kThreadNamePosGpsRollover, /* (2) */
        PNO_CLK_GPS, /* (3) */
        &StartGpsRolloverThreadPositioning, /* (4) */
        (NTFY_MSK_NS_BACKUPMGR_AVAILABILITY), /* (5) */
        (NTFY_MSK_NONE), /* (6) */
        THREAD_STS_MSK_POS_GPS, /* (7) */
        FALSE, /* (8) */
        THREAD_STS_NOEXIST, /* (9) */
        0 /* (10) */
    },
    {   /* Termination */
        ETID_POS_MAX, NULL, 0, NULL, NTFY_MSK_NONE, NTFY_MSK_NONE, 0, FALSE, THREAD_STS_NOEXIST, 0
    },
};

/* State Management Variables */
static bool g_start_flg = false;       /** Start Processed Flag                                */
static EnumExeSts_POS g_exe_sts;       /** Positioning running status                                 */
static EnumSetupMode_POS g_setup_mode; /** Thread activation mode                                  */
static uint8_t g_last_thread_sts;      /** Latest internal thread activation state                            */
static uint8_t g_last_srv_sts;         /** Latest service availability                            */
static uint8_t g_last_ntfy_sts;           /** Receive state of latest notification                                    */
static uint8_t g_last_num_of_thread;   /** Number of Current Startup Threads                                  */

/** Sub-thread creation table */
static ST_THREAD_CREATE_INFO* g_pos_thread_create_info;

/** Interprocess message receive buffer */
static uint8_t g_rcv_msg_buf[MAX_MSG_BUF_SIZE];

/** Dispatcher Registration Callback Table */
static const FrameworkunifiedProtocolCallbackHandler kPositioningPcbhs[] = {  // LCOV_EXCL_BR_LINE 11: unexpected branch
    {CID_THREAD_CREATE_COMP,                &PosThreadCreateComp                  }, /* Thread start completion notification */
    {CID_THREAD_STOP_COMP,                  &PosThreadStopComp                    }, /* Thread stop completion notice */
    {CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT,   &PosPosifRegisterListenerPkgSensorData},
    {CID_VEHICLEIF_DELIVERY_ENTRY,          &PosPosifRegisterListenerSensorData   },
    {CID_SENSORIF__CWORD82__REQUEST,              &PosPosifReqGpsSetting                },
    {CID_NAVIINFO_DELIVER,                  &PosPosifSetGpsInfo                   },
    {CID_VEHICLEIF_GET_VEHICLE_DATA,        &PosPosifGetGpsInfo                   },
    {CID_POSIF_SET_DATA,                    &PosPosifSetData                      },
    {CID_GPS_REQRESET,                      &PosPosifReqGpsReset                  },
};

static const FrameworkunifiedProtocolCallbackHandler kPositioningPcbhsVehicle[] = {  // LCOV_EXCL_BR_LINE 11: unexpected branch
    {CID_VEHICLESENS_VEHICLE_INFO,              &PosVehicleInfoRcv},
};

/** Dispatcher unregister command ID table */
static uint32_t g_positioning_cids[] = {
    CID_THREAD_CREATE_COMP,
    CID_THREAD_STOP_COMP,
    CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT,
    CID_VEHICLEIF_DELIVERY_ENTRY,
    CID_SENSORIF__CWORD82__REQUEST,
    CID_NAVIINFO_DELIVER,
    CID_VEHICLEIF_GET_VEHICLE_DATA,
    CID_POSIF_SET_DATA,
    CID_GPS_REQRESET,
};

static uint32_t g_positioning_cids_vehicle[] = {
    CID_VEHICLESENS_VEHICLE_INFO,
};



/** Stop request flag for GPS reception thread */
BOOL g_thread_stop_req;

/*---------------------------------------------------------------------------------*
 * Function                                                                        *
 *---------------------------------------------------------------------------------*/
/**
 * @brief
 *   FrameworkunifiedOnInitialization<br>
 *   Sends message to Notification Service
 *
 *   Mm 21 API perform initialization.<br>
 *   Generatings shared memories used by Vehicle function block..<br>
 *   Creates a sub-thread of the Vehicle feature block..
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 *            eFrameworkunifiedStatusFail    ABENDs
 */
EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
    RET_API ret_api;
    EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
    uint8_t* p_last_srv_sts = &g_last_srv_sts;
    uint8_t* p_last_thread_sts = &g_last_thread_sts;
    uint8_t* p_last_ntfy_sts = &g_last_ntfy_sts;
    ST_THREAD_CREATE_INFO** pp_thr_cre_info = &g_pos_thread_create_info;
    uint8_t* p_last_num_thr = &g_last_num_of_thread;
    BOOL* p_thr_stop_req = &g_thread_stop_req;
    EnumExeSts_POS* p_exe_sts = &g_exe_sts;
    EnumSetupMode_POS* pe_mode = &g_setup_mode;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    /* Global variable initialization */
    *p_last_srv_sts = 0;
    *p_last_thread_sts = 0;
    *p_last_ntfy_sts = 0;
    *pp_thr_cre_info = g_pos_thread_create_info_Grade1;
    *p_last_num_thr = 0;
    *p_thr_stop_req = FALSE;
    *p_exe_sts = EPOS_EXE_STS_STOP;
    *pe_mode = EPOS_SETUP_MODE_NORMAL;

    /* null check */
    if (h_app == NULL) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "h_app is NULL");
        e_status = eFrameworkunifiedStatusFail;
    } else {
        /* Positioning Base API initialization */
        ret_api = _pb_Setup_CWORD64_API(h_app);
        if (ret_api != RET_NORMAL) {  // LCOV_EXCL_BR_LINE 4: can not return error
            // LCOV_EXCL_START 8: invalid
            AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "_pb_Setup_CWORD64_API ERROR!! [ret_api = %d]",
                          ret_api);

            e_status = eFrameworkunifiedStatusFail;
            // LCOV_EXCL_STOP
        } else {
            /* Availability at Positioning startup,Set internal thread activation state */
            if (ChkUnitType(UNIT_TYPE_GRADE1) == true) {  /* GRADE1 environment */
                *pp_thr_cre_info = g_pos_thread_create_info_Grade1;
                FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, 
                              "*pp_thr_cre_info = g_pos_thread_create_info_Grade1");
            } else if (ChkUnitType(UNIT_TYPE_GRADE2) == true) {
              /*
               *  Note.
               *  This feature branches processing depending on the unit type.
               */
            } else {
                FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "_pb_ChkUnitType UNKNOWN!!");
            }

            /* Shared Memory Creation */
            PosCreateSharedMemory();

            if (e_status == eFrameworkunifiedStatusOK) {
                /* Register callback functions for Positioning internals */
                e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app,
                                                        "NS_ANY_SRC",
                                                        kPositioningPcbhs,
                                                        _countof(kPositioningPcbhs));  // LCOV_EXCL_BR_LINE 4:nsfw error
                if (e_status != eFrameworkunifiedStatusOK) {
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                  "FrameworkunifiedAttachCallbacksToDispatcher ERROR!! [e_status = %d]", e_status);
                }

                (void)VehicleIfAttachCallbacksToDispatcher(kPositioningPcbhsVehicle,
                                                            _countof(kPositioningPcbhsVehicle));
            }

            if (e_status == eFrameworkunifiedStatusOK) {  // LCOV_EXCL_BR_LINE 4: nsfw error
                /* Positioning/Availability registration */
                e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, POS_AVAILABILITY);
                if (eFrameworkunifiedStatusOK != e_status) {
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                  "FrameworkunifiedRegisterServiceAvailabilityNotification ERROR!! [e_status = %d]", e_status);
                }
            }

            if (e_status == eFrameworkunifiedStatusOK) {  // LCOV_EXCL_BR_LINE 4: nsfw error
                /* Positioning/Availability -> FALSE */
                e_status = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
                if (eFrameworkunifiedStatusOK != e_status) {
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                  "FrameworkunifiedPublishServiceAvailability ERROR!! [e_status = %d]", e_status);
                } else {
                    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> FALSE");
                }
            }

            /* Communication/Availability Changing notification registration */
            FrameworkunifiedSubscribeNotificationWithCallback(h_app, NTFY_Communication_Availability, &PosNotifyCommunicationAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* PS_CommUSB/Availability Changing notification registration */
            (void)CommUsbIfNotifyOnCommUSBAvailability(&PosNotifyCommUSBAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* PS_PSMShadow/Availability Changing notification registration */
            (void)PSMShadowIfNotifyOnPSMShadowAvailability(&PosNotifyPSMShadowAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)
            /* PS_PSMShadow Startup completion notification registration */
            (void)PSMShadowIfNotifyOnPSMShadowInitComp(&PosNotifyPSMShadowInitComp);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* Clock/Availability Changing notification registration */
            (void)ClockIfNotifyOnClockAvailability(&PosNotifyClockAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* NS_BackupMgr/Availability Changing notification registration */
            (void)BackupMgrIfNotifyOnBackupMgrAvailability(&PosNotifyNSBackupMgrAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* Regist Vehilce Availability Notification */
            (void)VehicleIfNotifyOnVehicleAvailability(&PosNotifyVehicleAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)

            /* DeviceDetectionServiceIf initialization */
            if (DevDetectSrvIfInitialize() == eFrameworkunifiedStatusOK) {
                /* SS_DevDetectSrv/Availability Changing notification registration */
                (void)DevDetectSrvIfNotifyOnDeviceDetectionAvailability(&PosNotifyDevDetectSrvAvailability);  // LCOV_EXCL_BR_LINE 6: not a branch  // NOLINT(whitespace/line_length)
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return e_status;
}

/**
 * @brief
 *   PositioningOnStartImpl
 */
static EFrameworkunifiedStatus PositioningOnStartImpl(const HANDLE hApp, const EPWR_SC_WAKEUP_TYPE wakeupType,
                                 const ESMDataResetModeInfo dataResetMode) {
    EnumExeSts_POS* p_exe_sts = &g_exe_sts;
    EnumSetupMode_POS* pe_mode = &g_setup_mode;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    if (g_start_flg == false) {
        g_start_flg = true;

        /* Running */
        *p_exe_sts = EPOS_EXE_STS_RUNNING;

        /* Cold start */
        if (wakeupType == epsstCOLDSTART) {
            FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "wakeupType:COLDSTART");

            *p_exe_sts = EPOS_EXE_STS_RUNNING_COLDSTART;

            /* Initialize GPS time setting information */
            PosBackupDataInit();
        } else {  /* Time of warm start */
            FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "wakeupType:WARMSTART");
        }

        /*  Time of factory initialization */
        if (dataResetMode == e_SS_SM_DATA_RESET_MODE_FACTORY) {
            FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "dataResetMode:FACTORYRESET");

            /* Set thread start mode to ""data reset start"" */
            *pe_mode = EPOS_SETUP_MODE_DATA_RESET;

            /* Initialize GPS time setting information */
            PosBackupDataInit();
        }

        PosCreateThread(hApp);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   FrameworkunifiedOnStart
 */
EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
    EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
    uint32_t size;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
    if (size != 0) {
        T_SS_SM_START_DataStructType* p_start_data;
        p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);

        ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return ret;
}

/**
 * @brief
 *   FrameworkunifiedOnStop
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 *            eFrameworkunifiedStatusFail    ABENDs
 */
EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
    EFrameworkunifiedStatus e_status;
    EnumExeSts_POS* p_exe_sts = &g_exe_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    /* null check */
    if (h_app == NULL) {  // LCOV_EXCL_BR_LINE 200: can not NULL
        // LCOV_EXCL_START 8: invalid
        AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "h_app is NULL");
        // LCOV_EXCL_STOP
    } else {
        *p_exe_sts = EPOS_EXE_STS_STOP;

        e_status = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
        if (eFrameworkunifiedStatusOK != e_status) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "FrameworkunifiedPublishServiceAvailability ERROR!! [e_status = %d]",
                          e_status);
        } else {
            FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> FALSE");
        }

        PosStopThread();

        g_start_flg = false;
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    /* Return end response to SM at timing after completion of internal thread stop */
    return eFrameworkunifiedStatusFail;
}

/**
 * @brief
 *   FrameworkunifiedOnPreStart
 */
EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
    EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
    uint32_t size;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
    if (size != 0) {
        T_SS_SM_START_DataStructType* p_start_data;
        p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);

        ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return ret;
}

/**
 * @brief
 *   FrameworkunifiedOnPreStop
 */
EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   FrameworkunifiedOnBackgroundStart
 */
EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
    EFrameworkunifiedStatus ret = eFrameworkunifiedStatusFail;
    uint32_t size;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    size = PosGetMsg(hApp, reinterpret_cast<void**>(&g_rcv_msg_buf), MAX_MSG_BUF_SIZE);
    if (size != 0) {
        T_SS_SM_START_DataStructType* p_start_data;
        p_start_data = reinterpret_cast<T_SS_SM_START_DataStructType*>(g_rcv_msg_buf);

        ret = PositioningOnStartImpl(hApp, p_start_data->wakeupType, p_start_data->dataResetMode);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return ret;
}

/**
 * @brief
 *   FrameworkunifiedOnBackgroundStop
 */
EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");
    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   FrameworkunifiedOnDestroy (Not mounted)
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 *            eFrameworkunifiedStatusFail    ABENDs
 */
EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) {  // LCOV_EXCL_START 14 Resident process, not called by NSFW
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}
// LCOV_EXCL_STOP

/**
 * @brief
 *   FrameworkunifiedOnDebugDump
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 *            eFrameworkunifiedStatusFail    ABENDs
 */
EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) {  // LCOV_EXCL_START 7: debug code
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    static uint8_t              buf_tmp[256];
    static uint8_t              buf_proc[128];
    static uint8_t              buf_thread[512];
    static uint8_t              buf_message[4][DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_mutex[3][DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_timer[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_event[9][DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_memory[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_other[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_nand[256];
    static uint8_t              buf_ram[256];
    static uint8_t              buf_gps_format_fail[512];
    static uint8_t              buf_antenna[256];
    static uint8_t              buf_gps_info[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_navi_info[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_deli_ctrl_tbl[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_deli_ctrl_tbl_mng[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_pkg_deli_tbl_mng[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_deli_pno_tbl[DEBUG_DUMP_MAX_SIZE];
    static uint8_t              buf_sys[128];
    int32_t                      i;
    ST_THREAD_CREATE_INFO*       p_thr_cre_info = g_pos_thread_create_info;
    ST_GPS_FIX_CNT               st_gps_fix_cnt;
    ST_GPS_SET_TIME              st_gps_set_time;
    uint8_t                      len_msg = 4;
    uint8_t                      len_mtx = 3;
    uint8_t                      len_evt = 9;
    EFrameworkunifiedStatus e_status;
    BOOL b_is_available;
    UNIT_TYPE e_type = UNIT_TYPE_NONE;
    u_int8                       sys_recv_flg;
    uint16_t                     wkn_rollover;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    memset(&buf_proc[0],           0x00, sizeof(buf_proc));
    memset(&buf_thread[0],         0x00, sizeof(buf_thread));
    memset(&buf_nand[0],           0x00, sizeof(buf_nand));
    memset(&buf_ram[0],            0x00, sizeof(buf_ram));
    memset(&buf_gps_format_fail[0],  0x00, sizeof(buf_gps_format_fail));
    memset(&buf_antenna[0],        0x00, sizeof(buf_antenna));
    memset(&buf_gps_info[0],        0x00, sizeof(buf_gps_info));
    memset(&buf_navi_info[0],       0x00, sizeof(buf_navi_info));
    memset(&buf_deli_ctrl_tbl[0],    0x00, sizeof(buf_deli_ctrl_tbl));
    memset(&buf_deli_ctrl_tbl_mng[0], 0x00, sizeof(buf_deli_ctrl_tbl_mng));
    memset(&buf_pkg_deli_tbl_mng[0],  0x00, sizeof(buf_pkg_deli_tbl_mng));
    memset(&buf_deli_pno_tbl[0],     0x00, sizeof(buf_deli_pno_tbl));
    memset(&buf_sys[0],            0x00, sizeof(buf_sys));

    for (i = 0; i < len_msg; i++) {
        memset(&buf_message[i][0], 0x00, sizeof(buf_message[i]));
    }
    for (i = 0; i < len_mtx; i++) {
        memset(&buf_mutex[i][0], 0x00, sizeof(buf_mutex[i]));
    }
    memset(&buf_timer[0],   0x00, sizeof(buf_timer));
    for (i = 0; i < len_evt; i++) {
        memset(&buf_event[i][0], 0x00, sizeof(buf_event[i]));
    }
    memset(&buf_memory[0],  0x00, sizeof(buf_memory));
    memset(&buf_other[0],   0x00, sizeof(buf_other));
    e_type = GetEnvSupportInfo();

    /* Availability status of related processes */
    snprintf(reinterpret_cast<char *>(&buf_proc[0]), sizeof(buf_proc),
            "Availability\n thread:0x%02x, srv:0x%02x, ntfy:0x%02x",
            g_last_thread_sts,  /* Latest internal thread activation state */
            g_last_srv_sts,     /* Latest service availability */
            g_last_ntfy_sts);   /* Receive state of latest notification         */

    /* Internal thread activation state */
    snprintf(reinterpret_cast<char *>(&buf_thread[0]), sizeof(buf_thread), "Thread");
    for (i = 0; i < ETID_POS_MAX; i++) {
        memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
        snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
                "\n [%d]id:%d, pno:0x%04x, name:%16s, sts:0x%02x, order:%d",
                i,
                p_thr_cre_info->id,       /* Thread ID */
                p_thr_cre_info->pno,      /* Process number */
                p_thr_cre_info->p_name,    /* Thread name */
                p_thr_cre_info->status,   /* Thread activation state */
                p_thr_cre_info->order);   /* Boot Sequence */
        _pb_strcat(reinterpret_cast<char *>(&buf_thread[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));
        p_thr_cre_info++;
    }

    /* BASE API control data */
    /*   Message */
    (void)_pb_GetDebugMsgMngTbl(&buf_message[0][0], &len_msg);
    /*   Mutex */
    (void)_pb_GetDebugMutexMngTbl(&buf_mutex[0][0], &len_mtx);
    /*   Timer */
    (void)_pb_GetDebugTimerMngTbl(&buf_timer[0]);
    /*   Event */
    (void)_pb_GetDebugEventMngTbl(&buf_event[0][0], &len_evt);
    /*   Shared Memory */
    (void)_pb_GetDebugMemoryMngTbl(&buf_memory[0]);
    /*   Other */
    (void)_pb_GetDebugOtherMngTbl(&buf_other[0]);

    /* NAND data */
    snprintf(reinterpret_cast<char *>(&buf_nand[0]), sizeof(buf_nand), "NAND");
    /*   GPS fix count */
    memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
    memset(&st_gps_fix_cnt, 0x00, sizeof(st_gps_fix_cnt));

    e_status = BackupMgrIfBackupDataRd(D_BK_ID_POS_GPS_FIX_CNT,
                                        0,
                                        &st_gps_fix_cnt,
                                        sizeof(st_gps_fix_cnt), &b_is_available);
    snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
            "\n %20s rd:0x%08x av:%d, 3d:%d, 2d:%d, else:%d, dmy:0x%02x%02x%02x%02x",
            "GPS_FIX_CNT",
            e_status,
            b_is_available,
            st_gps_fix_cnt.ul3d,
            st_gps_fix_cnt.ul2d,
            st_gps_fix_cnt.ul_else,
            st_gps_fix_cnt.dummy[0], st_gps_fix_cnt.dummy[1], st_gps_fix_cnt.dummy[2], st_gps_fix_cnt.dummy[3]);
    _pb_strcat(reinterpret_cast<char *>(&buf_nand[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));

    /* Data of the backup RAM */
    snprintf(reinterpret_cast<char *>(&buf_ram[0]), sizeof(buf_ram), "BackupRAM");
    /*   Set GPS date and time(Information) */
    memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
    (void)memset( reinterpret_cast<void *>(&st_gps_set_time), 0, (size_t)sizeof(st_gps_set_time) );

    e_status = BackupMgrIfBackupDataRd(D_BK_ID_POS_GPS_TIME_SET_INFO,
                                        0,
                                        &st_gps_set_time,
                                        sizeof(st_gps_set_time),
                                        &b_is_available);
    snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
            "\n %20s rd:0x%08x av:%d, %d/%d/%d %d:%d:%d  flag:0x%02x",
            "GPS_TIME_SET_INFO",
            e_status,
            b_is_available,
            st_gps_set_time.year,
            st_gps_set_time.month,
            st_gps_set_time.date,
            st_gps_set_time.hour,
            st_gps_set_time.minute,
            st_gps_set_time.second,
            st_gps_set_time.flag);
    _pb_strcat(reinterpret_cast<char *>(&buf_ram[0]), reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp));

    if (e_type == UNIT_TYPE_GRADE1) {
        /* GPS format anomaly counter  */ /* There is no lock control. */
        (void)DEVGpsGetDebugGpsFormatFailCnt(&buf_gps_format_fail[0]);

        /* GPS antenna connection status */ /* There is no lock control. */
        VEHICLESENS_DATA_MASTER st_sns_data = {0};
        (void)VehicleSensGetGpsAntenna(&st_sns_data, VEHICLESENS_GETMETHOD_LINE);
        snprintf(reinterpret_cast<char *>(&buf_antenna[0]), sizeof(buf_antenna),
            "Antenna\n sts:0x%02x",
            st_sns_data.uc_data[0]);

        /* GPS position time */ /* There is no lock control. */
        (void)VehicleSensGetDebugPosDate(&buf_gps_info[0], VEHICLESENS_GETMETHOD_GPS);
    }

    if (e_type == UNIT_TYPE_GRADE1) {
        /* Navigation position time */ /* There is no lock control. */
        (void)VehicleSensGetDebugPosDate(&buf_navi_info[0], VEHICLESENS_GETMETHOD_NAVI);
    }

    /* Delivery table */ /* There is no lock control. */
    (void)VehicleSensGetDebugDeliveryCtrlTbl(&buf_deli_ctrl_tbl[0]);
    (void)VehicleSensGetDebugDeliveryCtrlTblMng(&buf_deli_ctrl_tbl_mng[0]);
    (void)VehicleSensGetDebugPkgDeliveryTblMng(&buf_pkg_deli_tbl_mng[0]);
    (void)VehicleSensGetDebugDeliveryPnoTbl(&buf_deli_pno_tbl[0]);

    /* Initial Sensor Data Status from Sys */
    sys_recv_flg = LineSensDrvGetSysRecvFlag();
    snprintf(reinterpret_cast<char *>(&buf_sys[0]), sizeof(buf_sys),
            "Rx 1st Sensor Data %d\n", sys_recv_flg);

    /* Dump Information Out */
    PosOutputDebugDumpLog(&buf_proc[0]);
    PosOutputDebugDumpLog(&buf_thread[0]);
    for (i = 0; i < len_msg; i++) {
        PosOutputDebugDumpLog(&buf_message[i][0]);
    }
    for (i = 0; i < len_mtx; i++) {
        PosOutputDebugDumpLog(&buf_mutex[i][0]);
    }
    PosOutputDebugDumpLog(&buf_timer[0]);
    for (i = 0; i < len_evt; i++) {
        PosOutputDebugDumpLog(&buf_event[i][0]);
    }
    PosOutputDebugDumpLog(&buf_memory[0]);
    PosOutputDebugDumpLog(&buf_other[0]);
    PosOutputDebugDumpLog(&buf_nand[0]);
    PosOutputDebugDumpLog(&buf_ram[0]);
    if (e_type == UNIT_TYPE_GRADE1) {
        PosOutputDebugDumpLog(&buf_gps_format_fail[0]);
        PosOutputDebugDumpLog(&buf_antenna[0]);
        PosOutputDebugDumpLog(&buf_gps_info[0]);
    }
    if (e_type == UNIT_TYPE_GRADE1) {
        PosOutputDebugDumpLog(&buf_navi_info[0]);
    }
    PosOutputDebugDumpLog(&buf_deli_ctrl_tbl[0]);
    PosOutputDebugDumpLog(&buf_deli_ctrl_tbl_mng[0]);
    PosOutputDebugDumpLog(&buf_pkg_deli_tbl_mng[0]);
    PosOutputDebugDumpLog(&buf_deli_pno_tbl[0]);
    PosOutputDebugDumpLog(&buf_sys[0]);

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}
// LCOV_EXCL_STOP

/**
 * @brief
 *   FrameworkunifiedCreateStateMachine (Not mounted)
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 *            eFrameworkunifiedStatusFail    ABENDs
 */
EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) {  // LCOV_EXCL_START 8 : dead code
  AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}
// LCOV_EXCL_STOP

#ifdef __cplusplus
extern "C" {
#endif
/**
 * @brief
 *   Common processing after thread startup
 *
 *   Thread naming,Create Message Queue,Thread activation response
 *
 * @param[in]  h_app Application handle
 * @param[in]  e_tid    Thread ID
 *
 * @return  Thread activation mode
 */
EnumSetupMode_POS PosSetupThread(HANDLE h_app, EnumTID_POS e_tid) {
    RET_API ret;
    ST_THREAD_CREATE_INFO* p_thr_cre_info = g_pos_thread_create_info;
    ST_THREAD_CREATE_INFO* p_info;
    ST_THREAD_SETUP_INFO st_setup_info;
    ST_THREAD_SETUP_INFO* pst_setup_info = &st_setup_info;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    p_info = p_thr_cre_info + e_tid;

    /* Application handle setting */
    _pb_SetAppHandle(h_app);

    /* Create Message Queue */
    _pb_CreateMsg(p_info->pno);

    /* Get Thread Startup Information */
    pst_setup_info->e_mode = EPOS_SETUP_MODE_NORMAL;
    (void)PosGetMsg(h_app, reinterpret_cast<void**>(&pst_setup_info), sizeof(ST_THREAD_SETUP_INFO));
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "[e_mode = %d]", pst_setup_info->e_mode);

    /* Issue thread creation completion notice */
    ret = _pb_SndMsg_Ext(POS_THREAD_NAME, CID_THREAD_CREATE_COMP, sizeof(EnumTID_POS), (const void*)&e_tid, 0);
    if (ret != RET_NORMAL) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg_Ext ERROR!! [ret = %d]", ret);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return pst_setup_info->e_mode;
}

/**
 * @brief
 *   Common Processing at Thread Stop
 *
 *   Thread stop response,Thread destruction
 *
 * @param[in]  e_tid    Thread ID
 */
void PosTeardownThread(EnumTID_POS e_tid) {
    RET_API ret;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    /* Issue thread stop completion notice */
    ret = _pb_SndMsg_Ext(POS_THREAD_NAME, CID_THREAD_STOP_COMP, sizeof(EnumTID_POS), (const void*)&e_tid, 0);
    if (ret != RET_NORMAL) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg_Ext ERROR!! [ret = %d]", ret);
    }

    /* Thread destruction */
    _pb_ExitThread((DWORD)0);

    /* don't arrive here */
    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    return;  // LCOV_EXCL_LINE 8 : cannot reach here
}

#ifdef __cplusplus
}
#endif

/**
 * @brief
 *   FrameworkunifiedCreateChildThread dummy functions
 *
 * @param[in]  Application handle
 *
 * @return  eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosStopThreadDummy(HANDLE h_app) {  // LCOV_EXCL_START 8 : dead code
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}
// LCOV_EXCL_STOP

/*---------------------------------------------------------------------------------*
 * Local Function                                                                  *
 *---------------------------------------------------------------------------------*/
/**
 * @brief
 *   Communication services Availability notification callback functions
 *
 * @param[in]  h_app    Application handle
 *
 * @return eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosNotifyCommunicationAvailability(HANDLE h_app) {
    BOOL isAvailable;
    uint8_t* pLastSrvSts = &g_last_srv_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
    if (isAvailable == TRUE) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Communication/Availability -> TRUE");

        *pLastSrvSts |= NTFY_MSK_COMMUNICATION_AVAILABILITY;

        PosCreateThread(h_app);

        /* Sensor Log Initial Processing(First)*/
        SensLogInitialize(NULL);
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Communication/Availability -> FALSE");

        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_COMMUNICATION_AVAILABILITY);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   CommUSB services Availability notification callback functions
 *
 * @param[in]  h_app    Application handle
 *
 * @return eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosNotifyCommUSBAvailability(HANDLE h_app) {
    BOOL isAvailable;
    uint8_t* pLastSrvSts = &g_last_srv_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
    if (isAvailable == TRUE) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_CommUSB/Availability -> TRUE");

        *pLastSrvSts |= NTFY_MSK_PS_COMMUSB_AVAILABILITY;

        PosCreateThread(h_app);
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_CommUSB/Availability -> FALSE");

        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_PS_COMMUSB_AVAILABILITY);
    }

    /* Update CommUSB I/F availability */
    CommUsbIfSetAvailability(isAvailable);

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   PSMShadow services Availability notification callback functions
 *
 * @param[in]  h_app    Application handle
 *
 * @return eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosNotifyPSMShadowAvailability(HANDLE h_app) {
    BOOL isAvailable;
    uint8_t* pLastSrvSts = &g_last_srv_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
    if (isAvailable == TRUE) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_PSMShadow/Availability -> TRUE");

        *pLastSrvSts |= NTFY_MSK_PS_PSMSHADOW_AVAILABILITY;

        PosCreateThread(h_app);
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PS_PSMShadow/Availability -> FALSE");

        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_PS_PSMSHADOW_AVAILABILITY);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   PSMShadow services Callback function for notifying completion of startup
 *
 * @param[in]  h_app    Application handle
 *
 * @return eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosNotifyPSMShadowInitComp(HANDLE h_app) {
    uint8_t* pLastNtfySts = &g_last_ntfy_sts;
    ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    *pLastNtfySts |= NTFY_MSK_PS_PSMSHADOW_INIT_COMP;

    /* When the Pos_Sens thread is started */
    if (((pThrCreInfo + ETID_POS_SENS)->status) == THREAD_STS_CREATED) {
        /* External pin status request */
        LineSensDrvExtTermStsReq();
    }

    PosCreateThread(h_app);

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Clock Services Availability Notification Callback Functions
 *
 * @param[in]  h_app Application handle
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosNotifyClockAvailability(HANDLE h_app) {
    BOOL isAvailable;
    uint8_t* pLastSrvSts = &g_last_srv_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    isAvailable = FrameworkunifiedIsServiceAvailable(h_app);
    if (isAvailable == TRUE) {
        FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Clock/Availability -> TRUE");

        *pLastSrvSts |= NTFY_MSK_CLOCK_AVAILABILITY;

        PosCreateThread(h_app);
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Clock/Availability -> FALSE");

        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_CLOCK_AVAILABILITY);
    }

    /* Update Clock I/F availability */
    ClockIfSetAvailability(isAvailable);

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   NS_BackupMgr service Availability notification callback function
 *
 * @param[in]  h_app Application handle
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosNotifyNSBackupMgrAvailability(HANDLE h_app) {
    EnumExeSts_POS* pExeSts = &g_exe_sts;
    uint8_t* pLastSrvSts = &g_last_srv_sts;
    ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
    EnumSetupMode_POS* peMode = &g_setup_mode;
    BOOL bIsAvailable;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    bIsAvailable = FrameworkunifiedIsServiceAvailable(h_app);

    /* Update BackupMgr I/F  availability */
    BackupMgrIfSetAvailability(bIsAvailable);

    if (bIsAvailable == TRUE) {
        FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "NS_BackupMgr/Availability -> TRUE");

        *pLastSrvSts |= NTFY_MSK_NS_BACKUPMGR_AVAILABILITY;

        /* Executing after cold start or during factory initialization*/
        if ((*pExeSts == EPOS_EXE_STS_RUNNING_COLDSTART) ||
            (*peMode == EPOS_SETUP_MODE_DATA_RESET)) {
            /* Backup RAM initialization */
            PosBackupDataInit();
        }

        /* When the GPS management thread is started */
        if (((pThrCreInfo + ETID_POS_GPS)->status) == THREAD_STS_CREATED) {
            if ((*pExeSts == EPOS_EXE_STS_RUNNING_COLDSTART) ||
                (*peMode == EPOS_SETUP_MODE_DATA_RESET)) {
              // GPS reset request.
              SENSOR_INTERNAL_MSG_BUF  msg_buf = {};
              T_APIMSG_MSGBUF_HEADER  *msg_hdr = &msg_buf.hdr;
              msg_hdr->hdr.cid         = CID_GPS_REQRESET;
              msg_hdr->hdr.msgbodysize = sizeof(POS_RESETINFO);
              POS_RESETINFO           *msg_data    = reinterpret_cast<POS_RESETINFO *>(&msg_buf.data);
              msg_data->mode           = GPS_RST_COLDSTART;

              RET_API ret = _pb_SndMsg(PNO_NAVI_GPS_MAIN, sizeof(msg_buf), &msg_buf, 0);
              if (ret != RET_NORMAL) {
                  FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "_pb_SndMsg ERROR!! [ret=%d]", ret);
              }
            }

            /* Backup data read request to GSP management thread */
            (void)DEVGpsSndBackupDataLoadReq();
        }
        /* Enable Diag Code Writing */
        DiagSrvIfSetRegistrationPermission(TRUE);

        PosCreateThread(h_app);
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "NS_BackupMgr/Availability -> FALSE");

        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_NS_BACKUPMGR_AVAILABILITY);
        /* Write prohibited dialog code */
        DiagSrvIfSetRegistrationPermission(FALSE);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   SS_DevDetectSrv service Availability Callback Functions
 *
 * @param[in]  h_app Application handle
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosNotifyDevDetectSrvAvailability(HANDLE h_app) {
    EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
    BOOL isAvailable;
    BOOL bDummy;
    uint8_t* pLastSrvSts = &g_last_srv_sts;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    isAvailable = FrameworkunifiedIsServiceAvailable(h_app);

    /* Update DevDetectSrv I/F availability */
    DevDetectSrvIfSetAvailability(isAvailable);

    if (isAvailable == TRUE) {
        FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SS_DevDetectSrv/Availability -> TRUE");
        *pLastSrvSts |= NTFY_MSK_SS_DEVDETSRV_AVAILABILITY;

        eStatus = DevDetectSrvIfOpenSessionRequest(&bDummy);
        if (eFrameworkunifiedStatusOK != eStatus) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                "DeviceDetectionServiceIf OpenSession ERROR!! [eStatus = %d]", eStatus);
        } else {
            eStatus = DevDetectSrvIfNotifyOnOpenSessionAck(&PosOnDevDetectOpenSessionAck, &bDummy);
            if (eFrameworkunifiedStatusOK != eStatus) {
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                    "DeviceDetectionServiceIf NotifyOnOpenSessionAck ERROR!! [eStatus = %d]", eStatus);
            }
        }
    } else {
        FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SS_DevDetectSrv/Availability -> FALSE");
        *pLastSrvSts = static_cast<uint8_t>(*pLastSrvSts & ~NTFY_MSK_SS_DEVDETSRV_AVAILABILITY);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}


/**
 * @brief
 *   Vehicle Availability notification callback functions
 *
 * @param[in]  h_app    Application handle
 *
 * @return eFrameworkunifiedStatusOK    Normal completion
 *
 */
static EFrameworkunifiedStatus PosNotifyVehicleAvailability(HANDLE h_app) {
  BOOL isAvailable;
  uint8_t* pLastSrvSts = &g_last_srv_sts;

  FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

  isAvailable = FrameworkunifiedIsServiceAvailable(h_app);

  /* Update Vechile I/F Abailability */
  VehicleIf_SetAvailability(isAvailable);

  if (isAvailable == TRUE) {
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Vehicle/Availability -> TRUE");

    *pLastSrvSts |= NTFY_MSK_VS_VEHICLE_AVAILABILITY;

    if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_SPEED)) {
      FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry SPEED ERROR");
    }

    if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_REV)) {
      FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry REV ERROR");
    }

    if (eFrameworkunifiedStatusFail == VehicleIfDeliveryEntry(VEHICLE_DID_SPEED_PULSE_VEHICLE)) {
      FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleIfDeliveryEntry SPEED PULSE ERROR");
    }

    PosCreateThread(h_app);

  } else {
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Vehicle/Availability -> FALSE");

    *pLastSrvSts &= ~NTFY_MSK_VS_VEHICLE_AVAILABILITY;
  }

  FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");

  return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Shared Memory Creation for Positioning Function
 *
 * @return    RET_NORMAL    Normal completion
 *            RET_ERROR    ABENDs
 */
static void PosCreateSharedMemory(void) {
    RET_API    ret_api = RET_NORMAL;
    void        *mod_exec_dmy; /* Module data pointer(dummy) */
    int           retry; /* Retry counter */
    ST_SHAREDATA *p_shm_tbl;

    /* Configure Shared Data Generating Tables */
    p_shm_tbl = g_sharedata_tbl;

    while ( *(p_shm_tbl->share_data_name) != '\0' ) {
        for ( retry = 0; retry < DATMOD_RETRY; retry++ ) {
            /* Shared Memory Generation */
            ret_api = _pb_CreateShareData(p_shm_tbl->share_data_name, p_shm_tbl->data_size, &mod_exec_dmy);
            if (ret_api == RET_NORMAL) {  /* If successful */
                /* Set the shared memory status flag to ""Before initialization (0)"" */
                *reinterpret_cast<u_int32 *>(mod_exec_dmy) = DATMOD_PREINIT;

                break;
            } else {  /* In the event of failure */
                /* Error Handling */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                              "_pb_CreateShareData ERROR [ret_api:%d]",
                              ret_api);
            }
        }

        if (retry >= DATMOD_RETRY) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_CreateShareData failed more %d times.",
                                               DATMOD_RETRY);

            _pb_Exit();
            /* don't arrive here. */
        }

        /* Next shared memory generation */
        p_shm_tbl++;
    }

    return;
}

/**
 * @brief
 *   Positioning in-process thread creation
 *
 * @param[in]  hApp application handles
 */
static void PosCreateThread(HANDLE h_app) {
    HANDLE    threadHandle;
    EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
    EnumSetupMode_POS* peMode = &g_setup_mode;
    int32_t i;
    uint8_t* pLastSrvSts = &g_last_srv_sts;
    uint8_t* pLastThreadSts = &g_last_thread_sts;
    uint8_t* pLastNtfySts = &g_last_ntfy_sts;
    EnumExeSts_POS* pExeSts = &g_exe_sts;
    ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    for (i = 0; i < ETID_POS_MAX; i++) {
        if ((pThrCreInfo->status == THREAD_STS_NOEXIST) && (pThrCreInfo->routine != NULL)) {
            FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, 
                          "i=%d, mskThread=0x%02x, *pLastThreadSts=0x%02x,"\
                          "mskAvailable=0x%02x, *pLastSrvSts=0x%02x, mskNtfy=0x%02x, *pLastNtfySts=0x%02x",
                          i,
                          pThrCreInfo->msk_thread,
                          *pLastThreadSts,
                          pThrCreInfo->msk_available,
                          *pLastSrvSts,
                          pThrCreInfo->msk_ntfy,
                          *pLastNtfySts);

            if ((*pExeSts != EPOS_EXE_STS_STOP)
                && ((((pThrCreInfo->msk_thread) & (*pLastThreadSts)) == pThrCreInfo->msk_thread)
                    || (pThrCreInfo->msk_thread == 0))
                && ((((pThrCreInfo->msk_available) & (*pLastSrvSts)) == pThrCreInfo->msk_available)
                    || (pThrCreInfo->msk_available == NTFY_MSK_NONE))
                && ((((pThrCreInfo->msk_ntfy) & (*pLastNtfySts)) == pThrCreInfo->msk_ntfy)
                    || (pThrCreInfo->msk_ntfy == NTFY_MSK_NONE))) {
                if (pThrCreInfo->pno == PNO_LINE_SENS_DRV || \
                    pThrCreInfo->pno == PNO_NAVI_GPS_MAIN || \
                    pThrCreInfo->pno == PNO_NAVI_GPS_RCV  ||
                    pThrCreInfo->pno == PNO_CLK_GPS) {
                        (pThrCreInfo->routine)(h_app);
                } else {
                    /* Thread creation */
                    threadHandle = FrameworkunifiedCreateChildThread(h_app,
                                                       (PCSTR)(pThrCreInfo->p_name),
                                                       pThrCreInfo->routine,
                                                       &PosStopThreadDummy);
                    if (threadHandle == NULL) {  /* If the thread creation fails */
                        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                      "FrameworkunifiedCreateChildThread ERROR!! [tHandle=%p]",
                                      threadHandle);
                        _pb_Exit();
                        /* don't arrive here. */
                    } else {
                        /* Thread activation (Notify the startup mode) */
                        eStatus = FrameworkunifiedStartChildThread(h_app,
                                                      threadHandle,
                                                      sizeof(EnumSetupMode_POS),
                                                      reinterpret_cast<void*>(peMode));
                        if (eStatus != eFrameworkunifiedStatusOK) {
                            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                          "FrameworkunifiedStartChildThread ERROR!! [eStatus=%d, name=%s]",
                                          eStatus,
                                          pThrCreInfo->p_name);
                        } else {
                            pThrCreInfo->status = THREAD_STS_CREATING;
                            FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "name=%s", pThrCreInfo->p_name);
                        }
                    }
                }
            }
        }

        pThrCreInfo++;
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return;
}


/**
 * @brief
 *   Termination of Positioning in-process threads
 */
static void PosStopThread(void) {
    RET_API ret;
    ST_THREAD_CREATE_INFO* p_thr_cre_info = g_pos_thread_create_info;
    BOOL *p_thr_stop_req = &g_thread_stop_req;
    uint8_t uc_msg = 0;
    uint8_t uc_order = 0;
    PNO us_pno = 0;
    int32_t i;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    for (i = 0; i < ETID_POS_MAX; i++) {
        if (uc_order < p_thr_cre_info->order) {
            uc_order = p_thr_cre_info->order;
            us_pno = p_thr_cre_info->pno;
        }
        p_thr_cre_info++;
    }

    if (uc_order != 0) {
        /* Send Thread Termination Request */
        if (us_pno == PNO_NAVI_GPS_RCV) {
            /* Pos_gps_recv Only thread flag control */
            *p_thr_stop_req = TRUE;
        } else {
            ret = PosSndMsg(us_pno, CID_THREAD_STOP_REQ, &uc_msg, sizeof(uc_msg));
            if (ret != RET_NORMAL) {
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                              "PosSndMsg ERROR!! [ret = %d]",
                              ret);
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return;
}

/**
 * @brief
 *   Backup RAM initialization
 */
static void PosBackupDataInit(void) {
    UNIT_TYPE e_type = UNIT_TYPE_NONE;
    EFrameworkunifiedStatus e_status;
    BOOL b_is_available;
    ST_GPS_SET_TIME st_gps_set_time;

    (void)memset( reinterpret_cast<void *>(&st_gps_set_time), 0, (size_t)sizeof(st_gps_set_time) );

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    e_type = GetEnvSupportInfo();
    if (e_type == UNIT_TYPE_GRADE1) {
        /* Set GPS date and time */
        e_status = BackupMgrIfBackupDataWt(D_BK_ID_POS_GPS_TIME_SET_INFO,
                                            &st_gps_set_time,
                                            0,
                                            sizeof(st_gps_set_time),
                                            &b_is_available);
        FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "D_BK_ID_POS_GPS_TIME_SET_INFO:W:Clear");
        if (e_status != eFrameworkunifiedStatusOK) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "BackupMgrIfBackupDataWt ERROR!! [e_status=%d, b_is_available=%d]",
                          e_status,
                          b_is_available);
        }
    } else if (e_type == UNIT_TYPE_GRADE2) {
      /*
       *  Note.
       *  This feature branches processing depending on the unit type.
       */
    } else {
        /* No processing */
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return;
}

/**
 * @brief
 *   Callback function for registering the dispatcher()
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosThreadCreateComp(HANDLE h_app) {
    EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
    uint8_t* pRcvMsg;
    uint32_t size;
    uint8_t* pLastThreadSts = &g_last_thread_sts;
    ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
    uint8_t* pLastNumThr = &g_last_num_of_thread;
    uint8_t* pLastSrvSts = &g_last_srv_sts;
    uint8_t* pLastNtfySts = &g_last_ntfy_sts;
    EnumTID_POS eTid;
    int32_t i;
    static BOOL isSetAvailable = FALSE;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        (*pLastNumThr)++;

        eTid = *(reinterpret_cast<EnumTID_POS*>(pRcvMsg));

        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X]",
                      (pThrCreInfo + eTid)->p_name,
                      CID_THREAD_CREATE_COMP);

        /* Thread Management Variable Updates */
        *pLastThreadSts = static_cast<uint8_t>(*pLastThreadSts | (0x1u << eTid));
        (pThrCreInfo + eTid)->status = THREAD_STS_CREATED;
        (pThrCreInfo + eTid)->order  = *pLastNumThr;

        /* Individual processing of started threads */
        switch (eTid) {
            case ETID_POS_SENS: /* When sensor driver thread startup is completed */
            {
                /* When PSMShadow startup completion notice has been received */
                if (((NTFY_MSK_PS_PSMSHADOW_INIT_COMP) & (*pLastNtfySts)) == NTFY_MSK_PS_PSMSHADOW_INIT_COMP) {
                    /* External pin status request */
                    LineSensDrvExtTermStsReq();
                }
                break;
            }
            case ETID_POS_GPS: /* When the GPS management thread has started */
            {
                /* NSBackupMgr/Availability=When TRUE notification has been received */
                if (((NTFY_MSK_NS_BACKUPMGR_AVAILABILITY) & (*pLastSrvSts)) == NTFY_MSK_NS_BACKUPMGR_AVAILABILITY) {
                    /* Backup data read request to GSP management thread */
                    (void)DEVGpsSndBackupDataLoadReq();
                }
                break;
            }
            default: /* Other thread startup completion time */
                break;
        }

        PosCreateThread(h_app);

        for (i = 0; i < ETID_POS_MAX; i++) {
            if ((pThrCreInfo->is_depended == TRUE) && (pThrCreInfo->status != THREAD_STS_CREATED)) {
                break; /* Positioning/Availability->TRUE condition does not meet */
            }
            pThrCreInfo++;
        }

        if ((i == ETID_POS_MAX) && (isSetAvailable == FALSE)) {
            /* Positionig/Availability -> TRUE */
            eStatus = FrameworkunifiedPublishServiceAvailability(h_app, TRUE);
            if (eFrameworkunifiedStatusOK != eStatus) {
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                              "FrameworkunifiedPublishServiceAvailability ERROR!! [eStatus = %d]",
                              eStatus);
            } else {
                FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Positioning/Availability -> TRUE");
                isSetAvailable = TRUE;
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}


/**
 * @brief
 *   Callback function for registering the dispatcher()
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosThreadStopComp(HANDLE h_app) {
    EFrameworkunifiedStatus eStatus;
    BOOL bIsAvailable;

    uint8_t* pRcvMsg;
    uint32_t size;
    uint8_t* pLastThreadSts = &g_last_thread_sts;
    ST_THREAD_CREATE_INFO* pThrCreInfo = g_pos_thread_create_info;
    uint8_t* pLastNumThr = &g_last_num_of_thread;
    BOOL *pThrStopReq = &g_thread_stop_req;
    EnumTID_POS eTid;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        (*pLastNumThr)--;

        eTid = *(reinterpret_cast<EnumTID_POS*>(pRcvMsg));

        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X]",
                      (pThrCreInfo + eTid)->p_name,
                      CID_THREAD_STOP_COMP);

        *pLastThreadSts = static_cast<uint8_t>(*pLastThreadSts & ~(0x1u << eTid));

        (pThrCreInfo + eTid)->status = THREAD_STS_NOEXIST;
        (pThrCreInfo + eTid)->order  = 0;

        if ((pThrCreInfo + eTid)->pno == PNO_NAVI_GPS_RCV) {
            *pThrStopReq = FALSE;
        }
    }

    PosStopThread();

    /* When all threads have stopped */
    if (*pLastThreadSts == 0) {
        /* Unregister callback function */
        eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(h_app,
                                                   "NS_ANY_SRC",
                                                   (const PUI_32)g_positioning_cids,
                                                   _countof(g_positioning_cids), NULL);
        if (eStatus != eFrameworkunifiedStatusOK) {  /* In the event of failure */
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "PositioningDetachCallbacksToDispatcher Failed in FrameworkunifiedOnStop [eStatus:%d]",
                          eStatus);
        }

        /* Sensor log stop processing */
        SensLogTerminate();

        /* DeviceDetectionServiceIf termination process */
        eStatus = DevDetectSrvIfUnRegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV, &bIsAvailable);
        if (eStatus != eFrameworkunifiedStatusOK) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "DeviceDetectionServiceIf UnRegisterEvent ERROR!! [sts:%d, ava:%d]",
                          eStatus,
                          bIsAvailable);
        } else {
            eStatus = DevDetectSrvIfCloseSessionRequest(&bIsAvailable);
            if (eFrameworkunifiedStatusOK != eStatus) {
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                              "DeviceDetectionServiceIf CloseSession ERROR!! [sts=%d, ava:%d]",
                              eStatus,
                              bIsAvailable);
            }
        }

        (void)VehicleIfDetachCallbacksFromDispatcher((const PUI_32)g_positioning_cids_vehicle,
                                                            _countof(g_positioning_cids_vehicle));

        /* Releasing Base API Resources */
        _pb_Teardown_CWORD64_API();

        /* Stop processing completion response */
        SendInterfaceunifiedOnStopResponseToSystemManager(eFrameworkunifiedStatusOK);
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(POS_RegisterListenerPkgSensData)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifRegisterListenerPkgSensorData(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    EventID ulEventId;
    PCSTR pName;
    static const PCSTR pNone = "-";

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        pName = _pb_CnvPno2Name((reinterpret_cast<SENSOR_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
        if (pName == NULL) {
            pName = pNone;
        }
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X",
                      pName,
                      CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT);

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
            /* Event Generation */
            ulEventId = PosCreateEvent((reinterpret_cast<SENSOR_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
            if (ulEventId != 0) {
                /* Event publishing */
                ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, SENSOR_RET_ERROR_INNER);
                if (ret != RET_NORMAL) {
                    /* Event issuance failure */
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SetEvent ERROR!! [ret = %d]", ret);
                }
                /* Event deletion */
                (void)PosDeleteEvent(ulEventId);
            } else {
                /* Event generation failure */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosCreateEvent ERROR!!");
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(POS_RegisterListenerSensData)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifRegisterListenerSensorData(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    EventID ulEventId;
    PCSTR pName;
    static const PCSTR pNone = "-";

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        pName = _pb_CnvPno2Name((reinterpret_cast<VEHICLE_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
        if (pName == NULL) {
            pName = pNone;
        }
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X]",
                      pName,
                      CID_VEHICLEIF_DELIVERY_ENTRY);

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_VEHICLEIF_DELIVERY_ENTRY, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
            /* Event Generation */
            ulEventId = VehicleCreateEvent((reinterpret_cast<VEHICLE_MSG_DELIVERY_ENTRY_DAT*>(pRcvMsg))->pno);
            if (ulEventId != 0) {
                /* Event publishing */
                ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, SENSOR_RET_ERROR_INNER);
                if (ret != RET_NORMAL) {
                    /* Event issuance failure */
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SetEvent ERROR!! [ret = %d]", ret);
                }
                /* Event deletion */
                (void)VehicleDeleteEvent(ulEventId);
            } else {
                /* Event generation failure */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(POS_ReqGPSSetting)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifReqGpsSetting(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    uint8_t ucResult = SENSLOG_RES_FAIL;

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:-][CID:0x%X]",
                      CID_SENSORIF__CWORD82__REQUEST);
        ucResult = SENSLOG_RES_SUCCESS;

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_SENSORIF__CWORD82__REQUEST, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
        }
    }

    SensLogWriteInputData(SENSLOG_DATA_I_GPSSET, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
                          ucResult, SENSLOG_ON, SENSLOG_ON);
    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(POS_SetGPSInfo)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifSetGpsInfo(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    uint8_t ucResult = SENSLOG_RES_FAIL;

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:-][CID:0x%X]",
                      CID_NAVIINFO_DELIVER);
        ucResult = SENSLOG_RES_SUCCESS;

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_NAVI_GPS_MAIN, CID_NAVIINFO_DELIVER, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
        }
    }
    SensLogWriteInputData(SENSLOG_DATA_I_GPSINF, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
                         ucResult, SENSLOG_ON, SENSLOG_ON);
    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(POS_GetGPSInfo)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifGetGpsInfo(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    EventID ulEventId;
    PCSTR pName;
    static const PCSTR pNone = "-";

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        pName = _pb_CnvPno2Name((reinterpret_cast<VEHICLE_MSG_GET_VEHICLE_DATA_DAT*>(pRcvMsg))->pno);
        if (pName == NULL) {
            pName = pNone;
        }
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X]",
                      pName,
                      CID_VEHICLEIF_GET_VEHICLE_DATA);

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_VEHICLEIF_GET_VEHICLE_DATA, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
            /* Event Generation */
            ulEventId = VehicleCreateEvent((reinterpret_cast<VEHICLE_MSG_GET_VEHICLE_DATA_DAT*>(pRcvMsg))->pno);
            if (ulEventId != 0) {
                /* Event publishing */
                ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
                if (ret != RET_NORMAL) {
                    /* Event issuance failure */
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                  "_pb_SetEvent ERROR!! [ret = %d]",
                                  ret);
                }
                /* Event deletion */
                (void)VehicleDeleteEvent(ulEventId);
            } else {
                /* Event generation failure */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(CID_POSIF_SET_DATA)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifSetData(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    EventID ulEventId;
    PCSTR pName;
    static const PCSTR pNone = "-";
    uint8_t ucResult = SENSLOG_RES_FAIL;

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        ucResult = SENSLOG_RES_SUCCESS;

        pName = _pb_CnvPno2Name((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->pno);
        if (pName == NULL) {
            pName = pNone;
        }
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X][DID:0x%X]",
                      pName,
                      CID_POSIF_SET_DATA,
                      (reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did);

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_POSIF_SET_DATA, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
            if ((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did == VEHICLE_DID_SETTINGTIME) {
                /* GPS time setting(When waiting for completion of an event, an event is issued. */
                /* Event Generation */
                ulEventId = VehicleCreateEvent((reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->pno);
                if (ulEventId != 0) {
                    /* Event publishing */
                    ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
                    if (ret != RET_NORMAL) {
                        /* Event issuance failure */
                        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                      "_pb_SetEvent ERROR!! [ret = %d]",
                                      ret);
                    }
                    /* Event deletion */
                    (void)VehicleDeleteEvent(ulEventId);
                } else {
                    /* Event generation failure */
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
                }
            }
        }
    }
    SensLogWriteInputData(SENSLOG_DATA_I_UNSPECIFIED,
                          (reinterpret_cast<POS_MSGINFO*>(pRcvMsg))->did,
                          0,
                          pRcvMsg,
                          static_cast<uint16_t>(size),
                          ucResult,
                          SENSLOG_ON,
                          SENSLOG_ON);
    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(CID_GPS_REQRESET)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosPosifReqGpsReset(HANDLE h_app) {
    RET_API ret;
    uint8_t* pRcvMsg;
    uint32_t size;
    EventID ulEventId;
    PCSTR pName;
    static const PCSTR pNone = "-";
    uint8_t ucResult = SENSLOG_RES_FAIL;

    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "+");

    pRcvMsg = g_rcv_msg_buf;

    size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
    if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
        ucResult = SENSLOG_RES_SUCCESS;

        pName = _pb_CnvPno2Name((reinterpret_cast<POS_RESETINFO*>(pRcvMsg))->snd_pno);
        if (pName == NULL) {
            pName = pNone;
        }
        FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, 
                      "Get message = [Sender:%s][CID:0x%X]",
                      pName,
                      CID_GPS_REQRESET);

        /* Send Messages to Internal Thread */
        ret = PosSndMsg(PNO_NAVI_GPS_MAIN, CID_GPS_REQRESET, pRcvMsg, size);
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);

            /* Event Generation */
            ulEventId = VehicleCreateEvent((reinterpret_cast<POS_RESETINFO*>(pRcvMsg))->snd_pno);
            if (0 != ulEventId) {
                /* Event publishing */
                ret = _pb_SetEvent(ulEventId, SAPI_EVSET_ABSOLUTE, POS_RET_ERROR_INNER);
                if (ret != RET_NORMAL) {
                    /* Event issuance failure */
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                  "_pb_SetEvent ERROR!! [ret = %d]",
                                  ret);
                }
                /* Event deletion */
                (void)VehicleDeleteEvent(ulEventId);
            } else {
                /* Event generation failure */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleCreateEvent ERROR!!");
            }
        }
    }

    SensLogWriteInputData(SENSLOG_DATA_I_GPSRST, 0, 0, pRcvMsg, static_cast<uint16_t>(size),
                          ucResult, SENSLOG_ON, SENSLOG_ON);
    FRAMEWORKUNIFIEDLOG(ZONE_28, __FUNCTION__, "-");

    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Callback function for registering the dispatcher(CID_VEHICLESENS_VEHICLE_INFO)
 *
 *   Send a message to an internal thread.
 *
 * @param[in]  h_app    Application handle
 *
 * @return    eFrameworkunifiedStatusOK    Normal completion
 */
static EFrameworkunifiedStatus PosVehicleInfoRcv(HANDLE h_app) {
  LSDRV_MSG_LSDATA_DAT_G line_sns_data;
  RET_API ret = RET_NORMAL;

  memset(&line_sns_data, 0, sizeof(line_sns_data));
  LSDRV_MSG_LSDATA_DAT_G *p_line_sns_data = &line_sns_data;
  VEHICLE_UNIT_MSG_VSINFO *p_vehicle_msg = NULL;
  uint32_t size = 0;
  uint16_t us_speed = 0;

  uint8_t* pRcvMsg = g_rcv_msg_buf;

  size = PosGetMsg(h_app, reinterpret_cast<void**>(&pRcvMsg), MAX_MSG_BUF_SIZE);
  if (size != 0) {  // LCOV_EXCL_BR_LINE 4: nsfw error
    memset(p_line_sns_data, 0x00, sizeof(line_sns_data));
    p_vehicle_msg = (reinterpret_cast<VEHICLE_UNIT_MSG_VSINFO*>(pRcvMsg));
    switch (p_vehicle_msg->data.did) {
      // SPEED info
      case VEHICLE_DID_SPEED:
      {
        p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
        p_line_sns_data->st_data[LSDRV_SPEED_KMPH].ul_did = POSHAL_DID_SPEED_KMPH;
        p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_size = POS_SNDMSG_DTSIZE_2;
        p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_sns_cnt = 0;

        char p_env_variable[VP_MAX_LENGTH];

        VP_GetEnv("VP__CWORD31__SPEED", p_env_variable);
        if (0 == strcmp(p_env_variable, "direct")) {
          int16_t speed = 0;
          // To obtain the vehicle speed from Direct lanes,1 to 2 bytes of received data
          memcpy(&speed, &p_vehicle_msg->data.data[0], sizeof(speed));
          us_speed = static_cast<uint16_t>(abs(speed));
          // Unit conversion [km/h] -> [0.01km/h]
          us_speed = static_cast<uint16_t>(us_speed * 100);
        } else if (0 == strcmp(p_env_variable, "CAN")) {
          UINT16 speed = 0;
          // To obtain the vehicle speed from CAN,2 to 3 bytes of received data
          memcpy(&speed, &p_vehicle_msg->data.data[1], sizeof(speed));
          us_speed = static_cast<uint16_t>(abs(speed));
          // Unit conversion [km/h] -> [0.01km/h]
          us_speed = static_cast<uint16_t>(us_speed * 100);
        } else {
          // In case of invalid value, the vehicle speed is acquired by CAN.
          UINT16 speed = 0;
          memcpy(&speed, &p_vehicle_msg->data.data[1], sizeof(speed));
          us_speed = static_cast<uint16_t>(abs(speed));
          // Unit conversion [km/h] -> [0.01km/h]
          us_speed = static_cast<uint16_t>(us_speed * 100);
        }

        memcpy(&p_line_sns_data->st_data[LSDRV_SPEED_KMPH].uc_data[0], &us_speed, sizeof(us_speed));

        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
                        reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));

        break;
      }
      // REV information
      case VEHICLE_DID_REV:
      {
        p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
        p_line_sns_data->st_data[LSDRV_REV].ul_did = VEHICLE_DID_REV;
        p_line_sns_data->st_data[LSDRV_REV].uc_size = POS_SNDMSG_DTSIZE_1;
        p_line_sns_data->st_data[LSDRV_REV].uc_sns_cnt = 0;
        p_line_sns_data->st_data[LSDRV_REV].uc_data[0] = p_vehicle_msg->data.data[0];

        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
                            reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));
        break;
      }

      // Speed Pulse information
      case VEHICLE_DID_SPEED_PULSE_VEHICLE:
      {
        p_line_sns_data->uc_data_num = LSDRV_KINDS_MAX;
        p_line_sns_data->st_data[LSDRV_SPEED_PULSE].ul_did = POSHAL_DID_SPEED_PULSE;
        p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_size = sizeof(float);
        p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_sns_cnt = 0;

        memcpy(&p_line_sns_data->st_data[LSDRV_SPEED_PULSE].uc_data[0],
                                            &p_vehicle_msg->data.data[0], sizeof(float));

        p_line_sns_data->st_data[LSDRV_PULSE_TIME].ul_did = POSHAL_DID_PULSE_TIME;
        p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_size = sizeof(float);
        p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_sns_cnt = 0;

        memcpy(&p_line_sns_data->st_data[LSDRV_PULSE_TIME].uc_data[0],
                       &p_vehicle_msg->data.data[sizeof(float)], sizeof(float));

        ret = PosSndMsg(PNO_VEHICLE_SENSOR, CID_LINESENS_VEHICLE_DATA_G,
                            reinterpret_cast<void*>(p_line_sns_data), sizeof(line_sns_data));

        break;
      }
      default:
        break;
    }

    if (ret != RET_NORMAL) {
      FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosSndMsg ERROR!! [ret = %d]", ret);
    }
  }
  return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   Get Message
 *
 *   Get messages received by the dispatcher
 *
 * @param[in]  h_app  Application handle
 * @param[out] p_buf  Pointer to receive data storage buffer
 * @param[in]  Sizes of size receive data storage buffers
 *
 * @return    Received data size(0:Receiving error)
 */
static uint32_t PosGetMsg(HANDLE h_app, void** p_buf, uint32_t size) {
    EFrameworkunifiedStatus eStatus;
    uint32_t ulSize = 0;
    void* pRcvBuf;

    /* null check */
    if ((h_app == NULL) || (p_buf == NULL)) {  // LCOV_EXCL_BR_LINE 200: can not NULL
        // LCOV_EXCL_START 8: invalid
        AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                      "Argument ERROR!! [h_app = %p, p_buf = %p]",
                      h_app,
                      p_buf);
        // LCOV_EXCL_STOP
    } else {
        /* Check the size of received data */
        ulSize = FrameworkunifiedGetMsgLength(h_app);
        if (ulSize > size) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
                          "Message size ERROR!! [ulSize = %d, maxsize = %d]",
                          ulSize,
                          size);
            ulSize = 0;
        } else {
            /* Obtain data */
            eStatus = FrameworkunifiedGetDataPointer(h_app, &pRcvBuf);
            if (eStatus == eFrameworkunifiedStatusOK) {
                *p_buf = pRcvBuf;
            } else if (eStatus == eFrameworkunifiedStatusInvldBufSize) {
                eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, *p_buf, ulSize);
                /* When acquisition fails */
                if (eStatus != eFrameworkunifiedStatusOK) {
                    FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
                                  "FrameworkunifiedGetMsgDataOfSize ERROR [eStatus:%d]",
                                  eStatus);
                    ulSize = 0;
                }
            } else {
                /* When acquisition fails */
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
                              "FrameworkunifiedGetDataPointer ERROR [eStatus:%d]",
                              eStatus);
                ulSize = 0;
            }
        }
    }

    return ulSize;
}

/**
 * @brief
 *   Sending Messages for Internal Threads
 *
 *   Adds a header to the message received by the dispatcher and sends it to the internal thread..
 *
 * @param[in]  pno       PNO
 * @param[in]  cid      Command ID
 * @param[in]  p_msg_body  Sent message body
 * @param[in]  size         Send message size
 *
 * @return    RET_NORAML    Normal completion
 *            RET_ERROR    ABENDs
 */
static RET_API PosSndMsg(PNO pno, CID cid, void* p_msg_body, uint32_t size) {
    RET_API    ret = RET_NORMAL;
    T_APIMSG_MSGBUF_HEADER* p;
    static u_int8 sndMsgBuf[MAX_MSG_BUF_SIZE + sizeof(T_APIMSG_MSGBUF_HEADER)];

    if ((p_msg_body == NULL) || (size > MAX_MSG_BUF_SIZE)) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR!! [p_msg_body = %p, size = %d]", p_msg_body, size);
        ret = RET_ERROR;
    } else {
        p = reinterpret_cast<T_APIMSG_MSGBUF_HEADER*>(sndMsgBuf);

        /* Message header addition */
        p->hdr.cid = cid;
        p->hdr.msgbodysize = static_cast<uint16_t>(size);

        /* Copy of the data section */
        memcpy((p + 1), p_msg_body, size);

        /* Send a message to an internal thread */
        ret = _pb_SndMsg(pno, static_cast<uint16_t>(size + sizeof(T_APIMSG_MSGBUF_HEADER)), p, 0);
        /* When transmission fails */
        if (ret != RET_NORMAL) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SndMsg ERROR [ret = %d]", ret);
            ret = RET_ERROR;
        }
    }

    return ret;
}

/**
 * @brief
 *   SS_DevDetectSrv service OpenSessionAck Callback Functions
 *
 * @param  none
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosOnDevDetectOpenSessionAck(HANDLE h_app) {
    EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
    BOOL bIsAvailable;

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    eStatus = DevDetectSrvIfDecodeOpenSessionResponse(&bIsAvailable);
    if (eFrameworkunifiedStatusOK != eStatus) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                      "DeviceDetectionServiceIf OpenSession ERROR!! [sts=%d, ava=%d]", eStatus, bIsAvailable);
    } else {
        eStatus = DevDetectSrvIfRegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV,
                                                                 &PosOnDevDetectEvent,
                                                                 NULL,
                                                                 &bIsAvailable);
        if (eFrameworkunifiedStatusOK != eStatus) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                          "DeviceDetectionServiceIf RegisterEvent ERROR!! [sts=%d, ava=%d]", eStatus, bIsAvailable);
        } else {
            eStatus = DevDetectSrvIfNotifyOnCloseSessionAck(&PosOnDevDetectCloseSessionAck, &bIsAvailable);
            if (eFrameworkunifiedStatusOK != eStatus) {
                FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
                                     "DeviceDetectionServiceIf CloseSessionAck ERROR!! [sts=%d, ava=%d]",
                              eStatus,
                              bIsAvailable);
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   SS_DevDetectSrv service CloseSessionAck Callback Functions
 *
 * @param  none
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosOnDevDetectCloseSessionAck(HANDLE h_app) {
    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");

    /* Sensor log stop processing */
    SensLogTerminate();

    FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "-");
    return eFrameworkunifiedStatusOK;
}

/**
 * @brief
 *   SS_DevDetectSrv service Event Callback Functions
 *
 * @param  none
 *
 * @return eFrameworkunifiedStatusOK successful completion
 */
static EFrameworkunifiedStatus PosOnDevDetectEvent(HANDLE h_app) {
    SS_MediaDetectInfo stMedia;
    EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
    uint32_t ulSize = 0;
    uint8_t mode;

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "+");

    /* Check the size of received data */
    ulSize = FrameworkunifiedGetMsgLength(h_app);
    if (ulSize > sizeof(SS_MediaDetectInfo)) {
        FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Message size ERROR!! [ulSize = %d, maxsize = %ld]",
                      ulSize, sizeof(SS_MediaDetectInfo));
        ulSize = 0;
    } else {
        /* Obtain data */
        eStatus = FrameworkunifiedGetMsgDataOfSize(h_app, &stMedia, ulSize);
        /* When acquisition fails */
        if (eStatus != eFrameworkunifiedStatusOK) {
            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
                          "FrameworkunifiedGetMsgDataOfSize ERROR [eStatus:%d]", eStatus);
            ulSize = 0;
        } else {
            if (eUSB == stMedia.dev_type) {
                if (TRUE == stMedia.bIsDeviceAvailable) {
                    /* Mount detection */
                    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, 
                        "USB mounted sts=[%d] path=[%s] fusedav=[%d]",
                        stMedia.bIsDeviceAvailable, stMedia.deviceMountpath, stMedia.bIsFuseDav);

                    /* NOTE: bIsFuseDav -> From the _CWORD80_'s point of view,                          */
                    /*       TRUE(With a USB flash drive inserted into the _CWORD84_,Be synchronized on the FuseDav)*/
                    /*       FALSE(USB memory is inserted into the _CWORD80_.)                        */

                    if (stMedia.bIsFuseDav == FALSE) {
                        /* Inserted into your USB port */
                        FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "SensLog Initialize start.");
                        /*  Get Debug/Release setting */
                        eStatus = NsLogGetFrameworkunifiedLogFlag(POSITIONINGLOG_FLAG_NAVI, &mode);
                        /* When acquisition fails */
                        if (eStatus != eFrameworkunifiedStatusOK) {
                            FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
                            "NsLogGetFrameworkunifiedLogFlag ERROR [eStatus:%d]", eStatus);
                        } else {
                            if (mode == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG) {
                                /* Sensor Log Initial Processing(Normal)*/
                                SensLogInitialize(reinterpret_cast<uint8_t *>(stMedia.deviceMountpath));
                            }
                        }
                    } else {
                        /* TODO: Mounts (FuseDav synchronized) that are not inserted into your device's USB port are not supported. */
                        FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "Don't output SensLog.");
                    }
                } else {
                    /* Unmount detection */
                    if (stMedia.bIsFuseDav == FALSE) {
                        /* When it is unmounted to its own USB */
                        FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, 
                            "USB umounted sts=[%d] fusedav=[%d]",
                            stMedia.bIsDeviceAvailable, stMedia.bIsFuseDav);

                        /* Sensor log stop processing */
                        SensLogTerminate();
                    }
                }
            }
        }
    }

    FRAMEWORKUNIFIEDLOG(ZONE_INIT, __FUNCTION__, "-");
    return eStatus;
}

/**
 * @brief Debug dump log output function
 *
 * @param[in]    *p_buf Pointer to the output string
 */
static void PosOutputDebugDumpLog(uint8_t* p_buf) {  // LCOV_EXCL_START 7: uesd only in FrameworkunifiedOnDebugDump
    AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
    SSDEBUGDUMP("%s\n", p_buf);
    MilliSecSleep(1);
    return;
}
// LCOV_EXCL_STOP