diff options
Diffstat (limited to 'positioning/client/src')
16 files changed, 927 insertions, 1887 deletions
diff --git a/positioning/client/src/CanInput_API/common/CanInput_API.cpp b/positioning/client/src/CanInput_API/common/CanInput_API.cpp deleted file mode 100644 index ebf69dd8..00000000 --- a/positioning/client/src/CanInput_API/common/CanInput_API.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2019 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 name : CanInput_API.cpp - * System name : PastModel002 - * Sub System name : CanInput_API library - * Program name : CanInput_API - * Module configuration: CanInputInitialize() Initialization - * : CanInputSndMsg() Send a message - ******************************************************************************/ - -/************************************************************************ - * Include * - ***********************************************************************/ -#include <vehicle_service/positioning_base_library.h> -#include "CanInput_API.h" -#include "CanInput_API_private.h" - -/************************************************************************ -* Global variable * -************************************************************************/ - -/************************************************************************ -* Definition * -************************************************************************/ - -/******************************************************************************* - * MODULE : CanInputInitialize - * ABSTRACT : Initialization - * FUNCTION : CanInput_API Initialization - * ARGUMENT : None - * NOTE : - * RETURN : CAN_INPUT_RET_NORMAL : Successful completion - * : CAN_INPUT_RET_ERROR : An error has occurred - ******************************************************************************/ -CAN_INPUT_RET_API CanInputInitialize(void) { - RET_API ret_sys; - CAN_INPUT_RET_API ret_api; - - /* _CWORD64_api Initialization */ - ret_sys = _pb_Setup_CWORD64_API(NULL); - - if (ret_sys == RET_NORMAL) { - ret_api = CAN_INPUT_RET_NORMAL; - } else { - ret_api = CAN_INPUT_RET_ERROR; - } - - return ret_api; -} - -/******************************************************************************* - * MODULE : CanInputSndMsg - * ABSTRACT : Send a message - * FUNCTION : Send a message to VehicleSens_thread - * ARGUMENT : pno : Thread ID - * : cid : Command ID - * : msg_len : Data size - * : *msg_data : Pointer to the data buffer - * NOTE : - * RETURN : CAN_INPUT_RET_NORMAL : Successful completion - * : CAN_INPUT_RET_ERROR_PARAM : Parameter error - * : CAN_INPUT_RET_ERROR : An error has occurred - ******************************************************************************/ -CAN_INPUT_RET_API CanInputSndMsg(PNO pno, CID cid, u_int16 msg_len, const void *msg_data) { - CAN_INPUT_RET_API ret_api; - CANINPUT_MSG_INFO msg_buf; - - - if (cid == CANINPUT_CID_LOCALTIME_NOTIFICATION) { - if (msg_len <= sizeof(msg_buf.data)) { - RET_API ret_sys; - u_int16 msg_size; - - - /* Initialization message buffer */ - (void)memset(reinterpret_cast<void *>(&msg_buf), 0, sizeof(msg_buf)); - - /*--------------------------------------------------------------* - * Create a message header * - *--------------------------------------------------------------*/ - /* Set only the required data */ - msg_buf.hdr.hdr.sndpno = pno; /* source PNO */ - msg_buf.hdr.hdr.cid = cid; /* Command ID */ - msg_buf.hdr.hdr.msgbodysize = msg_len; /* Data size */ - - /*--------------------------------------------------------------* - * Create a message data * - *--------------------------------------------------------------*/ - if ((msg_len != 0) && (msg_data != NULL)) { - (void)memcpy(reinterpret_cast<void *>(&msg_buf.data), msg_data, (size_t)msg_len); - } - - msg_size = sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len; - - /*--------------------------------------------------------------* - * Send a message * - *--------------------------------------------------------------*/ - ret_sys = _pb_SndMsg(PNO_VEHICLE_SENSOR, /* destination PNO */ - msg_size, /* message size */ - reinterpret_cast<void *>(&msg_buf), /* message buffer */ - 0); /* Unused Argument */ - - if (ret_sys == RET_NORMAL) { - ret_api = CAN_INPUT_RET_NORMAL; - } else { - ret_api = CAN_INPUT_RET_ERROR; - } - } else { - /* Argument error(Data size) */ - ret_api = CAN_INPUT_RET_ERROR_PARAM; - } - } else { - /* Argument error(Command ID) */ - ret_api = CAN_INPUT_RET_ERROR_PARAM; - } - - return ret_api; -} - diff --git a/positioning/client/src/DR_API/common/DR_API.cpp b/positioning/client/src/DR_API/common/DR_API.cpp deleted file mode 100644 index a7416b48..00000000 --- a/positioning/client/src/DR_API/common/DR_API.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2019 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 DR_API.cpp -@detail DR_API Functions -@lib libDR_API.so -******************************************************************************/ - -/***************************************************************************** - * Include * - *****************************************************************************/ -#include <vehicle_service/positioning_base_library.h> -#include "DR_API.h" -#include "DR_API_private.h" - -#define DR_API_DEBUG 0 - -static EventID DrCreateEvent(PNO pno); -static RET_API DrDeleteEvent(EventID event_id); -static RET_API DrSndMsg(PNO pno_src, PNO pno_dest, CID cid, u_int16 msg_len, const void *msg_data); - -/****************************************************************************** -@brief DrSetMapMatchingData<BR> - Map matching information setting -@outline Set up map matching information. -@param[in] PNO pno : Thread ID -@param[in] MAP_MATCHING_DATA* map_matching_data : Map matching information<BR> -@param[out] none -@return DR_EXT_RET_API -@retval DR_EXT_RET_NORMAL : Normal completion -@retval DR_EXT_RET_ERROR : Parameter error -*******************************************************************************/ -DR_EXT_RET_API DrSetMapMatchingData(PNO pno, MAP_MATCHING_DATA* map_matching_data) { - DR_EXT_RET_API ret = DR_EXT_RET_NORMAL; /* Return value of this function */ - RET_API ret_api = RET_NORMAL; /* System API return value */ - -#if DR_API_DEBUG - FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DR_API : DrSetMapMatchingData \r\n"); - FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "\r\n lat[0x%08X] lon[0x%08X] sts[0x%02X] \r\n", - map_matching_data->position_info.latitude, - map_matching_data->position_info.longitude, - map_matching_data->position_info.status); - FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "rate[0x%04X] sts[0x%02X] ort[0x%04X] sts[0x%02X] \r\n Sts[0x%08X] \r\n", - map_matching_data->rate_info.rate, - map_matching_data->rate_info.status, - map_matching_data->orient_info.orient, - map_matching_data->orient_info.status, - map_matching_data->status); -#endif - - /*--------------------------------------------------------------* - * Send map matching information * - *--------------------------------------------------------------*/ - /* Messaging */ - ret_api = DrSndMsg(pno, - PNO_VEHICLE_SENSOR, - CID_DR_MAP_MATCHING_DATA, - (u_int16)sizeof(MAP_MATCHING_DATA), (const void *)map_matching_data); - - if (RET_NORMAL == ret_api) { - ret = DR_EXT_RET_NORMAL; - } else { - ret = DR_EXT_RET_ERROR; - } - -#if DR_API_DEBUG - FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "DR_API : DrSetMapMatchingData return[0x%X] \r\n", ret); -#endif - - return ret; -} - -/****************************************************************************** -@brief DrClearBackupData<BR> - DR backup data initialization -@outline Initialize the DR backup data. -@param[in] PNO pno : Thread ID -@param[out] none -@return DR_EXT_RET_API -@retval DR_EXT_RET_NORMAL : Clear success -@retval DR_EXT_RET_ERROR : Clear failed -*******************************************************************************/ -DR_EXT_RET_API DrClearBackupData(PNO pno) { - EventID event_id = 0; /* Event ID */ - int32 event_val = 0; /* Event value */ - RET_API ret_api = RET_NORMAL; /* System API return value */ - DR_EXT_RET_API ret = DR_EXT_RET_NORMAL; /* Return value */ - u_char data; /* Message data(Dummy) */ - - /* Event Generation */ - event_id = DrCreateEvent(pno); - - if (event_id != 0) { - /* Successful event generation */ - /* Messaging(Notify VehicleSens_thread) */ - ret_api = DrSndMsg(pno, - PNO_VEHICLE_SENSOR, - CID_DR_CLEAR_BACKUP_DATA, - 0U, /* Message size is set to 0 */ - (const void *)&data); /* Message data(Dummy) -> Errors by NULL */ - if (ret_api == RET_NORMAL) { - /* Message transmission process succeeded */ - /* Waiting for completion event from vehicle sensor thread */ - ret_api = _pb_WaitEvent(event_id, - SAPI_EVWAIT_VAL, - DR_RET_ERROR_MIN, DR_EXT_RET_NORMAL, &event_val, INFINITE); - if (ret_api == RET_NORMAL) { - /* Return from Event Wait */ - if (event_val == RET_NORMAL) { - /* Clear success */ - ret = DR_EXT_RET_NORMAL; - } else { - /* Clear failed */ - ret = DR_EXT_RET_ERROR; - } - } else { - /* Failed to wait for event */ - ret = DR_EXT_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_WaitEvent Failed"); - } - } else { - /* Message transmission failure */ - ret = DR_EXT_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "DrSndMsg Failed"); - } - /* Event deletion */ - (void)DrDeleteEvent(event_id); - } else { - /* Event generation failure */ - ret = DR_EXT_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "DrCreateEvent Failed"); - } - - return ret; -} - -/******************************************************************************* - * MODULE : DrSndMsg - * ABSTRACT : Message transmission processing - * FUNCTION : Send a message to the specified PNO - * ARGUMENT : pno_src : Source PNO - * : pno_dest : Destination PNO - * : cid : Command ID - * : msg_len : Message data body length - * : *msg_data : Pointer to message data - * NOTE : - * RETURN : RET_NORMAL : Normal completion - * : RET_ERRNOTRDY : Destination process is not wakeup - * : RET_ERRMSGFULL : Message queue overflows - * : RET_ERRPARAM : Buffer size error - ******************************************************************************/ -static RET_API DrSndMsg(PNO pno_src, PNO pno_dest, CID cid, u_int16 msg_len, const void *msg_data) { - DR_MSG_BUF msg_buf; - RET_API ret_api; - - if (msg_data != NULL) { - /* Initialization message buffe */ - (void)memset(reinterpret_cast<void *>(&msg_buf), 0, sizeof(DR_MSG_BUF)); - - /*--------------------------------------------------------------* - * Create a message header * - *--------------------------------------------------------------*/ - msg_buf.stHdr.hdr.sndpno = pno_src; /* source PNO */ - msg_buf.stHdr.hdr.cid = cid; /* Command ID */ - msg_buf.stHdr.hdr.msgbodysize = msg_len; /* Data size */ - - /*--------------------------------------------------------------* - * Create a message data * - *--------------------------------------------------------------*/ - if (msg_len != 0) { - (void)memcpy(reinterpret_cast<void *>(msg_buf.ucData), msg_data, (size_t)msg_len); - } - /*--------------------------------------------------------------* - * Send messages * - *--------------------------------------------------------------*/ - ret_api = _pb_SndMsg(pno_dest, /* destination PNO */ - (u_int16)(sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len), /* message size */ - reinterpret_cast<void *>(&msg_buf), /* message buffer */ - 0); /* Unused Argument */ - } else { - /* Argument error(Pointer to the data buffer) */ - ret_api = RET_ERRPARAM; - } - - return ret_api; -} - -/******************************************************************************* - * MODULE : DrCreateEvent - * ABSTRACT : Event creation process - * FUNCTION : Generate an event - * ARGUMENT : pno : Thread ID - * NOTE : - * RETURN : Non-zero : Event ID - * : Zero : Event generation failure - ******************************************************************************/ -static EventID DrCreateEvent(PNO pno) { - EventID event_id; /* Event ID */ - int8 event_name[32]; /* Event name character string buffer */ - - /* Initialization of event name character string buffer */ - (void)memset(reinterpret_cast<void *>(event_name), 0, sizeof(event_name)); - - /* Event name creation */ - snprintf(event_name, sizeof(event_name), "DR_API_%X", pno); - - /* Event Generation */ - event_id = _pb_CreateEvent(_CWORD64_EVENT_MANUALRESET_OFF, DR_EVENT_VAL_INIT, event_name); - - if (event_id == 0) { - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_CreateEvent"); - } - - return event_id; -} - -/******************************************************************************* - * MODULE : DrDeleteEvent - * ABSTRACT : Event deletion processing - * FUNCTION : Delete events - * ARGUMENT : event_id : Event ID of the event to delete - * NOTE : - * RETURN : RET_NORMAL : Normal completion - * : RET_EV_NONE : Specified event does not exist - ******************************************************************************/ -static RET_API DrDeleteEvent(EventID event_id) { - return (_pb_DeleteEvent(event_id)); -} - diff --git a/positioning/client/src/POS_common_API/Common_API.cpp b/positioning/client/src/POS_common_API/Common_API.cpp index ceabb18c..f266decd 100644 --- a/positioning/client/src/POS_common_API/Common_API.cpp +++ b/positioning/client/src/POS_common_API/Common_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. @@ -38,7 +38,7 @@ * @param[in] notifyName PCSTR - Destination thread name * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery) * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating) - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_BUFFULL Buffer-full<br> @@ -80,12 +80,15 @@ POS_RET_API POS_RegisterListenerLonLat(HANDLE hApp, // NOLINT(readability/nolin /* Supported HW Configuration Check */ type = GetEnvSupportInfo(); + if (UNIT_TYPE_GRADE1 == type) { /* GRADE1 */ ret = POS_RET_NORMAL; - if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || - (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + if (ucGetMethod == SENSOR_GET_METHOD_GPS) { did = VEHICLE_DID_LOCATION_LONLAT; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_LOCATION_LONLAT_NAVI; } else { /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ ret = POS_RET_ERROR_PARAM; @@ -138,7 +141,7 @@ POS_RET_API POS_RegisterListenerLonLat(HANDLE hApp, // NOLINT(readability/nolin * @param[in] notifyName PCSTR - Destination thread name * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery) * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating) - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -235,7 +238,7 @@ POS_RET_API POS_RegisterListenerAltitude(HANDLE hApp, // NOLINT(readability/nol * @param[in] notifyName PCSTR - Destination thread name * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery) * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating) - * @param[in] ucGetMethod uint8_t - Acquisition method(POS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(POS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_BUFFULL Buffer-full<br> @@ -280,11 +283,12 @@ POS_RET_API POS_RegisterListenerSpeed(HANDLE hApp, // NOLINT(readability/nolint if (UNIT_TYPE_GRADE1 == type) { /* GRADE1 */ ret = POS_RET_NORMAL; - if ((ucGetMethod == SENSOR_GET_METHOD_POS) || - (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + if (ucGetMethod == SENSOR_GET_METHOD_POS) { did = VEHICLE_DID_MOTION_SPEED_INTERNAL; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_MOTION_SPEED_NAVI; } else { - /* End as a parameter error abnormality except for POS/unspecified acquisition method */ ret = POS_RET_ERROR_PARAM; } } else if (UNIT_TYPE_GRADE2 == type) { @@ -335,7 +339,7 @@ POS_RET_API POS_RegisterListenerSpeed(HANDLE hApp, // NOLINT(readability/nolint * @param[in] notifyName PCSTR - Destination thread name * @param[in] ucCtrlFlg uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery) * @param[in] ucDeliveryTiming uint8_t - Delivery timing(Changing/Updating) - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -378,9 +382,11 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli if (UNIT_TYPE_GRADE1 == type) { /* GRADE1 */ ret = POS_RET_NORMAL; - if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || - (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + if (ucGetMethod == SENSOR_GET_METHOD_GPS) { did = VEHICLE_DID_MOTION_HEADING; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_MOTION_HEADING_NAVI; } else { /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ ret = POS_RET_ERROR_PARAM; @@ -431,7 +437,7 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * * @param[in] hApp HANDLE - Application handle * @param[in] dat SENSORLOCATION_LONLATINFO_DAT* - Pointer to the acquired latitude/longitude information storage destination - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -439,69 +445,71 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * POS_RET_ERROR_INNER Internal error * */ -//POS_RET_API POS_GetLonLat(HANDLE hApp, // NOLINT(readability/nolint) -// SENSORLOCATION_LONLATINFO_DAT *dat, // NOLINT(readability/nolint) -// uint8_t ucGetMethod) { // 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_LOCATION_LONLAT; /* 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) { -// /* GRADE1 */ -// if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || -// (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { -// did = VEHICLE_DID_LOCATION_LONLAT; -// } else { -// /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ -// ret = POS_RET_ERROR_PARAM; -// } -// } 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; -// } -// } -// -// /* Sensor information acquisition */ -// if (ret == POS_RET_NORMAL) { -// /* Data acquisition process */ -// ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_LONLATINFO_DAT)); -// if (static_cast<int32>(sizeof(SENSORLOCATION_LONLATINFO_DAT)) > 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_GetLonLat(HANDLE hApp, // NOLINT(readability/nolint) + SENSORLOCATION_LONLATINFO_DAT *dat, // NOLINT(readability/nolint) + uint8_t ucGetMethod) { // 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_LOCATION_LONLAT; /* 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) { + /* GRADE1 */ + if (ucGetMethod == SENSOR_GET_METHOD_GPS) { + did = VEHICLE_DID_LOCATION_LONLAT; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_LOCATION_LONLAT_NAVI; + } else { + /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ + ret = POS_RET_ERROR_PARAM; + } + } 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; + } + } + + /* Sensor information acquisition */ + if (ret == POS_RET_NORMAL) { + /* Data acquisition process */ + ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_LONLATINFO_DAT)); + if (static_cast<int32_t>(sizeof(SENSORLOCATION_LONLATINFO_DAT)) > 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; +} /** * @brief @@ -511,7 +519,7 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * * @param[in] hApp HANDLE - Application handle * @param[in] dat SENSORLOCATION_ALTITUDEINFO_DAT* - Pointer to the acquired altitude information storage destination - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -519,68 +527,68 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * POS_RET_ERROR_INNER Internal error * */ -//POS_RET_API POS_GetAltitude(HANDLE hApp, // NOLINT(readability/nolint) -// SENSORLOCATION_ALTITUDEINFO_DAT *dat, // NOLINT(readability/nolint) -// uint8_t ucGetMethod) { // 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_LOCATION_ALTITUDE; /* 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 altitude data is NULL, it terminates 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) { -// /* GRADE1 */ -// if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || -// (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { -// did = VEHICLE_DID_LOCATION_ALTITUDE; -// } else { -// /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ -// ret = POS_RET_ERROR_PARAM; -// } -// } 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; -// } -// } -// /* Sensor information acquisition */ -// if (ret == POS_RET_NORMAL) { -// /* Data acquisition process */ -// ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)); -// if (static_cast<int32>(sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)) > 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_GetAltitude(HANDLE hApp, // NOLINT(readability/nolint) + SENSORLOCATION_ALTITUDEINFO_DAT *dat, // NOLINT(readability/nolint) + uint8_t ucGetMethod) { // 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_LOCATION_ALTITUDE; /* 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 altitude data is NULL, it terminates 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) { + /* GRADE1 */ + if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_LOCATION_ALTITUDE; + } else { + /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ + ret = POS_RET_ERROR_PARAM; + } + } 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; + } + } + /* Sensor information acquisition */ + if (ret == POS_RET_NORMAL) { + /* Data acquisition process */ + ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)); + if (static_cast<int32_t>(sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)) > 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; +} /** * @brief @@ -590,7 +598,7 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * * @param[in] hApp HANDLE - Application handle * @param[in] dat SENSORMOTION_SPEEDINFO_DAT* - Pointer to the acquired car speed information storage destination - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -598,73 +606,75 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * POS_RET_ERROR_INNER Internal error * */ -//POS_RET_API POS_GetSpeed(HANDLE hApp, // NOLINT(readability/nolint) -// SENSORMOTION_SPEEDINFO_DAT *dat, // NOLINT(readability/nolint) -// uint8_t ucGetMethod) { // NOLINT(readability/nolint) -// POS_RET_API ret = POS_RET_NORMAL; /* Return value */ -// UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ -// DID did; /* Data ID */ -// int32 ret_get_proc; /* POS_GetProc Return Values */ -// -// FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); -// if (hApp == NULL) { -// /* If the handler is NULL, the process terminates with an error. */ -// ret = POS_RET_ERROR_PARAM; -// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [hApp = %p]", hApp); -// } else if (dat == NULL) { -// /* When the pointer to the vehicle speed data storage destination is NULL, the pointer terminates with an error in the parameter. */ -// ret = POS_RET_ERROR_PARAM; -// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [dat = %p]", dat); -// } 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; -// if ((ucGetMethod == SENSOR_GET_METHOD_POS) || -// (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { -// did = VEHICLE_DID_MOTION_SPEED_INTERNAL; -// } else { -// /* End as a parameter error abnormality except for POS/unspecified acquisition method */ -// ret = POS_RET_ERROR_PARAM; -// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, -// "Argument ERROR [type = %d, ucGetMethod = %d]", -// type, ucGetMethod); -// } -// } 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_ERR, __FUNCTION__, "GetEnvSupportInfo ERROR [type = %d]", type); -// } -// } -// -// if (ret == POS_RET_NORMAL) { -// /* Data acquisition process */ -// ret_get_proc = PosGetProc(did, dat, sizeof(SENSORMOTION_SPEEDINFO_DAT)); -// if (static_cast<int32>(sizeof(SENSORMOTION_SPEEDINFO_DAT)) > 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_GetSpeed(HANDLE hApp, // NOLINT(readability/nolint) + SENSORMOTION_SPEEDINFO_DAT *dat, // NOLINT(readability/nolint) + uint8_t ucGetMethod) { // NOLINT(readability/nolint) + POS_RET_API ret = POS_RET_NORMAL; /* Return value */ + UNIT_TYPE type = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ + DID did; /* Data ID */ + int32_t ret_get_proc; /* POS_GetProc Return Values */ + + FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); + if (hApp == NULL) { + /* If the handler is NULL, the process terminates with an error. */ + ret = POS_RET_ERROR_PARAM; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [hApp = %p]", hApp); + } else if (dat == NULL) { + /* When the pointer to the vehicle speed data storage destination is NULL, the pointer terminates with an error in the parameter. */ + ret = POS_RET_ERROR_PARAM; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [dat = %p]", dat); + } 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; + if (ucGetMethod == SENSOR_GET_METHOD_POS) { + did = VEHICLE_DID_MOTION_SPEED_INTERNAL; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_MOTION_SPEED_NAVI; + } else { + /* End as a parameter error abnormality except for POS/unspecified acquisition method */ + ret = POS_RET_ERROR_PARAM; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Argument ERROR [type = %d, ucGetMethod = %d]", + type, ucGetMethod); + } + } 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_ERR, __FUNCTION__, "GetEnvSupportInfo ERROR [type = %d]", type); + } + } + + if (ret == POS_RET_NORMAL) { + /* Data acquisition process */ + ret_get_proc = PosGetProc(did, dat, sizeof(SENSORMOTION_SPEEDINFO_DAT)); + if (static_cast<int32_t>(sizeof(SENSORMOTION_SPEEDINFO_DAT)) > 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; +} /** * @brief @@ -674,7 +684,7 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * * @param[in] hApp HANDLE - Application handle * @param[in] dat SENSORMOTION_HEADINGINFO_DAT* - Pointer to the acquired altitude information storage destination - * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/DR/Not specified) + * @param[in] ucGetMethod uint8_t - Acquisition method(GPS/Navigation/Not specified) * * @return POS_RET_NORMAL Normal completion(Include illegal)<br> * POS_RET_ERROR_PARAM Parameter error<br> @@ -682,68 +692,70 @@ POS_RET_API POS_RegisterListenerHeading(HANDLE hApp, // NOLINT(readability/noli * POS_RET_ERROR_INNER Internal error * */ -//POS_RET_API POS_GetHeading(HANDLE hApp, // NOLINT(readability/nolint) -// SENSORMOTION_HEADINGINFO_DAT *dat, // NOLINT(readability/nolint) -// uint8_t ucGetMethod) { // 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_MOTION_HEADING; /* Data ID */ -// 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) { -// /* GRADE1 */ -// if ((ucGetMethod == SENSOR_GET_METHOD_GPS) || -// (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { -// did = VEHICLE_DID_MOTION_HEADING; -// } else { -// /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ -// ret = POS_RET_ERROR_PARAM; -// } -// } 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; -// } -// } -// /* Sensor information acquisition */ -// if (ret == POS_RET_NORMAL) { -// /* Data acquisition process */ -// ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORMOTION_HEADINGINFO_DAT)); -// if (static_cast<int32>(sizeof(SENSORMOTION_HEADINGINFO_DAT)) > 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_GetHeading(HANDLE hApp, // NOLINT(readability/nolint) + SENSORMOTION_HEADINGINFO_DAT *dat, // NOLINT(readability/nolint) + uint8_t ucGetMethod) { // 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_MOTION_HEADING; /* Data ID */ + 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) { + /* GRADE1 */ + if (ucGetMethod == SENSOR_GET_METHOD_GPS) { + did = VEHICLE_DID_MOTION_HEADING; + } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) || + (ucGetMethod == SENSOR_GET_METHOD_AUTO)) { + did = VEHICLE_DID_MOTION_HEADING_NAVI; + } else { + /* End as a parameter error abnormality except for GPS/unspecified acquisition method */ + ret = POS_RET_ERROR_PARAM; + } + } 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; + } + } + /* Sensor information acquisition */ + if (ret == POS_RET_NORMAL) { + /* Data acquisition process */ + ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORMOTION_HEADINGINFO_DAT)); + if (static_cast<int32_t>(sizeof(SENSORMOTION_HEADINGINFO_DAT)) > 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; +} /** * @brief @@ -792,7 +804,7 @@ POS_RET_API POS_SetSpeedInfo(HANDLE hApp, uint16_t navispeed) { // NOLINT(reada if (ret == POS_RET_NORMAL) { /* Adjustment by unit [1.0km/h]->[0.01m/sec] */ - speed = static_cast<u_int16>(navispeed * 10000 / 360); + speed = static_cast<uint16_t>(navispeed * 10000 / 360); /* Data setting(After setting,Immediate termination) */ ret = PosSetProc(VEHICLE_DID_MOTION_SPEED_NAVI, reinterpret_cast<void *>(&speed), sizeof(uint16_t), FALSE); @@ -867,7 +879,7 @@ POS_RET_API POS_SetLocationInfo(HANDLE hApp, POS_POSDATA* pstPosData) { // NOLI } /* Data setting(After setting,Immediate termination) */ - ret = PosSetProc(VEHICLE_DID_GPS_CUSTOMDATA_NAVI, + ret = PosSetProc(VEHICLE_DID_GPS_CUSTOMDATA_NAVI, // == POSHAL_DID_GPS_CUSTOMDATA_NAVI reinterpret_cast<void *>(pstPosData), sizeof(POS_POSDATA), FALSE); } } @@ -875,66 +887,3 @@ POS_RET_API POS_SetLocationInfo(HANDLE hApp, POS_POSDATA* pstPosData) { // NOLI FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret); return ret; } - - -/** - * @brief - * Location Information (NMEA) Setting - * - * Set Location Information (NEMA) - * - * @param[in] hApp HANDLE - Application handle - * @param[in] locationInfo POS_LOCATIONINFO_NEMA - Pointer to location information - * - * @return POS_RET_NORMAL Normal completion(Include illegal)<br> - * POS_RET_ERROR_PARAM Parameter error<br> - * POS_RET_ERROR_INNER Internal error<br> - * POS_RET_ERROR_NOSUPPORT Unsupported environment - * - */ -POS_RET_API POS_SetLocationInfoNmea( HANDLE hApp, POS_LOCATIONINFO_NMEA* locationInfo ) { - POS_RET_API lRet = POS_RET_NORMAL; /* Return value of this function */ - UNIT_TYPE eType = UNIT_TYPE_NONE; /* Supported HW Configuration Type */ - - FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+"); - - /* Arguments & Support Configuration Check */ - if ((locationInfo == NULL) || (hApp == NULL)) { - lRet = POS_RET_ERROR_PARAM; - } else { - /* Positioning Base API initialization */ - _pb_Setup_CWORD64_API(hApp); - - /* Supported HW Configuration Check */ - eType = GetEnvSupportInfo(); - if ( UNIT_TYPE_GRADE1 == eType ) { - /* GRADE1 */ - lRet = POS_RET_NORMAL; - } else if ( UNIT_TYPE_GRADE2 == eType ) { - /* - * Note. - * This feature branches processing depending on the unit type. - */ - lRet = SENSOR_RET_ERROR_NOSUPPORT; - } else { - /* Environment error */ - lRet = SENSOR_RET_ERROR_NOSUPPORT; - } - } - - if ( lRet == POS_RET_NORMAL ) { - /* check data length */ - if ((locationInfo->length == 0) || (locationInfo->length > LOCATIONINFO_NMEA_MAX)) { - lRet = POS_RET_ERROR_PARAM; - } else { - /* Data setting(After setting,Immediate termination) */ - lRet = PosSetProc( VEHICLE_DID_LOCATIONINFO_NMEA_NAVI, (void*)locationInfo, - locationInfo->length + sizeof(locationInfo->length), FALSE ); - } - } - - FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [lRet = %d]", lRet); - return lRet; -} - - diff --git a/positioning/client/src/POS_common_API/Makefile b/positioning/client/src/POS_common_API/Makefile index 7f4ab1c0..4d7a90fb 100644 --- a/positioning/client/src/POS_common_API/Makefile +++ b/positioning/client/src/POS_common_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,20 +17,12 @@ INST_SHLIBS = libPOS_common_API ######### compiled sources ############# -VPATH += ../SensorLocation_API/common - -libPOS_common_API_SRCS += SensorLocation_API.cpp libPOS_common_API_SRCS += Common_API.cpp ######### add include path ############# -CPPFLAGS += -I./ CPPFLAGS += -I../../../server/include/common CPPFLAGS += -I../../include CPPFLAGS += -I../../../server/include/nsfw -CPPFLAGS += -I../SensorLocation_API/common - -CPPFLAGS += -I../Vehicle_API -CPPFLAGS += -I../Vehicle_API/common ######### add compile option ############# CPPFLAGS += -DLINUX -fPIC diff --git a/positioning/client/src/POS_common_API/libPOS_common_API.ver b/positioning/client/src/POS_common_API/libPOS_common_API.ver index 1e7baf59..afc7f3a5 100644 --- a/positioning/client/src/POS_common_API/libPOS_common_API.ver +++ b/positioning/client/src/POS_common_API/libPOS_common_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. 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. diff --git a/positioning/client/src/POS_naviinfo_API/variant/awnavi/src/Naviinfo_API.cpp b/positioning/client/src/POS_naviinfo_API/variant/awnavi/src/Naviinfo_API.cpp deleted file mode 100644 index 38f821f6..00000000 --- a/positioning/client/src/POS_naviinfo_API/variant/awnavi/src/Naviinfo_API.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2019 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 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>(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 */ - u_int16 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 altitude; -// int64_t tmp; -// u_int16 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>(0x7FFFFFFF)) { -// /* +Overflow of digits */ -// altitude = static_cast<int32>(0x7FFFFFFF); -// } else if (tmp < static_cast<int32>(0x80000000)) { /* Ignore->MISRA-C:2004 Rule 3.1 */ -// /* -Overflow of digits */ -// altitude = static_cast<int32>(0x80000000); /* Ignore->MISRA-C:2004 Rule 3.1 */ -// } else { -// altitude = static_cast<int32>(tmp); -// } -// navi_loc_info->stNaviGps.altitude = altitude; -// -// /* Measurement Azimuth Conversion[0.Once]->[0.01 degree] */ -// heading = navi_loc_info->stNaviGps.heading; -// heading = static_cast<u_int16>(heading - ((heading / 3600) * 3600)); -// heading = static_cast<u_int16>(heading * 10); -// navi_loc_info->stNaviGps.heading = heading; -// -// return; -//} diff --git a/positioning/client/src/POS_sensor_API/Makefile b/positioning/client/src/POS_sensor_API/Makefile index bde53d22..a4f627f4 100644 --- a/positioning/client/src/POS_sensor_API/Makefile +++ b/positioning/client/src/POS_sensor_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,21 +17,14 @@ INST_SHLIBS = libPOS_sensor_API ######### compiled sources ############# -VPATH += ../Vehicle_API/common ./common - libPOS_sensor_API_SRCS += Sensor_API.cpp libPOS_sensor_API_SRCS += Vehicle_API.cpp ######### add include path ############# -CPPFLAGS += -I./ -CPPFLAGS += -I./common/ CPPFLAGS += -I../../../server/include/common CPPFLAGS += -I../../include CPPFLAGS += -I../../../server/include/nsfw -CPPFLAGS += -I../Vehicle_API -CPPFLAGS += -I../Vehicle_API/common - ######### add compile option ############# CPPFLAGS += -DLINUX -fPIC diff --git a/positioning/client/src/POS_sensor_API/common/Sensor_API.cpp b/positioning/client/src/POS_sensor_API/Sensor_API.cpp index a015998f..179eb926 100644 --- a/positioning/client/src/POS_sensor_API/common/Sensor_API.cpp +++ b/positioning/client/src/POS_sensor_API/Sensor_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. @@ -19,24 +19,21 @@ * System name :GPF * Subsystem name :Sensor I/F library * Program name :SensorI/F API - * Module configuration :SensorPkgDeliveryEntry() Vehicle sensor information package delivery registration - * :SensorGetSensorPkgData() Vehicle sensor information package acquisition ******************************************************************************/ #include <stdio.h> -#include "Sensor_API.h" +#include <vehicle_service/POS_sensor_API.h> +#include <vehicle_service/POS_define.h> +#include <vehicle_service/POS_sensor_API.h> +#include <vehicle_service/positioning_base_library.h> +#include "POS_sensor_private.h" +#include "Sensor_Common_API.h" #include "Sensor_API_private.h" -/* ++ GPS _CWORD82_ support */ -#include "Vehicle_API_Dummy.h" -/* -- GPS _CWORD82_ support */ - #include "Sensor_Common_API.h" +#include "Vehicle_API_Dummy.h" #include "Vehicle_API_private.h" #include "Naviinfo_API.h" -#include <vehicle_service/POS_define.h> -#include <vehicle_service/POS_sensor_API.h> #include "POS_private.h" -#include <vehicle_service/positioning_base_library.h> /*************************************************/ /* Global variable */ @@ -51,31 +48,37 @@ */ static const SENSOR_RET_PKG g_ret_list_reg_lis_pkg_sens_data[SENSOR_PUBLIC_DID_NUM] = { /* GRADE2 GRADE1 DID (Key) */ - {TRUE, FALSE, POS_DID_SPEED_PULSE }, - {FALSE, FALSE, POS_DID_SPEED_KMPH }, - {TRUE, FALSE, POS_DID_GYRO }, - {TRUE, FALSE, POS_DID_GSNS_X }, - {TRUE, FALSE, POS_DID_GSNS_Y }, - {FALSE, FALSE, POS_DID_GPS_ANTENNA }, - {TRUE, FALSE, POS_DID_SNS_COUNTER }, - {FALSE, FALSE, POS_DID_SPEED_PULSE_FST }, - {FALSE, FALSE, POS_DID_GYRO_FST }, - {FALSE, FALSE, POS_DID_GPS__CWORD82__NMEA }, - {FALSE, FALSE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, - {FALSE, FALSE, POS_DID_GPS__CWORD82__FULLBINARY }, - {FALSE, FALSE, POS_DID_GPS_NMEA }, - {TRUE, FALSE, POS_DID_REV }, - {FALSE, FALSE, POS_DID_REV_FST }, - {TRUE, FALSE, POS_DID_GYRO_TEMP }, - {FALSE, FALSE, POS_DID_GYRO_TEMP_FST }, - {FALSE, FALSE, POS_DID_GSNS_X_FST }, - {FALSE, FALSE, POS_DID_GSNS_Y_FST }, - {TRUE, FALSE, POS_DID_PULSE_TIME }, - {FALSE, FALSE, POS_DID_GPS_CLOCK_DRIFT }, - {FALSE, FALSE, POS_DID_GPS_CLOCK_FREQ }, - {FALSE, FALSE, VEHICLE_DID_GPS_TIME }, /* For local use */ - {FALSE, FALSE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */ - {FALSE, FALSE, VEHICLE_DID_GPS_WKNROLLOVER } /* For local use */ + {TRUE, TRUE, POS_DID_SPEED_PULSE }, + {FALSE, TRUE, POS_DID_SPEED_KMPH }, + {TRUE, TRUE, POS_DID_GYRO_X }, + {TRUE, TRUE, POS_DID_GYRO_Y }, + {TRUE, TRUE, POS_DID_GYRO_Z }, + {TRUE, TRUE, POS_DID_GSNS_X }, + {TRUE, TRUE, POS_DID_GSNS_Y }, + {TRUE, TRUE, POS_DID_GSNS_Z }, + {FALSE, TRUE, POS_DID_GPS_ANTENNA }, + {TRUE, TRUE, POS_DID_SNS_COUNTER }, + {FALSE, TRUE, POS_DID_SPEED_PULSE_FST }, + {FALSE, TRUE, POS_DID_GYRO_X_FST }, + {FALSE, TRUE, POS_DID_GYRO_Y_FST }, + {FALSE, TRUE, POS_DID_GYRO_Z_FST }, + {FALSE, TRUE, POS_DID_GPS__CWORD82__NMEA }, + {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, + {FALSE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY }, + {FALSE, TRUE, POS_DID_GPS_NMEA }, + {TRUE, TRUE, POS_DID_REV }, + {FALSE, TRUE, POS_DID_REV_FST }, + {TRUE, TRUE, POS_DID_GYRO_TEMP }, + {FALSE, TRUE, POS_DID_GYRO_TEMP_FST }, + {FALSE, TRUE, POS_DID_GSNS_X_FST }, + {FALSE, TRUE, POS_DID_GSNS_Y_FST }, + {FALSE, TRUE, POS_DID_GSNS_Z_FST }, + {TRUE, TRUE, POS_DID_PULSE_TIME }, + {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT }, + {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ }, + {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */ + {FALSE, TRUE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */ + {FALSE, TRUE, VEHICLE_DID_GPS_WKNROLLOVER} /* For local use */ }; /** @@ -84,30 +87,36 @@ static const SENSOR_RET_PKG g_ret_list_reg_lis_pkg_sens_data[SENSOR_PUBLIC_DID_N static const SENSOR_RET_PKG g_ret_list_reg_lis_sens_data[SENSOR_PUBLIC_DID_NUM] = { /* GRADE2 GRADE1 DID (Key) */ {TRUE, TRUE, POS_DID_SPEED_PULSE }, - {FALSE, FALSE, POS_DID_SPEED_KMPH }, - {TRUE, FALSE, POS_DID_GYRO }, - {TRUE, FALSE, POS_DID_GSNS_X }, - {TRUE, FALSE, POS_DID_GSNS_Y }, + {FALSE, TRUE, POS_DID_SPEED_KMPH }, + {TRUE, TRUE, POS_DID_GYRO_X }, + {TRUE, TRUE, POS_DID_GYRO_Y }, + {TRUE, TRUE, POS_DID_GYRO_Z }, + {TRUE, TRUE, POS_DID_GSNS_X }, + {TRUE, TRUE, POS_DID_GSNS_Y }, + {TRUE, TRUE, POS_DID_GSNS_Z }, {TRUE, TRUE, POS_DID_GPS_ANTENNA }, - {FALSE, FALSE, POS_DID_SNS_COUNTER }, - {TRUE, FALSE, POS_DID_SPEED_PULSE_FST }, - {TRUE, FALSE, POS_DID_GYRO_FST }, - {TRUE, FALSE, POS_DID_GPS__CWORD82__NMEA }, - {FALSE, FALSE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, - {TRUE, FALSE, POS_DID_GPS__CWORD82__FULLBINARY }, + {FALSE, TRUE, POS_DID_SNS_COUNTER }, + {TRUE, TRUE, POS_DID_SPEED_PULSE_FST }, + {TRUE, TRUE, POS_DID_GYRO_X_FST }, + {TRUE, TRUE, POS_DID_GYRO_Y_FST }, + {TRUE, TRUE, POS_DID_GYRO_Z_FST }, + {TRUE, TRUE, POS_DID_GPS__CWORD82__NMEA }, + {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, + {TRUE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY }, {FALSE, TRUE, POS_DID_GPS_NMEA }, - {FALSE, FALSE, POS_DID_REV }, - {TRUE, FALSE, POS_DID_REV_FST }, - {TRUE, FALSE, POS_DID_GYRO_TEMP }, - {TRUE, FALSE, POS_DID_GYRO_TEMP_FST }, - {TRUE, FALSE, POS_DID_GSNS_X_FST }, - {TRUE, FALSE, POS_DID_GSNS_Y_FST }, - {FALSE, FALSE, POS_DID_PULSE_TIME }, + {FALSE, TRUE, POS_DID_REV }, + {TRUE, TRUE, POS_DID_REV_FST }, + {TRUE, TRUE, POS_DID_GYRO_TEMP }, + {TRUE, TRUE, POS_DID_GYRO_TEMP_FST }, + {TRUE, TRUE, POS_DID_GSNS_X_FST }, + {TRUE, TRUE, POS_DID_GSNS_Y_FST }, + {TRUE, TRUE, POS_DID_GSNS_Z_FST }, + {FALSE, TRUE, POS_DID_PULSE_TIME }, {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT }, {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ }, - {FALSE, FALSE, VEHICLE_DID_GPS_TIME }, /* For local use */ - {FALSE, FALSE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */ - {FALSE, FALSE, VEHICLE_DID_GPS_WKNROLLOVER } /* For local use */ + {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */ + {FALSE, TRUE, VEHICLE_DID_GPS_TIME_RAW }, /* For local use */ + {FALSE, TRUE, VEHICLE_DID_GPS_WKNROLLOVER } /* For local use */ }; /** @@ -116,25 +125,31 @@ static const SENSOR_RET_PKG g_ret_list_reg_lis_sens_data[SENSOR_PUBLIC_DID_NUM] static const SENSOR_RET_PKG g_ret_list_get_sens_data[SENSOR_PUBLIC_DID_NUM] = { /* GRADE2 GRADE1 DID (Key) */ {TRUE, TRUE, POS_DID_SPEED_PULSE }, - {FALSE, FALSE, POS_DID_SPEED_KMPH }, - {TRUE, FALSE, POS_DID_GYRO }, - {TRUE, FALSE, POS_DID_GSNS_X }, - {TRUE, FALSE, POS_DID_GSNS_Y }, + {FALSE, TRUE, POS_DID_SPEED_KMPH }, + {TRUE, TRUE, POS_DID_GYRO_X }, + {TRUE, TRUE, POS_DID_GYRO_Y }, + {TRUE, TRUE, POS_DID_GYRO_Z }, + {TRUE, TRUE, POS_DID_GSNS_X }, + {TRUE, TRUE, POS_DID_GSNS_Y }, + {TRUE, TRUE, POS_DID_GSNS_Z }, {TRUE, TRUE, POS_DID_GPS_ANTENNA }, - {FALSE, FALSE, POS_DID_SNS_COUNTER }, - {FALSE, FALSE, POS_DID_SPEED_PULSE_FST }, - {FALSE, FALSE, POS_DID_GYRO_FST }, - {TRUE, FALSE, POS_DID_GPS__CWORD82__NMEA }, - {FALSE, FALSE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, - {TRUE, FALSE, POS_DID_GPS__CWORD82__FULLBINARY }, + {FALSE, TRUE, POS_DID_SNS_COUNTER }, + {FALSE, TRUE, POS_DID_SPEED_PULSE_FST }, + {FALSE, TRUE, POS_DID_GYRO_X_FST }, + {FALSE, TRUE, POS_DID_GYRO_Y_FST }, + {FALSE, TRUE, POS_DID_GYRO_Z_FST }, + {TRUE, TRUE, POS_DID_GPS__CWORD82__NMEA }, + {FALSE, TRUE, POS_DID_GPS__CWORD82___CWORD44_GP4 }, + {TRUE, TRUE, POS_DID_GPS__CWORD82__FULLBINARY }, {FALSE, TRUE, POS_DID_GPS_NMEA }, - {FALSE, FALSE, POS_DID_REV }, - {FALSE, FALSE, POS_DID_REV_FST }, - {TRUE, FALSE, POS_DID_GYRO_TEMP }, - {FALSE, FALSE, POS_DID_GYRO_TEMP_FST }, - {FALSE, FALSE, POS_DID_GSNS_X_FST }, - {FALSE, FALSE, POS_DID_GSNS_Y_FST }, - {FALSE, FALSE, POS_DID_PULSE_TIME }, + {FALSE, TRUE, POS_DID_REV }, + {FALSE, TRUE, POS_DID_REV_FST }, + {TRUE, TRUE, POS_DID_GYRO_TEMP }, + {FALSE, TRUE, POS_DID_GYRO_TEMP_FST }, + {FALSE, TRUE, POS_DID_GSNS_X_FST }, + {FALSE, TRUE, POS_DID_GSNS_Y_FST }, + {FALSE, TRUE, POS_DID_GSNS_Z_FST }, + {FALSE, TRUE, POS_DID_PULSE_TIME }, {FALSE, TRUE, POS_DID_GPS_CLOCK_DRIFT }, {FALSE, TRUE, POS_DID_GPS_CLOCK_FREQ }, {FALSE, TRUE, VEHICLE_DID_GPS_TIME }, /* For local use */ @@ -260,9 +275,9 @@ SENSOR_RET_API POS_RegisterListenerPkgSensData(HANDLE hApp, BOOL ret_b; RET_API ret_api; /* System API return value */ EventID event_id; /* Event ID */ - int32 event_val; /* Event value */ + int32_t event_val; /* Event value */ SENSOR_MSG_DELIVERY_ENTRY_DAT data; /* Message data */ - int32 i; /* Generic counters */ + int32_t i; /* Generic counters */ PNO ch_pno; /* Converted internal PNO */ UNIT_TYPE type; /* Supported HW Configuration Type */ @@ -363,19 +378,14 @@ SENSOR_RET_API POS_RegisterListenerPkgSensData(HANDLE hApp, data.ctrl_flg = ucCtrlFlg; data.event_id = event_id; for (i = 0; i < ucPkgNum; i++) { - if (pulDid[i] == POS_DID_GYRO) { - /* Replaced because POS_DID_GYRO is treated internally as VEHICLE_DID_GYRO_EXT. */ - data.did[i] = VEHICLE_DID_GYRO_EXT; - } else { - data.did[i] = pulDid[i]; - } + data.did[i] = pulDid[i]; } /* Messaging */ ret_api = PosSndMsg(ch_pno, PNO_VEHICLE_SENSOR, CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT, - (u_int16)sizeof(SENSOR_MSG_DELIVERY_ENTRY_DAT), + (uint16_t)sizeof(SENSOR_MSG_DELIVERY_ENTRY_DAT), (const void *)&data); if (RET_NORMAL == ret_api) { @@ -485,12 +495,12 @@ RET_API PosDeleteEvent(EventID event_id) { * RETURN : RET_NORMAL : Normal completion * : RET_ERROR : There is no shared memory area. ******************************************************************************/ -RET_API SensorLinkShareData(void **share_top, u_int32 *share_size, u_int16 *offset) { // LCOV_EXCL_START 8:dead code +RET_API SensorLinkShareData(void **share_top, uint32_t *share_size, uint16_t *offset) { // LCOV_EXCL_START 8:dead code AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert RET_API ret_api; /* System API return value */ SemID sem_id; /* Semaphore ID */ SENSOR_SHARE *share_top_tmp; - int32 i; + int32_t i; /* Initialization */ ret_api = RET_ERROR; @@ -519,7 +529,7 @@ RET_API SensorLinkShareData(void **share_top, u_int32 *share_size, u_int16 *offs share_top_tmp->mng.lock_info[i] = SENSOR_SHARE_LOCK; /* Calculate the offset to the block */ - *offset = static_cast<u_int16>(i * SENSOR_SHARE_BLOCK_SIZE); + *offset = static_cast<uint16_t>(i * SENSOR_SHARE_BLOCK_SIZE); /* Normal completion */ ret_api = RET_NORMAL; @@ -556,11 +566,11 @@ RET_API SensorLinkShareData(void **share_top, u_int32 *share_size, u_int16 *offs * RETURN : RET_NORMAL : Normal completion * : RET_ERROR : There is no shared memory area./semaphore error ******************************************************************************/ -RET_API SensorUnLinkShareData(SENSOR_SHARE *share_top, u_int16 offset) { // LCOV_EXCL_START 8:dead code +RET_API SensorUnLinkShareData(SENSOR_SHARE *share_top, uint16_t offset) { // LCOV_EXCL_START 8:dead code AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert RET_API ret_api; /* System API return value */ SemID sem_id; /* Semaphore ID */ - int32 i; + int32_t i; /* Initialization */ ret_api = RET_ERROR; @@ -604,12 +614,12 @@ RET_API SensorUnLinkShareData(SENSOR_SHARE *share_top, u_int16 offset) { // LCO * NOTE : * RETURN : void ******************************************************************************/ -void SensorSetShareData(void *share_top, u_int16 offset, const void *data_src, u_int16 size_src) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length) +void SensorSetShareData(void *share_top, uint16_t offset, const void *data_src, uint16_t size_src) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length) AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert SENSOR_SHARE_BLOCK_DAT *share_dat; /* Calculate Shared Memory Write Address */ - share_dat = reinterpret_cast<SENSOR_SHARE_BLOCK_DAT *>(reinterpret_cast<u_int8 *>(share_top) + offset); + share_dat = reinterpret_cast<SENSOR_SHARE_BLOCK_DAT *>(reinterpret_cast<uint8_t *>(share_top) + offset); /* #QAC confirmation Rule11.4 Use structure for member reference(Cast according to shared memory link IF) */ /* Clear Shared Memory */ @@ -638,7 +648,7 @@ void SensorSetShareData(void *share_top, u_int16 offset, const void *data_src, u * : RET_ERRMSGFULL : Message queue overflows * : RET_ERRPARAM : Buffer size error ******************************************************************************/ -RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, u_int16 msg_len, const void *msg_data) { +RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, uint16_t msg_len, const void *msg_data) { SENSOR_INTERNAL_MSG_BUF msg_buf; /* message buffer */ T_APIMSG_MSGBUF_HEADER *msg_hdr; /* Pointer to the message header */ RET_API ret_api; /* Return value */ @@ -684,7 +694,7 @@ RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, u_int16 msg_len, const voi /* Internal Process Transmission and Reception Messages */ ret_api = _pb_SndMsg(pno_dest, - (u_int16)(sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len),/* Ignore->MISRA-C++:2008 Rule 5-0-5 */ + (uint16_t)(sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len),/* Ignore->MISRA-C++:2008 Rule 5-0-5 */ reinterpret_cast<void *>(&msg_buf), 0); } else { /* Internal debug log output */ @@ -694,7 +704,7 @@ RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, u_int16 msg_len, const voi /* External Process Transmission and Reception Messages */ ret_api = _pb_SndMsg_Ext(thread_name, cid, - (u_int16)(msg_len), /* Ignore->MISRA-C++:2008 Rule 5-0-5 */ + (uint16_t)(msg_len), /* Ignore->MISRA-C++:2008 Rule 5-0-5 */ reinterpret_cast<void *>(&(msg_buf.data)), 0); } /* If RET_ERROR,Register a dialog if called from a Vehicle related thread */ /* Task_30332 */ @@ -758,18 +768,17 @@ POS_RET_API POS_GetSensData(HANDLE hApp, DID did, void *dest_data, uint16_t dest } } -// if (ret == NAVIINFO_RET_NORMAL) { -// /* Judge DID*/ -// ret_b = SENSOR_DID_JUDGE_GET(did); -// if (ret_b == FALSE) { -// /* An unacceptable ID is regarded as a parameter error. */ -// ret = POS_RET_ERROR_PARAM; -// } else { -// /* Data acquisition process */ -// ret = PosGetProc(did, dest_data, dest_size); -// } -// } + if (ret == NAVIINFO_RET_NORMAL) { + /* Judge DID*/ + ret_b = SENSOR_DID_JUDGE_GET(did); + if (ret_b == FALSE) { + /* An unacceptable ID is regarded as a parameter error. */ + ret = POS_RET_ERROR_PARAM; + } else { + /* Data acquisition process */ + ret = PosGetProc(did, dest_data, dest_size); + } + } return ret; } - diff --git a/positioning/client/src/Vehicle_API/common/Vehicle_API.cpp b/positioning/client/src/POS_sensor_API/Vehicle_API.cpp index 27487d15..3cd97f86 100644 --- a/positioning/client/src/Vehicle_API/common/Vehicle_API.cpp +++ b/positioning/client/src/POS_sensor_API/Vehicle_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. diff --git a/positioning/client/src/POS_sensor_API/libPOS_sensor_API.ver b/positioning/client/src/POS_sensor_API/libPOS_sensor_API.ver index 5cb4bc2b..10fd95bc 100644 --- a/positioning/client/src/POS_sensor_API/libPOS_sensor_API.ver +++ b/positioning/client/src/POS_sensor_API/libPOS_sensor_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. diff --git a/positioning/client/src/SensorLocation_API/common/SensorLocation_API.cpp b/positioning/client/src/SensorLocation_API/common/SensorLocation_API.cpp deleted file mode 100644 index f39c9e17..00000000 --- a/positioning/client/src/SensorLocation_API/common/SensorLocation_API.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2019 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 SensorLocation_API.cpp -@detail SensorLocation_API Functions -@lib libSensorLocation_API.so -******************************************************************************/ - -/***************************************************************************** - * Include * - *****************************************************************************/ -#include <vehicle_service/positioning_base_library.h> -#include "SensorLocation_API.h" -#include "Vehicle_API.h" -#include "Vehicle_API_Dummy.h" -#include "SensorLocation_API_private.h" - -static RET_API SensorLocationGetLonLatOnShutdownGetData(LONLAT *lonlat); - -/******************************************************************************* -* MODULE : SensorLocationGetLonLatOnShutdownGetData -* ABSTRACT : Obtain position at shutdown -* FUNCTION : Gets the location at shutdown from shared memory -* ARGUMENT : LONLAT * lonlat : Latitude/Longitude -* NOTE : -* RETURN : RET_NORMAL : Successful acquisition -* : RET_ERROR : Failed to acquire -* : RET_ERRPARAM : Parameter error -******************************************************************************/ -static RET_API SensorLocationGetLonLatOnShutdownGetData(LONLAT *lonlat) { // LCOV_EXCL_START 8:dead code - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - RET_API ret = RET_NORMAL; - RET_API ret_api; - LONLAT *share_mem; /* Store Shared Memory Address */ - u_int32 share_mem_size; /* Size of the linked shared memory */ - - if (lonlat == NULL) { - ret = RET_ERRPARAM; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lonlat is NULL\r\n"); - } else { - /* Link to shared memory */ - ret_api = _pb_LinkShareData(const_cast<char *>(LONLAT_SHARE_NAME), - reinterpret_cast<void **>(&share_mem), &share_mem_size); - /* #QAC confirmation Rule11.4 Use structure for member reference(Cast according to shared memory link IF) */ - - if (ret_api == RET_NORMAL) { - /* Link to shared memory successful */ - - /* Get shutdown location from shared memory */ - *lonlat = *share_mem; - } else { - /* Failed to link to shared memory */ - ret = RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't link shared memory\r\n"); - } - } - - return ret; -} -// LCOV_EXCL_STOP - -/****************************************************************************** -@brief SensorLocationGetLonLatOnShutdown<BR> - Obtain position at shutdown -@outline Get location information at shutdown. -@param[in] none -@param[out] LONLAT* lonlat: Pointer to the acquired latitude/longitude information storage destination -@return SENSORLOCATION_RET_API -@retval SENSORLOCATION_RET_NORMAL : Normal completion -@retval SENSORLOCATION_RET_ERROR_INNER : Internal error -*******************************************************************************/ -SENSORLOCATION_RET_API SensorLocationGetLonLatOnShutdown(LONLAT *lonlat) { // LCOV_EXCL_START 8:dead code - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - SENSORLOCATION_RET_API ret; - RET_API ret_api; /* API return value */ - RET_API ret_tmp; - SemID sem_id; /* Semaphore ID */ - - if (lonlat != NULL) { - /* Get Semaphore ID */ - sem_id = _pb_CreateSemaphore(const_cast<char *>(LONLAT_SEMAPHO_NAME)); - - if (sem_id != 0) { /* Because the return value of _pb_CreateSemaphore is not defined in #define,Evaluate directly */ - /* Semaphore ID successfully acquired */ - - /* Semaphore Lock */ - ret_api = _pb_SemLock(sem_id); - - if (ret_api == RET_NORMAL) { - /* Semaphore lock successful */ - - /* Obtain position at shutdown */ - ret_tmp = SensorLocationGetLonLatOnShutdownGetData(lonlat); - - if (ret_tmp == RET_NORMAL) { - /* Position acquisition at shutdown successful */ - ret = SENSORLOCATION_RET_NORMAL; - } else { - /* Location acquisition at shutdown failed */ - ret = SENSORLOCATION_RET_ERROR_INNER; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SensorLocationGetLonLatOnShutdownGetData failed"); - } - - /* Semaphore unlock */ - ret_api = _pb_SemUnlock(sem_id); - if (ret_api != RET_NORMAL) { - /* Semaphore unlock failure */ - ret = SENSORLOCATION_RET_ERROR_INNER; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SemUnlock failed"); - } - } else { - /* Semaphore lock failed */ - ret = SENSORLOCATION_RET_ERROR_INNER; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SemLock failed"); - } - } else { - /* Semaphore ID acquisition failure */ - ret = SENSORLOCATION_RET_ERROR_INNER; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "sem_id == 0"); - } - } else { - ret = SENSORLOCATION_RET_ERROR_INNER; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lonlat == NULL"); - } - - return ret; -} -// LCOV_EXCL_STOP diff --git a/positioning/client/src/VehicleDebug_API/common/VehicleDebug_API.cpp b/positioning/client/src/VehicleDebug_API/common/VehicleDebug_API.cpp deleted file mode 100644 index 7ac19b2f..00000000 --- a/positioning/client/src/VehicleDebug_API/common/VehicleDebug_API.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* - * @copyright Copyright (c) 2016-2019 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 VehicleDebug_API.cpp -@detail VehicleDebug_API Functions -@lib libVehicleDebug_API.so -******************************************************************************/ - -/***************************************************************************** - * Include * - *****************************************************************************/ -#include <vehicle_service/positioning_base_library.h> -#include "VehicleDebug_API.h" -#include "VehicleDebug_API_private.h" - -static VEHICLEDEBUG_RET_API VehicleDebugSndMsg(PNO pno_src, - PNO pno_dest, CID cid, u_int16 msg_len, const void *msg_data); -static RET_API SensorGetLogSettingGetData(u_int32 *log_sw, u_int8 *severity); -static EventID SensorGetLogSettingCreateEvent(PNO pno); -static RET_API SensorGetLogSettingDeleteEvent(EventID event_id); - -/******************************************************************************* -* MODULE : SensorGetLogSettingGetData -* ABSTRACT : Get Log Settings from Shared Memory -* FUNCTION : Get log settings from shared memory -* ARGUMENT : u_int32* log_sw : Log type -* : u_int8* severity : Output level -* NOTE : -* RETURN : RET_NORMAL : Successful acquisition -* : RET_ERROR : Failed to acquire -* : RET_ERRPARAM : Parameter error -******************************************************************************/ -static RET_API SensorGetLogSettingGetData(u_int32 *log_sw, u_int8 *severity) { - RET_API ret = RET_NORMAL; - RET_API ret_api; /* API return value */ - VEHICLEDEBUG_MSG_LOGINFO_DAT *share_mem; /* Store Shared Memory Address */ - u_int32 share_mem_size; /* Size of the linked shared memory */ - - if (log_sw == NULL || severity == NULL) { - ret = RET_ERRPARAM; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "log_sw == NULL or severity == NULL\r\n"); - } else { - /* Link to shared memory */ - ret_api = _pb_LinkShareData(const_cast<char*>(LOG_SETTING_SHARE_MEMORY_NAME), - reinterpret_cast<void **>(&share_mem), &share_mem_size); - /* #QAC confirmation Rule11.4 Use structure for member reference(Cast according to shared memory link IF) */ - - if (ret_api == RET_NORMAL) { - /* Link to shared memory successful */ - if (share_mem_size == VEHICLEDEBUG_MSGBUF_DSIZE) { - /* When the size of the linked shared memory is correct */ - - /* Get log type/output level from shared memory */ - *log_sw = share_mem->log_sw; - (void)memcpy(reinterpret_cast<void *>(severity), - (const void *)(share_mem->severity), sizeof(share_mem->severity)); - } else { - /* The size of the linked shared memory is incorrect. */ - ret = RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Bad shared memory size\r\n"); - } - } else { - /* Failed to link to shared memory */ - ret = RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't link shared memory\r\n"); - } - } - - return ret; -} - -/******************************************************************************* -* MODULE : SensorGetLogSettingCreateEvent -* ABSTRACT : Event Generation -* FUNCTION : Generate an event -* ARGUMENT : PNO pno : Destination thread ID -* NOTE : -* RETURN : EventID event_id : Event ID (Event set failed if 0) -******************************************************************************/ -static EventID SensorGetLogSettingCreateEvent(PNO pno) { - EventID event_id; /* Event ID */ - int8 event_name[32]; /* Event name character string buffer */ - - /* Initialization of event name character string buffer */ - (void)memset(reinterpret_cast<void *>(event_name), 0, sizeof(event_name)); - - /* Event name creation */ - snprintf(event_name, sizeof(event_name), "VehicleDebug_%X", pno); - - /* Event Generation */ - event_id = _pb_CreateEvent(_CWORD64_EVENT_MANUALRESET_OFF, VEHICLEDEBUG_EVENT_VAL_INIT, event_name); - - return event_id; -} - -/******************************************************************************* - * MODULE : SensorGetLogSettingDeleteEvent - * ABSTRACT : Event deletion processing - * FUNCTION : Delete events - * ARGUMENT : event_id : Event ID of the event to delete - * NOTE : - * RETURN : RET_NORMAL : Normal completion - * : RET_EV_NONE : Specified event does not exist - ******************************************************************************/ -static RET_API SensorGetLogSettingDeleteEvent(EventID event_id) { - return(_pb_DeleteEvent(event_id)); -} - -/******************************************************************************* -@brief SensorGetLogSetting<BR> - Log setting acquisition -@outline Get the log settings. -@param[in] PNO pno : Destination thread ID -@param[out] u_int32* log_sw : Log type -@param[out] u_int8* severity : Output level -@return SENSORMOTION_RET_API -@retval VEHICLEDEBUG_RET_NORMAL : Successful acquisition -@retval VEHICLEDEBUG_RET_ERROR : Acquisition failure error -*******************************************************************************/ -VEHICLEDEBUG_RET_API SensorGetLogSetting(PNO pno, u_int32 *log_sw, u_int8 *severity) { - VEHICLEDEBUG_RET_API ret; - RET_API ret_api; /* API return value */ - RET_API ret_tmp; - EventID event_id; /* Event ID */ - int32 event_val; /* Event value */ - SemID sem_id; /* Semaphore ID */ - VEHICLEDEBUG_MSG_LOGINFO_DAT data; /* Message data(Dummy) */ - - if (log_sw == NULL || severity == NULL) { - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "log_sw == NULL or severity == NULL\r\n"); - } else { - /* Set of events */ - event_id = SensorGetLogSettingCreateEvent(pno); - - if (event_id != 0) { - /* Event Set Success */ - - /* Messaging(Notify VehicleSens_thread) */ - /* Because it uses shared memory for data retrieval,Message body does not need to be sent */ - ret_api = VehicleDebugSndMsg(pno, - PNO_VEHICLE_SENSOR, - CID_VEHICLEDEBUG_LOG_GET, - 0, /* Message size is set to 0 */ - (const void *)&data); /* Message data(Dummy) -> Errors by NULL */ - - if (ret_api == RET_NORMAL) { - /* Message transmission success */ - - /* Wait for completion event */ - ret_api = _pb_WaitEvent(event_id, - SAPI_EVWAIT_VAL, - VEHICLEDEBUG_RET_ERROR_MIN, VEHICLEDEBUG_RET_NORMAL, &event_val, INFINITE); - if (ret_api == RET_NORMAL) { - /* Return from Event Wait */ - if (event_val == VEHICLEDEBUG_RET_NORMAL) { - /* Log setting acquisition function succeeded */ - - /* Get Semaphore ID */ - sem_id = _pb_CreateSemaphore(const_cast<char *>(SENSOR_LOG_SETTING_SEMAPHO_NAME)); - - /* Because the return value of _pb_CreateSemaphore is not defined in #define,Evaluate directly */ - if (sem_id != 0) { - /* Semaphore ID successfully acquired */ - /* Semaphore Lock */ - ret_api = _pb_SemLock(sem_id); - - if (ret_api == RET_NORMAL) { - /* Semaphore lock successful */ - - /* Get Log Settings from Shared Memory */ - ret_tmp = SensorGetLogSettingGetData(log_sw, severity); - - if (ret_tmp == RET_NORMAL) { - /* Log setting acquisition success */ - ret = VEHICLEDEBUG_RET_NORMAL; - } else { - /* Log setting acquisition failure */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SensorGetLogSettingGetData Failed"); - } - - /* Semaphore unlock */ - ret_api = _pb_SemUnlock(sem_id); - if (ret_api != RET_NORMAL) { - /* Semaphore unlock failure */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SemUnlock Failed"); - } - } else { - /* Semaphore lock failed */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_SemLock Failed"); - } - } else { - /* Semaphore ID acquisition failure */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "sem_id == 0"); - } - } else { - /* Log setting acquisition function failed */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "event_val != VEHICLEDEBUG_RET_NORMAL"); - } - } else { - /* _pb_WaitEvent failed */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_WaitEvent Failed"); - } - } else { - /* Message transmission failure */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "VehicleDebugSndMsg Failed"); - } - /* Event deletion */ - (void)SensorGetLogSettingDeleteEvent(event_id); - } else { - /* Event set failed */ - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "event_id == 0"); - } - } - - return ret; -} - -/******************************************************************************* -@brief SensorSetLogStatus<BR> - Log Setting Request -@outline Configure the log. -@param[in] PNO pno : Destination thread ID -@param[in] u_int32 log_sw : Log type - Correspond to the log output by each bit. - 0th bit : Location Log Output Settings(0:OFF 1:ON) -@param[in] u_int8* severity : Output level(Not used) -@param[out] None -@return SENSORMOTION_RET_API -@retval VEHICLEDEBUG_RET_NORMAL : Setting success -@retval VEHICLEDEBUG_RET_ERROR : Setting failed -*******************************************************************************/ -VEHICLEDEBUG_RET_API SensorSetLogStatus(PNO pno, u_int32 log_sw, u_int8 *severity) { - RET_API ret_api = RET_NORMAL; /* System API return value */ - VEHICLEDEBUG_RET_API ret = VEHICLEDEBUG_RET_NORMAL; /* Return value */ - VEHICLEDEBUG_MSG_LOGINFO_DAT data; /* Message data */ - - if (severity != NULL) { - /* Message configuration */ - data.log_sw = log_sw; - (void)memcpy(reinterpret_cast<void *>(&(data.severity[0])), (const void *)(severity), sizeof(data.severity)); - - /* Messaging */ - ret_api = VehicleDebugSndMsg(pno, - PNO_VEHICLE_SENSOR, - CID_VEHICLEDEBUG_LOG_SET, - (u_int16)sizeof(VEHICLEDEBUG_MSG_LOGINFO_DAT), - (const void *)&data); - if (ret_api == RET_NORMAL) { - ret = VEHICLEDEBUG_RET_NORMAL; - } else { - ret = VEHICLEDEBUG_RET_ERROR; - } - } else { - ret = VEHICLEDEBUG_RET_ERROR; - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "severity == NULL"); - } - - return ret; -} - -/******************************************************************************* - * MODULE : VehicleDebugSndMsg - * ABSTRACT : Message transmission processing - * FUNCTION : Send a message to the specified PNO - * ARGUMENT : pno_src : Source PNO - * : pno_dest : Destination PNO - * : cid : Command ID - * : msg_len : Message data body length - * : *msg_data : Pointer to message data - * NOTE : - * RETURN : RET_NORMAL : Normal completion - * : RET_ERRNOTRDY : Destination process is not wakeup - * : RET_ERRMSGFULL : Message queue overflows - * : RET_ERRPARAM : Buffer size error - ******************************************************************************/ -static VEHICLEDEBUG_RET_API VehicleDebugSndMsg(PNO pno_src, - PNO pno_dest, CID cid, u_int16 msg_len, const void *msg_data) { - VEHICLEDEBUG_MSG_BUF msg_buf; - RET_API ret_api; - - if (msg_data != NULL) { - /* Initialization message buffe */ - (void)memset(reinterpret_cast<void *>(&msg_buf), 0, sizeof(VEHICLEDEBUG_MSG_BUF)); - - /*--------------------------------------------------------------* - * Create a message header * - *--------------------------------------------------------------*/ - msg_buf.hdr.hdr.sndpno = pno_src; /* source PNO */ - msg_buf.hdr.hdr.cid = cid; /* Command ID */ - msg_buf.hdr.hdr.msgbodysize = msg_len; /* Data size */ - - /*--------------------------------------------------------------* - * Create a message data * - *--------------------------------------------------------------*/ - if (msg_len != 0) { - (void)memcpy(reinterpret_cast<void *>(&msg_buf.data) , msg_data, sizeof(msg_buf.data)); - } - /*--------------------------------------------------------------* - * Send messages * - *--------------------------------------------------------------*/ - ret_api = _pb_SndMsg(pno_dest, /* destination PNO */ - static_cast<u_int16>(sizeof(T_APIMSG_MSGBUF_HEADER) + msg_len),/* message size */ - reinterpret_cast<void *><&msg_buf>, /* message buffer */ - 0); /* Unused Argument */ - } else { - /* Argument error(Pointer to the data buffer) */ - ret_api = VEHICLEDEBUG_RET_ERROR_PARAM; - } - - return ret_api; -} |