2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 * Module : POSITIONING
22 * Common I/F service functionality
24 #include <vehicle_service/positioning_base_library.h>
25 #include <vehicle_service/POS_define.h>
26 #include <vehicle_service/POS_common_API.h>
27 #include "POS_common_private.h"
28 #include "Vehicle_API_private.h"
29 #include "POS_private.h"
33 * Latitude and longitude informationDelivery registration
35 * Registering Latitude and Longitude Information Delivery
37 * @param[in] hApp HANDLE - Application handle
38 * @param[in] notifyName PCSTR - Destination thread name
39 * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
40 * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating)
41 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
43 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
44 * POS_RET_ERROR_BUFFULL Buffer-full<br>
45 * POS_RET_ERROR_INNER Internal error<br>
46 * POS_RET_ERROR_PARAM Parameter error<br>
47 * POS_RET_ERROR_NOSUPPORT Unsupported environment
50 POS_RET_API POS_RegisterListenerLonLat(HANDLE hApp, // NOLINT(readability/nolint)
51 PCSTR notifyName, // NOLINT(readability/nolint)
52 uint8_t ucCtrlFlg, // NOLINT(readability/nolint)
53 uint8_t ucDeliveryTiming, // NOLINT(readability/nolint)
54 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
55 POS_RET_API ret = POS_RET_NORMAL; /* Return value of this function */
56 SENSOR_RET_API ret_sens = SENSOR_RET_NORMAL; /* API return value */
57 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
58 DID did = VEHICLE_DID_LOCATION_LONLAT; /* Data ID */
60 /* Internal debug log output */
61 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
63 /* Arguments & Support Configuration Check */
64 if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
65 (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
66 /* Change delivery timing,Terminate as a parameter error except update */
67 ret = POS_RET_ERROR_PARAM;
68 } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
69 /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
70 ret = POS_RET_ERROR_PARAM;
71 } else if (hApp == NULL) {
72 /* If the handler is NULL, the process terminates with an error. */
73 ret = POS_RET_ERROR_PARAM;
74 } else if (notifyName == NULL) {
75 /* If the thread name is NULL, it terminates with an abnormal parameter. */
76 ret = POS_RET_ERROR_PARAM;
78 /* Positioning Base API initialization */
79 _pb_Setup_CWORD64_API(hApp);
81 /* Supported HW Configuration Check */
82 type = GetEnvSupportInfo();
84 if (UNIT_TYPE_GRADE1 == type) {
87 if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
88 did = VEHICLE_DID_LOCATION_LONLAT;
89 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
90 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
91 did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
93 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
94 ret = POS_RET_ERROR_PARAM;
96 } else if (UNIT_TYPE_GRADE2 == type) {
99 * This feature branches processing depending on the unit type.
101 ret = POS_RET_ERROR_NOSUPPORT;
103 /* Environment error */
104 ret = POS_RET_ERROR_NOSUPPORT;
108 /* Delivery registration */
109 if (ret == POS_RET_NORMAL) {
110 /* Delivery registry SensorAPI calls */
111 ret_sens = PosRegisterListenerProc(notifyName, /* Destination thread name */
113 ucCtrlFlg, /* Delivery control */
114 ucDeliveryTiming); /* Delivery timing */
116 /* Decision of delivery registration result */
117 if (ret_sens == SENSOR_RET_NORMAL) {
118 ret = POS_RET_NORMAL;
119 } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
120 ret = POS_RET_ERROR_PARAM;
121 } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
122 ret = POS_RET_ERROR_BUFFULL;
123 } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
124 ret = POS_RET_ERROR_RESOURCE;
126 ret = POS_RET_ERROR_INNER;
130 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
136 * Altitude information delivery registration
138 * Register for the delivery of altitude information
140 * @param[in] hApp HANDLE - Application handle
141 * @param[in] notifyName PCSTR - Destination thread name
142 * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
143 * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating)
144 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
146 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
147 * POS_RET_ERROR_PARAM Parameter error<br>
148 * POS_RET_ERROR_NOSUPPORT Unsupported environment
151 POS_RET_API POS_RegisterListenerAltitude(HANDLE hApp, // NOLINT(readability/nolint)
152 PCSTR notifyName, // NOLINT(readability/nolint)
153 uint8_t ucCtrlFlg, // NOLINT(readability/nolint)
154 uint8_t ucDeliveryTiming, // NOLINT(readability/nolint)
155 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
156 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
157 SENSOR_RET_API ret_sens = SENSOR_RET_NORMAL; /* API return value */
158 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
159 DID did = VEHICLE_DID_LOCATION_ALTITUDE; /* Data ID */
161 /* Internal debug log output */
162 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
164 /* Arguments & Support Configuration Check */
165 if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
166 (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
167 /* Change delivery timing,Terminate as a parameter error except update */
168 ret = POS_RET_ERROR_PARAM;
169 } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
170 /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
171 ret = POS_RET_ERROR_PARAM;
172 } else if (hApp == NULL) {
173 /* If the handler is NULL, the process terminates with an error. */
174 ret = POS_RET_ERROR_PARAM;
175 } else if (notifyName == NULL) {
176 /* If the thread name is NULL, it terminates with an abnormal parameter. */
177 ret = POS_RET_ERROR_PARAM;
179 /* Positioning Base API initialization */
180 _pb_Setup_CWORD64_API(hApp);
182 /* Supported HW Configuration Check */
183 type = GetEnvSupportInfo();
184 if (UNIT_TYPE_GRADE1 == type) {
186 ret = POS_RET_NORMAL;
187 if ((ucGetMethod == SENSOR_GET_METHOD_GPS) ||
188 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
189 did = VEHICLE_DID_LOCATION_ALTITUDE;
191 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
192 ret = POS_RET_ERROR_PARAM;
194 } else if (UNIT_TYPE_GRADE2 == type) {
197 * This feature branches processing depending on the unit type.
199 ret = SENSOR_RET_ERROR_NOSUPPORT;
201 /* Environment error */
202 ret = SENSOR_RET_ERROR_NOSUPPORT;
206 /* Delivery registration */
207 if (ret == POS_RET_NORMAL) {
208 /* Delivery registry SensorAPI calls */
209 ret_sens = PosRegisterListenerProc(notifyName, /* Destination thread name */
211 ucCtrlFlg, /* Delivery control */
212 ucDeliveryTiming); /* Delivery timing */
214 /* Decision of delivery registration result */
215 if (ret_sens == SENSOR_RET_NORMAL) {
216 ret = POS_RET_NORMAL;
217 } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
218 ret = POS_RET_ERROR_PARAM;
219 } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
220 ret = POS_RET_ERROR_BUFFULL;
221 } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
222 ret = POS_RET_ERROR_RESOURCE;
224 ret = POS_RET_ERROR_INNER;
227 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
233 * Vehicle Speed Information Transmission Registration
235 * Register delivery of vehicle speed information
237 * @param[in] hApp HANDLE - Application handle
238 * @param[in] notifyName PCSTR - Destination thread name
239 * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
240 * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating)
241 * @param[in] ucGetMethod uint8_t - Acquisition method(POS/Navigation/Not specified)
243 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
244 * POS_RET_ERROR_BUFFULL Buffer-full<br>
245 * POS_RET_ERROR_INNER Internal error<br>
246 * POS_RET_ERROR_PARAM Parameter error<br>
247 * POS_RET_ERROR_NOSUPPORT Unsupported environment
250 POS_RET_API POS_RegisterListenerSpeed(HANDLE hApp, // NOLINT(readability/nolint)
251 PCSTR notifyName, // NOLINT(readability/nolint)
252 uint8_t ucCtrlFlg, // NOLINT(readability/nolint)
253 uint8_t ucDeliveryTiming, // NOLINT(readability/nolint)
254 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
255 POS_RET_API ret = POS_RET_NORMAL; /* Return value of this function */
256 SENSOR_RET_API ret_sens = SENSOR_RET_NORMAL; /* API return value */
257 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
258 DID did; /* Data ID */
260 /* Internal debug log output */
261 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
263 /* Arguments & Support Configuration Check */
264 if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
265 (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
266 /* Change delivery timing,Terminate as a parameter error except update */
267 ret = POS_RET_ERROR_PARAM;
268 } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
269 /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
270 ret = POS_RET_ERROR_PARAM;
271 } else if (hApp == NULL) {
272 /* If the handler is NULL, the process terminates with an error. */
273 ret = POS_RET_ERROR_PARAM;
274 } else if (notifyName == NULL) {
275 /* If the thread name is NULL, it terminates with an abnormal parameter. */
276 ret = POS_RET_ERROR_PARAM;
278 /* Positioning Base API initialization */
279 _pb_Setup_CWORD64_API(hApp);
281 /* Supported HW Configuration Check */
282 type = GetEnvSupportInfo();
283 if (UNIT_TYPE_GRADE1 == type) {
285 ret = POS_RET_NORMAL;
286 if (ucGetMethod == SENSOR_GET_METHOD_POS) {
287 did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
288 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
289 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
290 did = VEHICLE_DID_MOTION_SPEED_NAVI;
292 ret = POS_RET_ERROR_PARAM;
294 } else if (UNIT_TYPE_GRADE2 == type) {
297 * This feature branches processing depending on the unit type.
299 ret = POS_RET_ERROR_NOSUPPORT;
301 /* Environment error */
302 ret = POS_RET_ERROR_NOSUPPORT;
306 /* Delivery registration */
307 if (ret == POS_RET_NORMAL) {
308 /* Delivery registry SensorAPI calls */
309 ret_sens = PosRegisterListenerProc(notifyName, /* Destination thread name */
311 ucCtrlFlg, /* Delivery control */
312 ucDeliveryTiming); /* Delivery timing */
314 /* Decision of delivery registration result */
315 if (ret_sens == SENSOR_RET_NORMAL) {
316 ret = POS_RET_NORMAL;
317 } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
318 ret = POS_RET_ERROR_PARAM;
319 } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
320 ret = POS_RET_ERROR_BUFFULL;
321 } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
322 ret = POS_RET_ERROR_RESOURCE;
324 ret = POS_RET_ERROR_INNER;
328 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
334 * Compass Information Transmission Register
336 * Register the delivery of the vehicle orientation information
338 * @param[in] hApp HANDLE - Application handle
339 * @param[in] notifyName PCSTR - Destination thread name
340 * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
341 * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating)
342 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
344 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
345 * POS_RET_ERROR_PARAM Parameter error<br>
346 * POS_RET_ERROR_NOSUPPORT Unsupported environment
349 POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/nolint)
350 PCSTR notifyName, // NOLINT(readability/nolint)
351 uint8_t ucCtrlFlg, // NOLINT(readability/nolint)
352 uint8_t ucDeliveryTiming, // NOLINT(readability/nolint)
353 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
354 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
355 SENSOR_RET_API ret_sens = SENSOR_RET_NORMAL; /* API return value */
356 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
357 DID did = VEHICLE_DID_MOTION_HEADING; /* TODO VEHICLE_DID_LOCATION_HEADING Missing */
360 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
362 /* Arguments & Support Configuration Check */
363 if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
364 (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
365 /* Change delivery timing,Terminate as a parameter error except update */
366 ret = POS_RET_ERROR_PARAM;
367 } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
368 /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
369 ret = POS_RET_ERROR_PARAM;
370 } else if (hApp == NULL) {
371 /* If the handler is NULL, the process terminates with an error. */
372 ret = POS_RET_ERROR_PARAM;
373 } else if (notifyName == NULL) {
374 /* If the thread name is NULL, it terminates with an abnormal parameter. */
375 ret = POS_RET_ERROR_PARAM;
377 /* Positioning Base API initialization */
378 _pb_Setup_CWORD64_API(hApp);
380 /* Supported HW Configuration Check */
381 type = GetEnvSupportInfo();
382 if (UNIT_TYPE_GRADE1 == type) {
384 ret = POS_RET_NORMAL;
385 if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
386 did = VEHICLE_DID_MOTION_HEADING;
387 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
388 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
389 did = VEHICLE_DID_MOTION_HEADING_NAVI;
391 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
392 ret = POS_RET_ERROR_PARAM;
394 } else if (UNIT_TYPE_GRADE2 == type) {
397 * This feature branches processing depending on the unit type.
399 ret = SENSOR_RET_ERROR_NOSUPPORT;
401 /* Environment error */
402 ret = SENSOR_RET_ERROR_NOSUPPORT;
406 /* Delivery registration */
407 if (ret == POS_RET_NORMAL) {
408 /* Delivery registry SensorAPI calls */
409 ret_sens = PosRegisterListenerProc(notifyName, /* Destination thread name */
411 ucCtrlFlg, /* Delivery control */
412 ucDeliveryTiming); /* Delivery timing */
414 /* Decision of delivery registration result */
415 if (ret_sens == SENSOR_RET_NORMAL) {
416 ret = POS_RET_NORMAL;
417 } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
418 ret = POS_RET_ERROR_PARAM;
419 } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
420 ret = POS_RET_ERROR_BUFFULL;
421 } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
422 ret = POS_RET_ERROR_RESOURCE;
424 ret = POS_RET_ERROR_INNER;
428 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
434 * Get Lltitude and longitude information
436 * Get Lltitude and longitude information
438 * @param[in] hApp HANDLE - Application handle
439 * @param[in] dat SENSORLOCATION_LONLATINFO_DAT* - Pointer to the acquired latitude/longitude information storage destination
440 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
442 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
443 * POS_RET_ERROR_PARAM Parameter error<br>
444 * POS_RET_ERROR_NOSUPPORT Unsupported environment<br>
445 * POS_RET_ERROR_INNER Internal error
448 POS_RET_API POS_GetLonLat(HANDLE hApp, // NOLINT(readability/nolint)
449 SENSORLOCATION_LONLATINFO_DAT *dat, // NOLINT(readability/nolint)
450 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
451 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
452 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
453 DID did = VEHICLE_DID_LOCATION_LONLAT; /* DID */
454 int32_t ret_get_proc; /* POS_GetProc Return Values */
456 /* Internal debug log output */
457 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
459 /* Arguments & Support Configuration Check */
461 /* If the handler is NULL, the process terminates with an error. */
462 ret = POS_RET_ERROR_PARAM;
463 } else if (dat == NULL) {
464 /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */
465 ret = POS_RET_ERROR_PARAM;
467 /* Positioning Base API initialization */
468 _pb_Setup_CWORD64_API(hApp);
470 /* Supported HW Configuration Check */
471 type = GetEnvSupportInfo();
472 if (UNIT_TYPE_GRADE1 == type) {
474 if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
475 did = VEHICLE_DID_LOCATION_LONLAT;
476 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
477 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
478 did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
480 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
481 ret = POS_RET_ERROR_PARAM;
483 } else if (UNIT_TYPE_GRADE2 == type) {
486 * This feature branches processing depending on the unit type.
488 ret = POS_RET_ERROR_NOSUPPORT;
490 /* Environment error */
491 ret = POS_RET_ERROR_NOSUPPORT;
495 /* Sensor information acquisition */
496 if (ret == POS_RET_NORMAL) {
497 /* Data acquisition process */
498 ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_LONLATINFO_DAT));
499 if (static_cast<int32_t>(sizeof(SENSORLOCATION_LONLATINFO_DAT)) > ret_get_proc) {
500 /* Failed to acquire */
501 if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
502 /* Insufficient resource */
503 ret = POS_RET_ERROR_RESOURCE;
505 ret = POS_RET_ERROR_INNER;
507 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
510 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
516 * Altitude information acquisition
518 * Obtain altitude information
520 * @param[in] hApp HANDLE - Application handle
521 * @param[in] dat SENSORLOCATION_ALTITUDEINFO_DAT* - Pointer to the acquired altitude information storage destination
522 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Not specified)
524 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
525 * POS_RET_ERROR_PARAM Parameter error<br>
526 * POS_RET_ERROR_NOSUPPORT Unsupported environment<br>
527 * POS_RET_ERROR_INNER Internal error
530 POS_RET_API POS_GetAltitude(HANDLE hApp, // NOLINT(readability/nolint)
531 SENSORLOCATION_ALTITUDEINFO_DAT *dat, // NOLINT(readability/nolint)
532 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
533 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
534 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
535 DID did = VEHICLE_DID_LOCATION_ALTITUDE; /* DID */
536 int32_t ret_get_proc; /* POS_GetProc Return Values */
538 /* Internal debug log output */
539 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
541 /* Arguments & Support Configuration Check */
543 /* If the handler is NULL, the process terminates with an error. */
544 ret = POS_RET_ERROR_PARAM;
545 } else if (dat == NULL) {
546 /* If the altitude data is NULL, it terminates with an abnormal parameter. */
547 ret = POS_RET_ERROR_PARAM;
549 /* Positioning Base API initialization */
550 _pb_Setup_CWORD64_API(hApp);
552 /* Supported HW Configuration Check */
553 type = GetEnvSupportInfo();
554 if (UNIT_TYPE_GRADE1 == type) {
556 if ((ucGetMethod == SENSOR_GET_METHOD_GPS) ||
557 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
558 did = VEHICLE_DID_LOCATION_ALTITUDE;
560 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
561 ret = POS_RET_ERROR_PARAM;
563 } else if (UNIT_TYPE_GRADE2 == type) {
566 * This feature branches processing depending on the unit type.
568 ret = POS_RET_ERROR_NOSUPPORT;
570 /* Environment error */
571 ret = POS_RET_ERROR_NOSUPPORT;
574 /* Sensor information acquisition */
575 if (ret == POS_RET_NORMAL) {
576 /* Data acquisition process */
577 ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_ALTITUDEINFO_DAT));
578 if (static_cast<int32_t>(sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)) > ret_get_proc) {
579 /* Failed to acquire */
580 if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
581 /* Insufficient resource */
582 ret = POS_RET_ERROR_RESOURCE;
584 ret = POS_RET_ERROR_INNER;
586 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
589 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
595 * Vehicle Speed Information Acquisition
597 * Obtain vehicle speed information
599 * @param[in] hApp HANDLE - Application handle
600 * @param[in] dat SENSORMOTION_SPEEDINFO_DAT* - Pointer to the acquired car speed information storage destination
601 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
603 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
604 * POS_RET_ERROR_PARAM Parameter error<br>
605 * POS_RET_ERROR_NOSUPPORT Unsupported environment<br>
606 * POS_RET_ERROR_INNER Internal error
609 POS_RET_API POS_GetSpeed(HANDLE hApp, // NOLINT(readability/nolint)
610 SENSORMOTION_SPEEDINFO_DAT *dat, // NOLINT(readability/nolint)
611 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
612 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
613 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
614 DID did; /* Data ID */
615 int32_t ret_get_proc; /* POS_GetProc Return Values */
617 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
619 /* If the handler is NULL, the process terminates with an error. */
620 ret = POS_RET_ERROR_PARAM;
621 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [hApp = %p]", hApp);
622 } else if (dat == NULL) {
623 /* When the pointer to the vehicle speed data storage destination is NULL, the pointer terminates with an error in the parameter. */
624 ret = POS_RET_ERROR_PARAM;
625 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [dat = %p]", dat);
627 /* Positioning Base API initialization */
628 _pb_Setup_CWORD64_API(hApp);
630 /* Supported HW Configuration Check */
631 type = GetEnvSupportInfo();
632 if (UNIT_TYPE_GRADE1 == type) {
634 ret = POS_RET_NORMAL;
635 if (ucGetMethod == SENSOR_GET_METHOD_POS) {
636 did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
637 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
638 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
639 did = VEHICLE_DID_MOTION_SPEED_NAVI;
641 /* End as a parameter error abnormality except for POS/unspecified acquisition method */
642 ret = POS_RET_ERROR_PARAM;
643 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
644 "Argument ERROR [type = %d, ucGetMethod = %d]",
647 } else if (UNIT_TYPE_GRADE2 == type) {
650 * This feature branches processing depending on the unit type.
652 ret = POS_RET_ERROR_NOSUPPORT;
654 /* Environment error */
655 ret = POS_RET_ERROR_NOSUPPORT;
656 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "GetEnvSupportInfo ERROR [type = %d]", type);
660 if (ret == POS_RET_NORMAL) {
661 /* Data acquisition process */
662 ret_get_proc = PosGetProc(did, dat, sizeof(SENSORMOTION_SPEEDINFO_DAT));
663 if (static_cast<int32_t>(sizeof(SENSORMOTION_SPEEDINFO_DAT)) > ret_get_proc) {
664 /* Failed to acquire */
665 if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
666 /* Insufficient resource */
667 ret = POS_RET_ERROR_RESOURCE;
669 ret = POS_RET_ERROR_INNER;
671 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
674 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
681 * Compass information acquisition
683 * Get Bill Direction Information
685 * @param[in] hApp HANDLE - Application handle
686 * @param[in] dat SENSORMOTION_HEADINGINFO_DAT* - Pointer to the acquired altitude information storage destination
687 * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified)
689 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
690 * POS_RET_ERROR_PARAM Parameter error<br>
691 * POS_RET_ERROR_NOSUPPORT Unsupported environment<br>
692 * POS_RET_ERROR_INNER Internal error
695 POS_RET_API POS_GetHeading(HANDLE hApp, // NOLINT(readability/nolint)
696 SENSORMOTION_HEADINGINFO_DAT *dat, // NOLINT(readability/nolint)
697 uint8_t ucGetMethod) { // NOLINT(readability/nolint)
698 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
699 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
700 DID did = VEHICLE_DID_MOTION_HEADING; /* Data ID */
701 int32_t ret_get_proc; /* POS_GetProc Return Values */
703 /* Internal debug log output */
704 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
706 /* Arguments & Support Configuration Check */
708 /* If the handler is NULL, the process terminates with an error. */
709 ret = POS_RET_ERROR_PARAM;
710 } else if (dat == NULL) {
711 /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */
712 ret = POS_RET_ERROR_PARAM;
714 /* Positioning Base API initialization */
715 _pb_Setup_CWORD64_API(hApp);
717 /* Supported HW Configuration Check */
718 type = GetEnvSupportInfo();
719 if (UNIT_TYPE_GRADE1 == type) {
721 if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
722 did = VEHICLE_DID_MOTION_HEADING;
723 } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
724 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
725 did = VEHICLE_DID_MOTION_HEADING_NAVI;
727 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
728 ret = POS_RET_ERROR_PARAM;
730 } else if (UNIT_TYPE_GRADE2 == type) {
733 * This feature branches processing depending on the unit type.
735 ret = SENSOR_RET_ERROR_NOSUPPORT;
737 /* Environment error */
738 ret = SENSOR_RET_ERROR_NOSUPPORT;
741 /* Sensor information acquisition */
742 if (ret == POS_RET_NORMAL) {
743 /* Data acquisition process */
744 ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORMOTION_HEADINGINFO_DAT));
745 if (static_cast<int32_t>(sizeof(SENSORMOTION_HEADINGINFO_DAT)) > ret_get_proc) {
746 /** Failed to acquire */
747 if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
748 /** Insufficient resource */
749 ret = POS_RET_ERROR_RESOURCE;
751 ret = POS_RET_ERROR_INNER;
753 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
756 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
762 * Vehicle speed information setting
764 * Setting Vehicle Speed Information
766 * @param[in] hApp HANDLE - Application handle
767 * @param[in] navispped uint16_t - Vehicle speed information[Unit:1.0km/h]
769 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
770 * POS_RET_ERROR_PARAM Parameter error<br>
771 * POS_RET_ERROR_NOSUPPORT Unsupported environment
774 POS_RET_API POS_SetSpeedInfo(HANDLE hApp, uint16_t navispeed) { // NOLINT(readability/nolint)
775 POS_RET_API ret = POS_RET_NORMAL; /* Return value */
776 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
777 uint16_t speed; /* Vehicle speed */
779 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
781 /* Arguments & Support Configuration Check */
783 ret = POS_RET_ERROR_PARAM;
785 /* Positioning Base API initialization */
786 _pb_Setup_CWORD64_API(hApp);
788 /* Supported HW Configuration Check */
789 type = GetEnvSupportInfo();
790 if (UNIT_TYPE_GRADE1 == type) {
792 ret = POS_RET_NORMAL;
793 } else if (UNIT_TYPE_GRADE2 == type) {
796 * This feature branches processing depending on the unit type.
798 ret = SENSOR_RET_ERROR_NOSUPPORT;
800 /* Environment error */
801 ret = SENSOR_RET_ERROR_NOSUPPORT;
805 if (ret == POS_RET_NORMAL) {
806 /* Adjustment by unit [1.0km/h]->[0.01m/sec] */
807 speed = static_cast<uint16_t>(navispeed * 10000 / 360);
808 /* Data setting(After setting,Immediate termination) */
809 ret = PosSetProc(VEHICLE_DID_MOTION_SPEED_NAVI,
810 reinterpret_cast<void *>(&speed), sizeof(uint16_t), FALSE);
813 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
819 * Location information setting
821 * Set location information
823 * @param[in] hApp HANDLE - Application handle
824 * @param[in] posData POS_POSDATA - Pointer to location information
826 * @return POS_RET_NORMAL Normal completion(Include illegal)<br>
827 * POS_RET_ERROR_PARAM Parameter error<br>
828 * POS_RET_ERROR_INNER Internal error<br>
829 * POS_RET_ERROR_NOSUPPORT Unsupported environment
832 POS_RET_API POS_SetLocationInfo(HANDLE hApp, POS_POSDATA* pstPosData) { // NOLINT(readability/nolint)
833 POS_RET_API ret = POS_RET_NORMAL; /* Return value of this function */
834 UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */
836 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
838 /* Arguments & Support Configuration Check */
839 if ((pstPosData == NULL) || (hApp == NULL)) {
840 ret = POS_RET_ERROR_PARAM;
842 /* Positioning Base API initialization */
843 _pb_Setup_CWORD64_API(hApp);
845 /* Supported HW Configuration Check */
846 type = GetEnvSupportInfo();
847 if (UNIT_TYPE_GRADE1 == type) {
849 ret = POS_RET_NORMAL;
850 } else if (UNIT_TYPE_GRADE2 == type) {
853 * This feature branches processing depending on the unit type.
855 ret = SENSOR_RET_ERROR_NOSUPPORT;
857 /* Environment error */
858 ret = SENSOR_RET_ERROR_NOSUPPORT;
862 if (ret == POS_RET_NORMAL) {
863 /* Data status check */
864 if ((0x01 > pstPosData->status) || (0x0F < pstPosData->status)) {
865 ret = POS_RET_ERROR_PARAM;
867 /* Parameter range check */
869 if ((pstPosData->status & POS_LOC_INFO_LAT) == POS_LOC_INFO_LAT) {
870 (void)POS_CHKPARAM32(pstPosData->latitude, -41472000, 41472000);
873 if ((pstPosData->status & POS_LOC_INFO_LON) == POS_LOC_INFO_LON) {
874 (void)POS_CHKPARAM32(pstPosData->longitude, -82944000, 82944000);
877 if ((pstPosData->status & POS_LOC_INFO_HEAD) == POS_LOC_INFO_HEAD) {
878 (void)POS_CHKPARAM16(pstPosData->heading, -179, 180);
881 /* Data setting(After setting,Immediate termination) */
882 ret = PosSetProc(VEHICLE_DID_GPS_CUSTOMDATA_NAVI, // == POSHAL_DID_GPS_CUSTOMDATA_NAVI
883 reinterpret_cast<void *>(pstPosData), sizeof(POS_POSDATA), FALSE);
887 FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);