diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-22 09:06:18 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-22 09:06:18 +0900 |
commit | 00ab09fac9701443fdff616fdcc274809a03d4d7 (patch) | |
tree | 03aa078b69aa17d12c77f7d4b74cf6f3a93ffefd /positioning/client/src/POS_gps_API | |
parent | fa6fa9f4ee5486b30d223914e1a6e50d4d3adf71 (diff) |
vs-positioning branch 0.1sandbox/ToshikazuOhiwa/vs-positioning
Diffstat (limited to 'positioning/client/src/POS_gps_API')
-rw-r--r-- | positioning/client/src/POS_gps_API/Gps_API.cpp | 285 | ||||
-rw-r--r-- | positioning/client/src/POS_gps_API/Makefile | 5 | ||||
-rw-r--r-- | positioning/client/src/POS_gps_API/Naviinfo_API.cpp | 404 | ||||
-rw-r--r-- | positioning/client/src/POS_gps_API/libPOS_gps_API.ver | 2 |
4 files changed, 525 insertions, 171 deletions
diff --git a/positioning/client/src/POS_gps_API/Gps_API.cpp b/positioning/client/src/POS_gps_API/Gps_API.cpp index b3da219e..7395f9d6 100644 --- a/positioning/client/src/POS_gps_API/Gps_API.cpp +++ b/positioning/client/src/POS_gps_API/Gps_API.cpp @@ -1,5 +1,5 @@ /* - * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * @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. @@ -67,9 +67,9 @@ POS_RET_API POS_ReqGPSReset(HANDLE hApp, PCSTR ResName, uint8_t mode) { // NOLI /* Arguments & Support Configuration Check */ if ((hApp == NULL) || (ResName == NULL)) { ret = POS_RET_ERROR_PARAM; -// } else if (GPS_RST_COLDSTART != mode) { -// /* Parameter error except */ -// ret = POS_RET_ERROR_PARAM; + } else if (GPS_RST_COLDSTART != mode) { + /* Parameter error except */ + ret = POS_RET_ERROR_PARAM; } else { /* Positioning Base API initialization */ _pb_Setup_CWORD64_API(hApp); @@ -95,7 +95,7 @@ POS_RET_API POS_ReqGPSReset(HANDLE hApp, PCSTR ResName, uint8_t mode) { // NOLI if (VehicleGetResource() == TRUE) { /* Event Generation */ rs_pno = _pb_CnvName2Pno(ResName); - pid = (u_int32)getpid(); + pid = (uint32_t)getpid(); tid = GetTid(); snprintf(name, sizeof(name), "PR_p%u_t%u", pid, tid); @@ -155,53 +155,6 @@ POS_RET_API POS_ReqGPSReset(HANDLE hApp, PCSTR ResName, uint8_t mode) { // NOLI /** * @brief - * Get GPS version - * - * Get GPS version information - * - * @param[in] hApp HANDLE - Application handle - * @param[in] buf_size uint8_t - Storage size of version information(Byte) - * @param[in] buf int8_t* - Pointer to store the version information - * @param[in] size uint8_t* - Size of the character string written to buf(Byte) - * - * @return POS_RET_NORMAL Normal completion(Include illegal)<br> - * POS_RET_ERROR_PARAM Parameter error<br> - * POS_RET_ERROR_NOSUPPORT Unsupported environment - * - */ -POS_RET_API POS_GetGPSVersion(HANDLE hApp, // NOLINT(readability/nolint) - uint8_t buf_size, - int8_t* buf, // NOLINT(readability/nolint) - uint8_t* size) { - POS_RET_API ret = POS_RET_NORMAL; /* Return value */ - UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ - - FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); - - /* Positioning Base API initialization */ - _pb_Setup_CWORD64_API(hApp); - - /* Supported HW Configuration Check */ - type = GetEnvSupportInfo(); - if (UNIT_TYPE_GRADE1 == type) { - /* GRADE1 */ - ret = POS_RET_ERROR_NOSUPPORT; - } else if (UNIT_TYPE_GRADE2 == type) { - /* - * Note. - * This feature branches processing depending on the unit type. - */ - ret = POS_RET_ERROR_NOSUPPORT; - } else { - /* Environment error */ - ret = POS_RET_ERROR_NOSUPPORT; - } - FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); - return ret; -} - -/** - * @brief * GPS time setting request delivery registration * * Register delivery of GPS time setting request @@ -295,67 +248,67 @@ POS_RET_API POS_RegisterListenerGPSTimeSetReq(HANDLE hApp, // NOLINT(readabilit * POS_RET_ERROR_NOSUPPORT Unsupported environment * */ -//POS_RET_API POS_SetGPStime(HANDLE hApp, POS_DATETIME* pstDateTime) { // NOLINT(readability/nolint) -// POS_RET_API ret = POS_RET_NORMAL; /* Return value of this function */ -// UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ -// -// FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); -// -// /* Arguments & Support Configuration Check */ -// if ((pstDateTime == NULL) || (hApp == NULL)) { -// ret = POS_RET_ERROR_PARAM; -// } else { -// /* Positioning Base API initialization */ -// _pb_Setup_CWORD64_API(hApp); -// -// /* Supported HW Configuration Check */ -// type = GetEnvSupportInfo(); -// if (UNIT_TYPE_GRADE1 == type) { -// /* GRADE1 */ -// ret = POS_RET_NORMAL; -// } else if (UNIT_TYPE_GRADE2 == type) { -// /* -// * Note. -// * This feature branches processing depending on the unit type. -// */ -// ret = POS_RET_ERROR_NOSUPPORT; -// } else { -// /* Environment error */ -// ret = POS_RET_ERROR_NOSUPPORT; -// } -// } -// -// if (ret == POS_RET_NORMAL) { -// /* Parameter range check */ -// /* Month */ -// if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->month, 1, 12)) { -// return POS_RET_ERROR_PARAM; -// } -// /* Day */ -// if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->date, 1, 31)) { -// return POS_RET_ERROR_PARAM; -// } -// /* Hour */ -// if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->hour, 0, 23)) { -// return POS_RET_ERROR_PARAM; -// } -// /* Minutes */ -// if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->minute, 0, 59)) { -// return POS_RET_ERROR_PARAM; -// } -// /* Second */ -// if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->second, 0, 59)) { -// return POS_RET_ERROR_PARAM; -// } -// -// /* Data setting(Immediate recovery)*/ -// ret = PosSetProc(VEHICLE_DID_SETTINGTIME, -// reinterpret_cast<void*>(pstDateTime), sizeof(POS_DATETIME), FALSE); -// } -// -// FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); -// return ret; -//} +POS_RET_API POS_SetGPStime(HANDLE hApp, POS_DATETIME* pstDateTime) { // NOLINT(readability/nolint) + POS_RET_API ret = POS_RET_NORMAL; /* Return value of this function */ + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + + FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); + + /* Arguments & Support Configuration Check */ + if ((pstDateTime == NULL) || (hApp == NULL)) { + ret = POS_RET_ERROR_PARAM; + } else { + /* Positioning Base API initialization */ + _pb_Setup_CWORD64_API(hApp); + + /* Supported HW Configuration Check */ + type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { + /* GRADE1 */ + ret = POS_RET_NORMAL; + } else if (UNIT_TYPE_GRADE2 == type) { + /* + * Note. + * This feature branches processing depending on the unit type. + */ + ret = POS_RET_ERROR_NOSUPPORT; + } else { + /* Environment error */ + ret = POS_RET_ERROR_NOSUPPORT; + } + } + + if (ret == POS_RET_NORMAL) { + /* Parameter range check */ + /* Month */ + if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->month, 1, 12)) { + return POS_RET_ERROR_PARAM; + } + /* Day */ + if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->date, 1, 31)) { + return POS_RET_ERROR_PARAM; + } + /* Hour */ + if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->hour, 0, 23)) { + return POS_RET_ERROR_PARAM; + } + /* Minutes */ + if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->minute, 0, 59)) { + return POS_RET_ERROR_PARAM; + } + /* Second */ + if (POS_RET_ERROR == POS_CHKPARAMU8(pstDateTime->second, 0, 59)) { + return POS_RET_ERROR_PARAM; + } + + /* Data setting(Immediate recovery)*/ + ret = PosSetProc(VEHICLE_DID_SETTINGTIME, + reinterpret_cast<void*>(pstDateTime), sizeof(POS_DATETIME), FALSE); + } + + FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); + return ret; +} /** * @brief @@ -448,56 +401,56 @@ SENSOR_RET_API POS_RegisterListenerGPStime(HANDLE hApp, // NOLINT(readability/n * POS_RET_ERROR_NOSUPPORT Unsupported environment * */ -//POS_RET_API POS_GetGPStime(HANDLE hApp, SENSOR_GPSTIME* dat) { // NOLINT(readability/nolint) -// POS_RET_API ret = POS_RET_NORMAL; /* Return value */ -// UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ -// DID did = VEHICLE_DID_GPS_TIME; /* DID */ -// int32 ret_get_proc; /* POS_GetProc Return Values */ -// -// /* Internal debug log output */ -// FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); -// -// /* Arguments & Support Configuration Check */ -// if (hApp == NULL) { -// /* If the handler is NULL, the process terminates with an error. */ -// ret = POS_RET_ERROR_PARAM; -// } else if (dat == NULL) { -// /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */ -// ret = POS_RET_ERROR_PARAM; -// } else { -// /* Positioning Base API initialization */ -// _pb_Setup_CWORD64_API(hApp); -// -// /* Supported HW Configuration Check */ -// type = GetEnvSupportInfo(); -// if (UNIT_TYPE_GRADE1 == type) { -// ret = POS_RET_NORMAL; -// } else { -// /* -// * Note. -// * This feature branches processing depending on the unit type. -// */ -// ret = POS_RET_ERROR_NOSUPPORT; -// } -// } -// -// /* Sensor information acquisition */ -// if (ret == POS_RET_NORMAL) { -// /* Data acquisition process */ -// ret_get_proc = PosGetProc(did, reinterpret_cast<void*>(dat), sizeof(SENSOR_GPSTIME)); -// if (static_cast<int32>(sizeof(SENSOR_GPSTIME)) > ret_get_proc) { -// /** Failed to acquire */ -// if (ret_get_proc == POS_RET_ERROR_RESOURCE) { -// /** Insufficient resource */ -// ret = POS_RET_ERROR_RESOURCE; -// } else { -// ret = POS_RET_ERROR_INNER; -// } -// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret); -// } -// } -// -// FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); -// -// return ret; -//} +POS_RET_API POS_GetGPStime(HANDLE hApp, SENSOR_GPSTIME* dat) { // NOLINT(readability/nolint) + POS_RET_API ret = POS_RET_NORMAL; /* Return value */ + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + DID did = VEHICLE_DID_GPS_TIME; /* DID */ + int32_t ret_get_proc; /* POS_GetProc Return Values */ + + /* Internal debug log output */ + FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); + + /* Arguments & Support Configuration Check */ + if (hApp == NULL) { + /* If the handler is NULL, the process terminates with an error. */ + ret = POS_RET_ERROR_PARAM; + } else if (dat == NULL) { + /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */ + ret = POS_RET_ERROR_PARAM; + } else { + /* Positioning Base API initialization */ + _pb_Setup_CWORD64_API(hApp); + + /* Supported HW Configuration Check */ + type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { + ret = POS_RET_NORMAL; + } else { + /* + * Note. + * This feature branches processing depending on the unit type. + */ + ret = POS_RET_ERROR_NOSUPPORT; + } + } + + /* Sensor information acquisition */ + if (ret == POS_RET_NORMAL) { + /* Data acquisition process */ + ret_get_proc = PosGetProc(did, reinterpret_cast<void*>(dat), sizeof(SENSOR_GPSTIME)); + if (static_cast<int32_t>(sizeof(SENSOR_GPSTIME)) > ret_get_proc) { + /* Failed to acquire */ + if (ret_get_proc == POS_RET_ERROR_RESOURCE) { + /* Insufficient resource */ + ret = POS_RET_ERROR_RESOURCE; + } else { + ret = POS_RET_ERROR_INNER; + } + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret); + } + } + + FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); + + return ret; +} diff --git a/positioning/client/src/POS_gps_API/Makefile b/positioning/client/src/POS_gps_API/Makefile index a2de3c80..c6391a9e 100644 --- a/positioning/client/src/POS_gps_API/Makefile +++ b/positioning/client/src/POS_gps_API/Makefile @@ -1,5 +1,5 @@ # -# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. +# @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. @@ -17,13 +17,10 @@ INST_SHLIBS = libPOS_gps_API ######### compiled sources ############# -VPATH += ../POS_naviinfo_API/variant/awnavi/src - libPOS_gps_API_SRCS += Gps_API.cpp libPOS_gps_API_SRCS += Naviinfo_API.cpp ######### add include path ############# -CPPFLAGS += -I./ CPPFLAGS += -I../../../server/include/common CPPFLAGS += -I../../include CPPFLAGS += -I../../../server/include/nsfw diff --git a/positioning/client/src/POS_gps_API/Naviinfo_API.cpp b/positioning/client/src/POS_gps_API/Naviinfo_API.cpp new file mode 100644 index 00000000..cfe04ff8 --- /dev/null +++ b/positioning/client/src/POS_gps_API/Naviinfo_API.cpp @@ -0,0 +1,404 @@ +/* + * @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 Naviinfo_API.cpp +@detail Naviinfo_API Functions +@lib libNaviinfo_API.so +******************************************************************************/ + +/***************************************************************************** + * Include * + *****************************************************************************/ +#include "Naviinfo_API.h" +#include <vehicle_service/POS_define.h> +#include <vehicle_service/POS_sensor_API.h> +#include <vehicle_service/POS_gps_API.h> +#include "Vehicle_API_Dummy.h" +#include "POS_private.h" +#include <native_service/frameworkunified_types.h> // NOLINT(build/include_order) + +void PosCnvGpsInfo(NAVIINFO_ALL *navi_loc_info); + + +/** + * @brief + * GPS information setting + * + * Set GPS information + * + * @param[in] hApp HANDLE - Application handle + * @param[in] navilocinfo NAVIINFO_ALL* - Pointer to GPS information storage area + * + * @return NAVIINFO_RET_NORMAL Normal completion<br> + * NAVIINFO_RET_ERROR_PARAM Parameter error<br> + * NAVIINFO_RET_ERROR_INNER Internal error<br> + * NAVIINFO_RET_ERROR_NOSUPPORT Unsupported environment + * + */ +NAVIINFO_RET_API POS_SetGPSInfo(HANDLE hApp, NAVIINFO_ALL *navilocinfo) +{ + NAVIINFO_RET_API ret = NAVIINFO_RET_NORMAL; /* Return value of this function */ + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + NAVIINFO_ALL navi_loc_info_tmp; /* Conversion quantity area */ + RET_API ret_api; + + /** NULL checking */ + if (navilocinfo == NULL) { + /** Parameter error */ + ret = NAVIINFO_RET_ERROR_PARAM; + } else if (hApp == NULL) { + /** Parameter error */ + ret = NAVIINFO_RET_ERROR_PARAM; + } else { + /* Positioning Base API initialization */ + _pb_Setup_CWORD64_API(hApp); + + /* Supported HW Configuration Check */ + type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { + /* GRADE1 */ + ret = NAVIINFO_RET_NORMAL; + } else if (UNIT_TYPE_GRADE2 == type) { + /* + * Note. + * This feature branches processing depending on the unit type. + */ + ret = NAVIINFO_RET_ERROR_NOSUPPORT; + } else { + /* Environment error */ + ret = NAVIINFO_RET_ERROR_NOSUPPORT; + } + } + + if (ret == NAVIINFO_RET_NORMAL) { + /* Parameter range check */ + if (navilocinfo->stNaviGps.tdsts != 0) { /* Other than ""Time not calibrated after receiver reset"" */ + /* Positioning status information */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stDiagGps.stFix.ucFixSts, 0, 2)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* Latitude */ + if (POS_RET_ERROR == POS_CHKPARAM32(navilocinfo->stDiagGps.stFix.stWgs84.lLat, -82944000, 82944000)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* Longitude */ + if (POS_RET_ERROR == POS_CHKPARAM32(navilocinfo->stDiagGps.stFix.stWgs84.lLon, -165888000, 165888000)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* Measurement Azimuth */ + if (POS_RET_ERROR == POS_CHKPARAMU16(navilocinfo->stNaviGps.heading, 0, 3599)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* UTC(Month) */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.utc.month, 1, 12)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* UTC(Day) */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.utc.date, 1, 31)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* UTC(Hour) */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.utc.hour, 0, 23)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* UTC(Minutes) */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.utc.minute, 0, 59)) { + return NAVIINFO_RET_ERROR_PARAM; + } + /* UTC(Second) */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.utc.second, 0, 59)) { + return NAVIINFO_RET_ERROR_PARAM; + } + } + /* Date and Time Status */ + if (POS_RET_ERROR == POS_CHKPARAMU8(navilocinfo->stNaviGps.tdsts, 0, 2)) { + return NAVIINFO_RET_ERROR_PARAM; + } + + /* Copy to conversion area */ + memcpy(&navi_loc_info_tmp, navilocinfo, sizeof(NAVIINFO_ALL)); + /** Data unit conversion */ + PosCnvGpsInfo(&navi_loc_info_tmp); + + /* Resource acquisition */ + if (VehicleGetResource() == TRUE) { + + /** Send navigation information to vehicle sensor */ + ret_api = _pb_SndMsg_Ext(POS_THREAD_NAME, + CID_NAVIINFO_DELIVER, + sizeof(NAVIINFO_ALL), + reinterpret_cast<void*>(&navi_loc_info_tmp), 0); + if (ret_api != RET_NORMAL) { + /** Message transmission failure */ + ret = NAVIINFO_RET_ERROR_INNER; + } + } else { + /* When resource shortage occurs, the system terminates with an insufficient resource error. */ + ret = NAVIINFO_RET_ERROR_RESOURCE; + } + /* Resource release */ + VehicleReleaseResource(); + } + + return ret; +} + +/** + * @brief + * GPS information acquisition + * + * Access GPS information + * + * @param[in] hApp HANDLE - Application handle + * @param[in] navidiaginfo NAVIINFO_DIAG_GPS* - Pointer to GPS information storage area + * + * @return NAVIINFO_RET_NORMAL Normal completion<br> + * NAVIINFO_RET_ERROR_PARAM Parameter error<br> + * NAVIINFO_RET_ERROR_INNER Internal error<br> + * NAVIINFO_RET_ERROR_NOSUPPORT Unsupported environment + * + */ +NAVIINFO_RET_API POS_GetGPSInfo(HANDLE hApp, NAVIINFO_DIAG_GPS *navidiaginfo) +{ + NAVIINFO_RET_API ret = NAVIINFO_RET_NORMAL; /* Return value of this function */ + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + int32_t ret_veh; /* VehicleAPI Return Values */ + NAVIINFO_DIAG_GPS dest_data; /* Data acquisition area */ + + /** NULL checking */ + if (navidiaginfo == NULL) { + /** Parameter error */ + ret = NAVIINFO_RET_ERROR_PARAM; + } else if (hApp == NULL) { + /** Parameter error */ + ret = NAVIINFO_RET_ERROR_PARAM; + } else { + /* Positioning Base API initialization */ + _pb_Setup_CWORD64_API(hApp); + + /* Supported HW Configuration Check */ + type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { + /* GRADE1 */ + ret = NAVIINFO_RET_NORMAL; + } else if (UNIT_TYPE_GRADE2 == type) { + /* + * Note. + * This feature branches processing depending on the unit type. + */ + ret = NAVIINFO_RET_ERROR_NOSUPPORT; + } else { + /* Environment error */ + ret = NAVIINFO_RET_ERROR_NOSUPPORT; + } + } + + if (ret == NAVIINFO_RET_NORMAL) { + /** Acquisition of navigation data for Diag provide */ + ret_veh = PosGetProc( + (DID)VEHICLE_DID_NAVIINFO_DIAG_GPS, + reinterpret_cast<void*>(&dest_data), + (u_int16)sizeof(dest_data)); + + if (static_cast<int32_t>(sizeof(NAVIINFO_DIAG_GPS)) > ret_veh) { + /** Failed to acquire */ + if (ret_veh == POS_RET_ERROR_RESOURCE) { + ret = NAVIINFO_RET_ERROR_RESOURCE; + } else { + ret = NAVIINFO_RET_ERROR_INNER; + } + } else { + /** Successful acquisition */ + memcpy( navidiaginfo, &dest_data, sizeof(NAVIINFO_DIAG_GPS)); + } + } + + return ret; +} + +/* ++ GPS _CWORD82_ support */ +/** + * @brief + * GPS setting transmission request + * + * Requesting GPS Settings with Complete Return + * + * @param[in] hApp HANDLE - Application handle + * @param[in] p_data SENSOR_MSG_SEND_DAT* - GPS setting information to be sent + * + * @return SENSOR_RET_NORMAL Normal completion<br> + * SENSOR_RET_ERROR_CREATE_EVENT Event generation failure<br> + * SENSOR_RET_ERROR_PARAM Parameter error<br> + * SENSOR_RET_ERROR_DID Unregistered DID<br> + * SENSOR_RET_ERROR_NOSUPPORT Unsupported environment + * + */ +int32 POS_ReqGPSSetting(HANDLE hApp, SENSOR_MSG_SEND_DAT *p_data) { /* Ignore->MISRA-C++:2008 Rule 7-1-2 */ + SENSOR_RET_API ret = SENSOR_RET_NORMAL; /* Return value */ + RET_API ret_api; /* System API return value */ + uint16_t expected_size; /* Message size for the specified DID */ + + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + + if (hApp == NULL) { + /* Parameter error */ + ret = SENSOR_RET_ERROR_PARAM; + } + + if (ret == SENSOR_RET_NORMAL) { + /* Positioning Base API initialization */ + _pb_Setup_CWORD64_API(hApp); + + /* Argument check (DID) + Size calculation */ + if (p_data != reinterpret_cast<SENSOR_MSG_SEND_DAT*>(NULL)) { + switch (p_data->did) { + case VEHICLE_DID_GPS__CWORD82__SETINITIAL: + { + expected_size = 71; + break; + } + case VEHICLE_DID_GPS__CWORD82__SETRMODE: + { + expected_size = 50; + break; + } + case VEHICLE_DID_GPS__CWORD82__SETRMODEEX: + { + expected_size = 63; + break; + } + case VEHICLE_DID_GPS__CWORD82__SELSENT: + { + expected_size = 21; + break; + } + case VEHICLE_DID_GPS__CWORD82__SETSBAS: + { + expected_size = 34; + break; + } + case VEHICLE_DID_GPS__CWORD82__SETCONF1: + { + expected_size = 37; + break; + } + case VEHICLE_DID_GPS__CWORD82__SETCONF2: + { + expected_size = 45; + break; + } + default: /* Ignore->MISRA-C++:2008 Rule 6-3-1, 6-4-1 */ + ret = SENSOR_RET_ERROR_DID; + break; + } + } else { + ret = SENSOR_RET_ERROR_PARAM; + } + } + + /* Supported HW Configuration Check */ + if (ret == SENSOR_RET_NORMAL) { + type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { + /* GRADE1 */ + ret = SENSOR_RET_NORMAL; + } else if (UNIT_TYPE_GRADE2 == type) { + /* + * Note. + * This feature branches processing depending on the unit type. + */ + ret = SENSOR_RET_ERROR_NOSUPPORT; + } else { + /* Environment error */ + ret = SENSOR_RET_ERROR_NOSUPPORT; + } + } + + if (ret == SENSOR_RET_NORMAL) { + /* Argument check (Size)*/ + if (expected_size != p_data->usSize) { + ret = SENSOR_RET_ERROR_PARAM; + } else { + /* Message buffer initialization */ + + /* Create message data */ + + /* Resource acquisition */ + if (VehicleGetResource() == TRUE) { + /* External Process Transmission and Reception Messages */ + FRAMEWORKUNIFIEDLOG(ZONE_27, __FUNCTION__, + "POSITIONING: POS_ReqGPSSetting() --> cid = %d", + CID_SENSORIF__CWORD82__REQUEST); + ret_api = _pb_SndMsg_Ext(POS_THREAD_NAME, + CID_SENSORIF__CWORD82__REQUEST, + sizeof(SENSOR_MSG_SEND_DAT), + reinterpret_cast<void *>(p_data), 0); + FRAMEWORKUNIFIEDLOG(ZONE_27, __FUNCTION__, "POSITIONING: POS_ReqGPSSetting() <--"); + + if (ret_api != RET_NORMAL) { + ret = SENSOR_RET_ERROR_CREATE_EVENT; + } + } else { + /* When resource shortage occurs, the system terminates with an insufficient resource error. */ + ret = SENSOR_RET_ERROR_RESOURCE; + } + /* Resource release */ + VehicleReleaseResource(); + } + } + + return ret; +} +/* -- GPS _CWORD82_ support */ + +/** + * @brief + * GPS information conversion process + * + * Convert GPS information to a format to be provided to the vehicle sensor + * + * @param[in] none + * @param[in] navi_loc_info NAVIINFO_ALL* - GPS information pointer + * + * @return none + */ +void PosCnvGpsInfo(NAVIINFO_ALL *navi_loc_info) { + int32_t altitude; + int64_t tmp; + uint16_t heading; + + /* Unit conversion of fix altitude[1m]->[0.01m] */ + tmp = (int64_t)((int64_t)(navi_loc_info->stNaviGps.altitude) * 100); + if (tmp > static_cast<int32_t>(0x7FFFFFFF)) { + /* +Overflow of digits */ + altitude = static_cast<int32_t>(0x7FFFFFFF); + } else if (tmp < static_cast<int32_t>(0x80000000)) { /* Ignore->MISRA-C:2004 Rule 3.1 */ + /* -Overflow of digits */ + altitude = static_cast<int32_t>(0x80000000); /* Ignore->MISRA-C:2004 Rule 3.1 */ + } else { + altitude = static_cast<int32_t>(tmp); + } + navi_loc_info->stNaviGps.altitude = altitude; + + /* Measurement Azimuth Conversion[0.Once]->[0.01 degree] */ + heading = navi_loc_info->stNaviGps.heading; + heading = static_cast<uint16_t>(heading - ((heading / 3600) * 3600)); + heading = static_cast<uint16_t>(heading * 10); + navi_loc_info->stNaviGps.heading = heading; + + return; +} diff --git a/positioning/client/src/POS_gps_API/libPOS_gps_API.ver b/positioning/client/src/POS_gps_API/libPOS_gps_API.ver index 93578dec..038c99ec 100644 --- a/positioning/client/src/POS_gps_API/libPOS_gps_API.ver +++ b/positioning/client/src/POS_gps_API/libPOS_gps_API.ver @@ -1,5 +1,5 @@ /* - * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * @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. |