diff options
Diffstat (limited to 'service/other/vehicle_parameter_library/library')
11 files changed, 2006 insertions, 0 deletions
diff --git a/service/other/vehicle_parameter_library/library/Makefile b/service/other/vehicle_parameter_library/library/Makefile new file mode 100755 index 0000000..ae99cfa --- /dev/null +++ b/service/other/vehicle_parameter_library/library/Makefile @@ -0,0 +1,40 @@ +# +# @copyright Copyright (c) 2017-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. +# + +INST_SHLIBS = libvp + +VPATH = ./src ./include/$(COMPONENT_NAME) + +INST_HEADERS = VP_GetEnv.h env_vehicle.h \ + env_vehicleparameterlibrary.h env_vehicleparameterlibrary_serial.h env_ext.h \ + VP_FuncCheck_CanRcv.h vehicle_parameter_library.h + +libvp_SRCS = VP_FuncCheck_CanRcv.c VP_GetEnv.c + +LDLIBS += -Wl,--no-as-needed +LDLIBS += -Wl,-Bdynamic -lns_backup + +CPPFLAGS += -I./include +CPPFLAGS += -Werror=implicit-function-declaration +CPPFLAGS += -Werror=format-security +CPPFLAGS += -Wconversion +CPPFLAGS += -Wpointer-to-int-cast +CPPFLAGS += -Wint-to-pointer-cast +CPPFLAGS += -Wpointer-arith +CPPFLAGS += -Wformat +CPPFLAGS += -DVP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE + +include ../../other_service.mk diff --git a/service/other/vehicle_parameter_library/library/include/VP_FuncCheck_CanRcv_private.h b/service/other/vehicle_parameter_library/library/include/VP_FuncCheck_CanRcv_private.h new file mode 100755 index 0000000..193e54a --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/VP_FuncCheck_CanRcv_private.h @@ -0,0 +1,90 @@ +/* + * @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 VP_FuncCheck_CanRcv_private.h + * @brief Get function existence API internal header file + * @attention Cannot be included from external functions + * + * Exported because it will be inconvenient at MT + */ +/* ====================================================================== */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_VP_FUNCCHECK_CANRCV_PRIVATE_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_VP_FUNCCHECK_CANRCV_PRIVATE_H_ + +/* ====================================================================== */ +/* Include public headers */ +/* ====================================================================== */ +#include <other_service/VP_FuncCheck_CanRcv.h> + +/* ====================================================================== */ +/* Internal definitions for debugging */ +/* ====================================================================== */ +#ifdef DEBUG_MT + #include <stdio.h> + + #define MT_STATIC /**< Static definitions - Remove the static in order to remove the file scope at MT. */ + + /**< Debugging output function - Compile the entity at MT */ + #define DEBUG_PRINT(msg) {printf("%s\n", (msg) ) ;} + /**< Debugging output function - Compile the entity at MT */ + #define DEBUG_PRINTF(format, msg) {printf((format), (msg) ) ;} + + /**< Static assertion */ + #define VP_DEBUG_STATIC_ASSERT(expr) do { int static_assert[ (expr)? 1:-1 ]; }while(0); +#else + /**< Static definitions. The scope shall be limited by static at the time of releasing. + * Remove the static in order to remove the file scope at MT. + */ + #define MT_STATIC static + + /**< Static definitions. The scope shall be limited by static at the time of releasing. + * Remove the static in order to remove the file scope at MT. + */ + #define DEBUG_PRINT(msg) + + /**< Static definitions. The scope shall be limited by static at the time of releasing. + * Remove the static in order to remove the file scope at MT. + */ + #define DEBUG_PRINTF(format, msg) + + /**< Static definitions. The scope shall be limited by static at the time of releasing. + * Remove the static in order to remove the file scope at MT. + */ + #define VP_DEBUG_STATIC_ASSERT(expr) +#endif + +/* ====================================================================== */ +/* General-purpose type definition - Redifined for internal use */ +/* ====================================================================== */ +/**< Internal boolean type - sys/type.h has no type definitions, so defined it here. FCCR: "F"unc"C"heck_"C"an"R"cv */ +typedef enum VP_FCCR_BOOL_Tag { + B_FALSE, /**< FALSE */ + B_TRUE /**< TRUE */ +} VP_FCCR_BOOL; + + +/* ====================================================================== */ +/* Structure */ +/* ====================================================================== */ +typedef struct TABLE_INDEX_INFO_tag { + char* code_str; /**< String that can be gotten from vehicle parameters */ + unsigned int index; /**< Index for function existence */ +} TABLE_INDEX_INFO; + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_VP_FUNCCHECK_CANRCV_PRIVATE_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/VP_FuncCheck_CanRcv.h b/service/other/vehicle_parameter_library/library/include/other_service/VP_FuncCheck_CanRcv.h new file mode 100755 index 0000000..17b4503 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/VP_FuncCheck_CanRcv.h @@ -0,0 +1,133 @@ +/* + * @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 VP_FuncCheck_CanRcv.h + * @brief \~english Get function existence API header file + */ +/* ====================================================================== */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_FUNCCHECK_CANRCV_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_FUNCCHECK_CANRCV_H_ + +#include <sys/types.h> + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ + +// typedef unsigned char u_int8; + + +/** +* @~english XM Audio +*/ +#define XM_AUDIO ((u_int8_t)1) +/** +* @~english _CWORD76_ +*/ +#define _CWORD76_ ((u_int8_t)2) + +#define VP_CANRCV__CWORD27_ ((u_int8_t)3) /**< _CWORD27_ */ +/** +* @~english WiFi HotSpot +*/ +#define WIFI_HOTSPOT ((u_int8_t)4) +/** +* @~english standard driving rregulation of AREA1 +*/ +#define AREA1_STD_TRAF_LIMIT ((u_int8_t)5) +/** +* @~english HD Data (Include traffic) +*/ +#define HD_DATA ((u_int8_t)6) +/** +* @~english WiFi 5G +*/ +#define WIFI_5G ((u_int8_t)7) + +/** +* @~english definiton of return value of API(VP_FuncCheck_CanRcv),which is used to get status of function implemention +*/ +#define FUNCTION_CHECK_RESULT_OK ((u_int8_t)0) +/** +* @~english this function is invalid +*/ +#define FUNCTION_CHECK_RESULT_NG ((u_int8_t)1) +/** +* @~english this function does not exist +*/ +#define FUNCTION_CHECK_RESULT_UNKNOWN ((u_int8_t)2) +/** +* @~english reference out of AREA1 +*/ +#define FUNCTION_CHECK_RESULT_OUT_OF_AREA1 ((u_int8_t)3) + +/* Function prototype declaration */ +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////////////// +/// \ingroup VP_FuncCheck_CanRcv +/// \~english @par Brief +/// VP_FuncCheck_CanRcv +/// \~english @param [in] FunctionName +/// function name +/// \~english @retval FUNCTION_CHECK_RESULT_OK: This function is available +/// \~english @retval FUNCTION_CHECK_RESULT_NG: This function is unavailable +/// \~english @retval FUNCTION_CHECK_RESULT_UNKNOWN: This function does not exist +/// \~english @retval FUNCTION_CHECK_RESULT_OUT_OF_AREA1: reference out of Area1 +/// \~english @par Prerequisite +/// None +/// \~english @par Change of internal state +/// None +/// \~english @par Conditions of processing failure +/// None +/// \~english @par Classification +/// Public +/// \~english @par Type +/// Sync Only +/// \~english @par Detail +/// - To get the function check result from +/// - vehicle parameter:CAN info judge +/// - vehicle parameter:country ID +/// - country ID and function judge info in API +/// - When vehicle parameter:CAN info judge +/// is [CAN_judge] or [country_ID], +/// and if country_ID is unacquainted or undefined, the API returns [available]. +/// \~english @see None +//////////////////////////////////////////////////////////////////////////////// +u_int8_t VP_FuncCheck_CanRcv(u_int8_t FunctionName); + +#ifdef __cplusplus +} +#endif + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_FUNCCHECK_CANRCV_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/VP_GetEnv.h b/service/other/vehicle_parameter_library/library/include/other_service/VP_GetEnv.h new file mode 100755 index 0000000..69f6df2 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/VP_GetEnv.h @@ -0,0 +1,114 @@ +/* + * @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 VP_GetEnv.h + * @brief \~english Get vehicle parameter environment variable API header file + */ +/* ====================================================================== */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_GETENV_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_GETENV_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ +#include <other_service/env_ext.h> + +/** +* @~english the max length of vehicle parameter environment viarable +*/ + +#define VP_MAX_LENGTH 128 + +/** +* @~english definition of parameter environment viarable such as destination +* destination diff +*/ + +#define VEHICLEPARAMETERLIBRARY_AREA "VEHICLEPARAMETERLIBRARY_AREA" + +/** +* @~english brand diff +*/ +#define VEHICLEPARAMETERLIBRARY_BRAND "VEHICLEPARAMETERLIBRARY_BRAND" + +/** +* @~english definition of _CWORD31_ vehicle parameter environment viarable +*/ +#include <other_service/env_vehicle.h> + +/** +* @~english definition of vehicle parameter environment viarable +*/ +#include <other_service/env_vehicleparameterlibrary.h> + +/** +* @~english definition of Serial vehicle parameter environment viarable +*/ +#include <other_service/env_vehicleparameterlibrary_serial.h> + +/* Function prototype declaration */ +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////////////// +/// \ingroup VP_GetEnv +/// \~english @par Brief +/// VP_GetEnv +/// \~english @param [in] pEnvStr +/// The pointer of environment variable name string +/// \~english @param [out] pEnvBuff +/// The head address of saving environment variable value +/// \~english @retval None +/// \~english @par Prerequisite +/// None +/// \~english @par Change of internal state +/// None +/// \~english @par Conditions of processing failure +/// None +/// \~english @par Classification +/// Public +/// \~english @par Type +/// Sync Only +/// \~english @par Detail +/// - To get the environment variable value by the environment variable name, +/// and save it in pEnvBuff. +/// - When environment variable name is NULL or an undefined value, +/// a blank string shall be saved in pEnvBuff. +/// \~english @see None +//////////////////////////////////////////////////////////////////////////////// +void VP_GetEnv(const char *pEnvStr, char *pEnvBuff); + +#ifdef __cplusplus +} +#endif + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_VP_GETENV_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/env_ext.h b/service/other/vehicle_parameter_library/library/include/other_service/env_ext.h new file mode 100755 index 0000000..266e510 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/env_ext.h @@ -0,0 +1,45 @@ +/* + * @copyright Copyright (c) 2019-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 env_ext.h + * @brief \~english Define of supplier vehicle parameter environment variable. + */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_EXT_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_EXT_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ + +// +// Please describe supplier-specific definitions of the vehicle parameters. +// + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_EXT_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/env_vehicle.h b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicle.h new file mode 100755 index 0000000..a0eaaf9 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicle.h @@ -0,0 +1,331 @@ +/* + * @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 env_vehicle.h + * @brief \~english Define of _CWORD31_ vehicle parameter environment variable + */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLE_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLE_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ + +/** +* @~english _CWORD31_ version +*/ +#define VP__CWORD31__VERSION "VP__CWORD31__version" +/** +* @~english _CWORD31_ class type of LAN +*/ + +#define VP__CWORD31__CLASS_TYPE_OF_LAN "VP__CWORD31__class_type_of_LAN" +/** +* @~english _CWORD31_ reverse signal +*/ + +#define VP__CWORD31__REVERSE "VP__CWORD31__reverse" +/** +* @~english _CWORD31_ PKB signal +*/ + +#define VP__CWORD31__PKB "VP__CWORD31__PKB" +/** +* @~english _CWORD31_ ADIM signal of _CWORD62_ +*/ + +#define VP__CWORD31__ADIM__CWORD62_ "VP__CWORD31__ADIM__CWORD62_" +/** +* @~english _CWORD31_ telematics function +*/ + +#define VP__CWORD31__TELEMATICS_FUNCTION "VP__CWORD31__telematics_function" +/** +* @~english _CWORD31_ opening picture +*/ + +#define VP__CWORD31__OPENING_PICTURE "VP__CWORD31__opening_picture" +/** +* @~english _CWORD31_ theme color +*/ + +#define VP__CWORD31__THEME_COLOR "VP__CWORD31__theme_color" +/** +* @~english _CWORD31_ vehicle design vehicle body +*/ +#define VP__CWORD31__VEHICLE_BODY "VP__CWORD31__vehicle_body" +/** +* @~english _CWORD31_ air conditioner on screen +*/ +#define VP__CWORD31__AC_ONSCREEN "VP__CWORD31__AC_onscreen" +/** +* @~english _CWORD31_ air conditioner screen operation +*/ +#define VP__CWORD31__AC_SCREEN_OPERATION "VP__CWORD31__AC_screen_operation" +/** +* @~english _CWORD31_ air conditioner home screen +*/ +#define VP__CWORD31__AC_SCREEN_HOME "VP__CWORD31__AC_screen_home" +/** +* @~english _CWORD31_ air conditioner switch concierge +*/ +#define VP__CWORD31__AC_SWITCH_CONCIERGE "VP__CWORD31__AC_switch_concierge" +/** +* @~english _CWORD31_ _CWORD113_ +*/ +#define VP__CWORD31___CWORD11_ "VP__CWORD31___CWORD11_" +/** +* @~english _CWORD31_ EF home screen +*/ +#define VP__CWORD31___CWORD11__HOME "VP__CWORD31___CWORD11__home" +/** +* @~english _CWORD31_ drive wheel of _CWORD113_ +*/ +#define VP__CWORD31___CWORD11__DRIVE_WHEEL "VP__CWORD31___CWORD11__drive_wheel" +/** +* @~english _CWORD31_ drive type of _CWORD113_ +*/ +#define VP__CWORD31___CWORD11__DRIVE_TYPE "VP__CWORD31___CWORD11__drive_type" +/** +* @~english _CWORD31_ battery position of _CWORD113_ +*/ +#define VP__CWORD31___CWORD11__BATTERY_POSITION "VP__CWORD31___CWORD11__battery_position" +/** +* @~english _CWORD31_ _CWORD112_ trip +*/ +#define VP__CWORD31___CWORD9__TRIP "VP__CWORD31___CWORD9__trip" +/** +* @~english _CWORD31_ FC home screen trip +*/ +#define VP__CWORD31___CWORD9__HOME_TRIP "VP__CWORD31___CWORD9__home_trip" +/** +* @~english _CWORD31_ _CWORD112_ fuel +*/ +#define VP__CWORD31___CWORD9__FUEL "VP__CWORD31___CWORD9__fuel" +/** +* @~english _CWORD31_ FC home screen fuel +*/ +#define VP__CWORD31___CWORD9__HOME_FUEL "VP__CWORD31___CWORD9__home_fuel" +/** +* @~english _CWORD31_ FC eco safety point service +*/ +#define VP__CWORD31__FC_ECO_SAFETY_POINT_SERVICE "VP__CWORD31__FC_eco_safety_point_service" +/** +* @~english _CWORD31_ FC GAS scale +*/ +#define VP__CWORD31__FC_SCALE_GAS "VP__CWORD31__FC_scale_GAS" +/** +* @~english _CWORD31_ FC HV scale +*/ +#define VP__CWORD31__FC_SCALE_HV "VP__CWORD31__FC_scale_HV" +/** +* @~english _CWORD31_ fuel consumption display function scale of fuel consumption (ForFC) +*/ +#define VP__CWORD31__FC_SCALE_FC "VP__CWORD31__FC_scale_FC" +/** +* @~english _CWORD31_ fuel consumption display function scale of fuel consumption (ForEV) +*/ +#define VP__CWORD31__FC_SCALE_EV "VP__CWORD31__FC_scale_EV" +/** +* @~english _CWORD31_ FC energy mark +*/ +#define VP__CWORD31__FC_ENERGY_MARK "VP__CWORD31__FC_energy_mark" +/** +* @~english _CWORD31_ _CWORD112_ type +*/ +#define VP__CWORD31___CWORD9__TYPE "VP__CWORD31___CWORD9__type" +/** +* @~english _CWORD31_ FC signal +*/ +#define VP__CWORD31__FC_SIGNAL "VP__CWORD31__FC_SIGNAL" +/** +* @~english _CWORD31_ display setting screen +*/ +#define VP__CWORD31__DISPLAY_SETTING_SCREEN "VP__CWORD31__display_setting_screen" +/** +* @~english _CWORD31_ clock type +*/ +#define VP__CWORD31__CLOCK_TYPE "VP__CWORD31__clock_type" +/** +* @~english _CWORD31_ start up BGM +*/ +#define VP__CWORD31__START_UP_BGM "VP__CWORD31__start_up_BGM" +/** +* @~english _CWORD31_ start up BGM type +*/ +#define VP__CWORD31__START_UP_BGM_TYPE "VP__CWORD31__start_up_BGM_type" +/** +* @~english _CWORD31_ font left DTV antenna +*/ +#define VP__CWORD31__DTV_ANTENNA_FL "VP__CWORD31__DTV_antenna_FL" +/** +* @~english _CWORD31_ font right DTV antenna +*/ +#define VP__CWORD31__DTV_ANTENNA_FR "VP__CWORD31__DTV_antenna_FR" +/** +* @~english _CWORD31_ rear left DTV antenna +*/ +#define VP__CWORD31__DTV_ANTENNA_RL "VP__CWORD31__DTV_antenna_RL" +/** +* @~english _CWORD31_ rear right DTV antenna +*/ +#define VP__CWORD31__DTV_ANTENNA_RR "VP__CWORD31__DTV_antenna_RR" +/** +* @~english _CWORD31_ DTV antenna +*/ +#define VP__CWORD31__DTV_ANTENNA "VP__CWORD31__DTV_antenna" +/** +* @~english _CWORD31_ antenna info antenna available / unavailable +*/ +#define VP__CWORD31__BEACON_ANTENNA "VP__CWORD31__beacon_antenna" +/** +* @~english _CWORD31_ HF voice quality type +*/ +#define VP__CWORD31__HF_VOICE_QUALITY_TYPE "VP__CWORD31__HF_voice_quality_type" +/** +* @~english _CWORD31_ DAB antenna +*/ +#define VP__CWORD31__DAB_ANTENNA "VP__CWORD31__DAB_antenna" +/** +* @~english _CWORD31_ DAB screen display +*/ +#define VP__CWORD31__DAB_SCREEN "VP__CWORD31__DAB_screen" +/** +* @~english _CWORD31_ hard switch beep +*/ +#define VP__CWORD31__HARD_SWITCH_BEEP "VP__CWORD31__hard_switch_beep" +/** +* @~english _CWORD31_ beep while hard SW being pressed +*/ +#define VP__CWORD31__SCREEN_SWITCH_BEEP "VP__CWORD31__screen_switch_beep" +/** +* @~english _CWORD31_ steering SW type of steering SW +*/ +#define VP__CWORD31__STEERING_SWITCH_TYPE "VP__CWORD31__steering_switch_type" +/** +* @~english _CWORD31_ TEL switch of steering +*/ +#define VP__CWORD31__STEERING_SWITCH_TEL "VP__CWORD31__steering_switch_tel" +/** +* @~english _CWORD31_ class circuit mode +*/ +#define VP__CWORD31__CLASS_CIRCUIT_MODE "VP__CWORD31__class_circuit_mode" +/** +* @~english _CWORD31_ panel microcomputer +*/ +#define VP__CWORD31__PANEL_MICROCOMPUTER "VP__CWORD31__panel_microcomputer" +/** +* @~english _CWORD31_ class watch at brake hold +*/ +#define VP__CWORD31__CLASS_WATCH_AT_BRAKE_HOLD "VP__CWORD31__class_watch_at_brake_hold" +/** +* @~english _CWORD31_ GPS antenna +*/ +#define VP__CWORD31__GPS_ANTENNA "VP__CWORD31__GPS_antenna" +/** +* @~english _CWORD31_ ILL- available / unavailable +*/ +#define VP__CWORD31__ILL_SIGNAL "VP__CWORD31__ILL_signal" +/** +* @~english _CWORD31_ switch trigger +*/ +#define VP__CWORD31__SWITCH_TRIGGER "VP__CWORD31__switch_trigger" +/** +* @~english _CWORD31_ sensitivity level +*/ +#define VP__CWORD31__SENSITIVITY_LEVEL "VP__CWORD31__sensitivity_level" +/** +* @~english _CWORD31_ hadsfree bluetooth device name / WiFi AP name selection +*/ +#define VP__CWORD31__BT_DEVICE_AP_NAME "VP__CWORD31__BT_device_AP_name" +/** +* @~english _CWORD31_ Eco drive max vol setting in D4 model +*/ +#define VP__CWORD31__ECO_RUN_D4_VOL_MAX "VP__CWORD31__eco_run_D4_VOL_max" +/** +* @~english _CWORD31_ thumbnail type +*/ +#define VP__CWORD31__THUMBNAIL_TYPE "VP__CWORD31__thumbnail_type" +/** +* @~english _CWORD31_ EOM function +*/ +#define VP__CWORD31__EOM_FUNCTION "VP__CWORD31__EOM_function" +/** +* @~english _CWORD31_ Microphone Type +*/ +#define VP__CWORD31__MICROPHONE_TYPE "VP__CWORD31__Microphone_Type" +/** +* @~english _CWORD31_ Microphone Location +*/ +#define VP__CWORD31__MICROPHONE_LOCATION "VP__CWORD31__Microphone_Location" +/** +* @~english _CWORD31_ VR microphone parameter vehicle noize level +*/ +#define VP__CWORD31__VEHICLE_NOIZE_LEVEL "VP__CWORD31__vehicle_noize_level" + +/** +* @~english _CWORD31_ wide band FM +*/ +#define VP__CWORD31__WIDE_BAND_FM "VP__CWORD31__Wide_band_FM" +/** +* @~english _CWORD31_ map color +*/ +#define VP__CWORD31__MAP_COLOR "VP__CWORD31__map_color" +/** +* @~english _CWORD31_ cloud eco +*/ +#define VP__CWORD31__CLOUD_ECO "VP__CWORD31__cloud_eco" +/** +* @~english _CWORD31_ eg type +*/ +#define VP__CWORD31__EG_TYPE "VP__CWORD31__EG_type" + +/** +* @~english _CWORD31_ display type +*/ +#define VP__CWORD31__DISPLAY_TYPE "VP__CWORD31__display_type" +/** +* @~english _CWORD31_ clock display +*/ +#define VP__CWORD31__CLOCK_DISPLAY "VP__CWORD31__clock_display" +/** +* @~english _CWORD31_ destination +*/ +#define VP__CWORD31__DESTINATION "VP__CWORD31__destination" +/** +* @~english _CWORD31_ class operation +*/ +#define VP__CWORD31__CLASS_OPERATION "VP__CWORD31__class_operation" +/** +* @~english _CWORD31_ DES function +*/ +#define VP__CWORD31__DES_FUNCTION "VP__CWORD31__DES_function" + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLE_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary.h b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary.h new file mode 100755 index 0000000..1c0020c --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary.h @@ -0,0 +1,138 @@ +/* + * @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 env_vehicleparameterlibrary.h + * @brief \~english Define of vehicle parameter environment variable + */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ + +/** +* @~english version +*/ +#define VP_VEHICLEPARAMETERLIBRARY_VERSION "VP_VEHICLEPARAMETERLIBRARY_version" +/** +* @~english maker ID +*/ +#define VP_VEHICLEPARAMETERLIBRARY_MAKER_ID "VP_VEHICLEPARAMETERLIBRARY_maker_ID" +/** +* @~english area +*/ +#define VP_VEHICLEPARAMETERLIBRARY_AREA "VP_VEHICLEPARAMETERLIBRARY_area" +/** +* @~english grade +*/ +#define VP_VEHICLEPARAMETERLIBRARY_GRADE "VP_VEHICLEPARAMETERLIBRARY_grade" +/** +* @~english destination country code +*/ +#define VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE "VP_VEHICLEPARAMETERLIBRARY_dest_c_code" +/** +* @~english DAB tuner number +*/ +#define VP_VEHICLEPARAMETERLIBRARY_DAB_TUNER_NUM "VP_VEHICLEPARAMETERLIBRARY_DAB_tuner_num" +/** +* @~english AM radio +*/ +#define VP_VEHICLEPARAMETERLIBRARY_AM_RADIO "VP_VEHICLEPARAMETERLIBRARY_AM_Radio" +/** +* @~english amp type +*/ +#define VP_VEHICLEPARAMETERLIBRARY_AMP_TYPE "VP_VEHICLEPARAMETERLIBRARY_AMP_type" +/** +* @~english display +*/ +#define VP_VEHICLEPARAMETERLIBRARY_DISPLAY "VP_VEHICLEPARAMETERLIBRARY_DISPLAY" +/** +* @~english touch panel +*/ +#define VP_VEHICLEPARAMETERLIBRARY_TOUCHPANEL "VP_VEHICLEPARAMETERLIBRARY_TOUCHPANEL" +/** +* @~english DECK +*/ +#define VP_VEHICLEPARAMETERLIBRARY_DECK "VP_VEHICLEPARAMETERLIBRARY_DECK" +/** +* @~english JP traffic information show +*/ +#define VP_VEHICLEPARAMETERLIBRARY_JPTRAFFICINFO_SHOW "VP_VEHICLEPARAMETERLIBRARY_JPTrafficInfo_show" +/** +* @~english connection server +*/ +#define VP_VEHICLEPARAMETERLIBRARY_CONNECTION_SERVER "VP_VEHICLEPARAMETERLIBRARY_CONNECTION_SERVER" +/** +* @~english _CWORD40_ generation +*/ +#define VP_VEHICLEPARAMETERLIBRARY__CWORD40_ "VP_VEHICLEPARAMETERLIBRARY__CWORD40_" + +/** +* @~english Radio reception level +*/ +#define VP_VEHICLEPARAMETERLIBRARY_RADIO_LV_DIAG "VP_VEHICLEPARAMETERLIBRARY_RADIO_LV_DIAG" + +/** +* @~english Navigation model +*/ +#define VP_VEHICLEPARAMETERLIBRARY_NAVI "VP_VEHICLEPARAMETERLIBRARY_NAVI" + +/** +* @~english Map update service +*/ +#define VP_VEHICLEPARAMETERLIBRARY_MAP_UPDATE "VP_VEHICLEPARAMETERLIBRARY_MAP_UPDATE" + +/** +* @~english Headunit identification +*/ +#define VP_HEAD_UNIT_ID "VP_HEAD_UNIT_ID" + +/** +* @~english Serius raido +*/ +#define VP_VEHICLEPARAMETERLIBRARY_SDARS "VP_VEHICLEPARAMETERLIBRARY_SDARS" + +/** +* @~english optional amp +*/ +#define VP_VEHICLEPARAMETERLIBRARY_ACCESSORY_AMP "VP_VEHICLEPARAMETERLIBRARY_ACCESSORY_AMP" + +/** +* @~english Key trace +*/ +#define VP_VEHICLEPARAMETERLIBRARY_KEY_TRACE "VP_VEHICLEPARAMETERLIBRARY_KEY_TRACE" + +/** +* @~english diatal TV +*/ +#define VP_VEHICLEPARAMETERLIBRARY_DTV "VP_VEHICLEPARAMETERLIBRARY_DTV" + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary_serial.h b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary_serial.h new file mode 100755 index 0000000..04ae10e --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/env_vehicleparameterlibrary_serial.h @@ -0,0 +1,46 @@ +/* + * @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 env_vehicleparameterlibrary_serial.h + * @brief \~english Define of Serial vehicle parameter environment variable + */ + +#ifndef VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_SERIAL_H_ +#define VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_SERIAL_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ + +/** + * \~english Enviroment variable _CWORD49__ID + */ +#define VP_VEHICLEPARAMETERLIBRARY_SER__CWORD49__ID "VP_VEHICLEPARAMETERLIBRARY_SER__CWORD49__ID" + +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // VEHICLE_PARAMETER_LIBRARY_LIBRARY_INCLUDE_OTHER_SERVICE_ENV_VEHICLEPARAMETERLIBRARY_SERIAL_H_ diff --git a/service/other/vehicle_parameter_library/library/include/other_service/vehicle_parameter_library.h b/service/other/vehicle_parameter_library/library/include/other_service/vehicle_parameter_library.h new file mode 100755 index 0000000..151bae5 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/include/other_service/vehicle_parameter_library.h @@ -0,0 +1,46 @@ +/* + * @copyright Copyright (c) 2017-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 vehicle_parameter_library.h + * @brief \~english include all vehicle_parameter_library head files + */ + +#ifndef OTHERSERVICE_VEHICLEPARAMETERLIBRARY_H_ // NOLINT(build/header_guard) +#define OTHERSERVICE_VEHICLEPARAMETERLIBRARY_H_ // NOLINT(build/header_guard) + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup other_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup vehicle_parameter_library + * @ingroup other_service + * @{ + */ +#include <other_service/VP_FuncCheck_CanRcv.h> +#include <other_service/VP_GetEnv.h> +#include <other_service/env_vehicleparameterlibrary.h> +#include <other_service/env_vehicleparameterlibrary_serial.h> +#include <other_service/env_vehicle.h> +#include <other_service/env_ext.h> +/** @}*/ // end of vehicle_parameter_library +/** @}*/ // end of other_service +/** @}*/ // end of BaseSystem + +#endif // OTHERSERVICE_VEHICLEPARAMETERLIBRARY_H_ diff --git a/service/other/vehicle_parameter_library/library/src/VP_FuncCheck_CanRcv.c b/service/other/vehicle_parameter_library/library/src/VP_FuncCheck_CanRcv.c new file mode 100755 index 0000000..938ea7f --- /dev/null +++ b/service/other/vehicle_parameter_library/library/src/VP_FuncCheck_CanRcv.c @@ -0,0 +1,732 @@ +/* + * @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 VP_FuncCheck_CanRcv.c + * @brief Get function existence API + */ + + +/* ====================================================================== */ +/* Header */ +/* ====================================================================== */ +#include <assert.h> +#include <string.h> +#include <regex.h> + +#include <other_service/VP_GetEnv.h> +#include "VP_FuncCheck_CanRcv_private.h" + +/* ====================================================================== */ +/* Enumeration types */ +/* ====================================================================== */ +typedef enum VPFuncTableDestIndexTag{ + /* + * Note. + * This feature needs to be defined by the vendor. + */ + VP_FUNC_TABLE_DEST_INDEX_A , + VP_FUNC_TABLE_DEST_INDEX_B , + + VP_FUNC_TABLE_DEST_INDEX_MAX /**< Number of choices (index maximum value: 1) */ +} VP_FUNC_TABLE_DEST_INDEX; + +typedef enum VPFuncTableBrandTag{ + /* + * Note. + * This feature needs to be defined by the vendor. + */ + VP_FUNC_TABLE_BRAND_A, + VP_FUNC_TABLE_BRAND_B, + + VP_FUNC_TABLE_BRAND_INDEX_MAX /**< Number of choices (index maximum value: 1) */ +} VP_FUNC_TABLE_BRAND; + +typedef enum VPFuncTableGradeLTag{ + /* + * Note. + * This feature needs to be defined by the vendor. + */ + VP_FUNC_TABLE_GRADE_A1, + VP_FUNC_TABLE_GRADE_A2, + + VP_FUNC_TABLE_GRADE_A_INDEX_MAX /**< Number of choices (index maximum value: 1) */ +} VP_FUNC_TABLE_GRADE_A; + +typedef enum VPFuncTableGradeTTag{ + /* + * Note. + * This feature needs to be defined by the vendor. + */ + VP_FUNC_TABLE_GRADE_B1, + VP_FUNC_TABLE_GRADE_B2, + + VP_FUNC_TABLE_GRADE_B_INDEX_MAX /**< Number of choices (index maximum value: 1) */ +} VP_FUNC_TABLE_GRADE_B; + +typedef enum VPFuncTableFuncTypeIndexTag{ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN , /**< Unknown function */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO , /**< XM Audio */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ , /**< _CWORD27_ */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT , /**< Wifi Hotspot */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION , /**< Travel Restriction */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA , /**< HD Data */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G , /**< Wifi 5G */ + + VP_FUNC_TABLE_FUNC_TYPE_INDEX_MAX /**< Number of choices (index maximum value: 1) */ +} VP_FUNC_TABLE_FUNC_TYPE; + +/** Processing definitions for CAN information availability */ +typedef enum CANFuncCheckSwitchTag{ + CAN_FUNC_CHEK_AVAILABLE , + CAN_FUNC_CHEK_UNAVAILABLE , + CAN_FUNC_CHEK_COUNTRY_CODE +} CAN_FUNC_CHEK_SWITCH; + + + +/**< Definition of number of functions (required for initial definition of function availability table) */ + +#define VP_FUNC_TABLE_FUNCTION_INDEX_MAX ((unsigned int)7) + +/* ====================================================================== */ +/* Macro definitions */ +/* ====================================================================== */ +/* Definition for return value from string functions */ +#define RET_STD_LIB_STRING_STR_CMP_OK ((int)0) /**< The return value of the strncmp. this value is returned when matched. */ + +/* Default index values */ +#define DEFAULT_TABLE_INDEX_DEST (VP_FUNC_TABLE_DEST_INDEX_A) /* Initial value changed by the specification which returns the setting of the belonging property when the undefined country code is gotten. */ +#define DEFAULT_TABLE_INDEX_BRAND (VP_FUNC_TABLE_BRAND_A) +#define DEFAULT_TABLE_INDEX_GRADE_A (VP_FUNC_TABLE_GRADE_A1) +#define DEFAULT_TABLE_INDEX_GRADE_B (VP_FUNC_TABLE_GRADE_B1) +#define DEFAULT_CAN_JUDGE_STATUS (CAN_FUNC_CHEK_COUNTRY_CODE) + +/* ====================================================================== */ +/* Constant definitions */ +/* ====================================================================== */ + +/* ====================================================================== */ +/* Structures */ +/* ====================================================================== */ + +/* ====================================================================== */ +/* Internal function prototype declarations */ +/* ====================================================================== */ +#ifdef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE +MT_STATIC u_int8_t getResult_CanJudge( unsigned int idx_func ); +MT_STATIC unsigned int getIndexOfFunc( u_int8_t func ); +MT_STATIC unsigned int getIndexOfTable( const char vp_param_str[] , const TABLE_INDEX_INFO table_index_info[] , unsigned int info_size, unsigned int default_index ); +MT_STATIC VP_FCCR_BOOL hasMultipleCoutnry( const char dest_str[] , const char multiple_country_code_desig[] ); +#endif +/* ====================================================================== */ +/* Public function definitions */ +/* ====================================================================== */ +/** + * @fn + * u_int8_t VP_FuncCheck_CanRcv( u_int8_t FunctionName ) + * @brief Get function existence API(Public) + * @param[in] (FunctionName) Function Name (Number) + * @return FUNCTION_CHECK_RESULT_OK :This function is available + * FUNCTION_CHECK_RESULT_NG :This function is unavailable + * FUNCTION_CHECK_RESULT_UNKNOWN :This function does not exist + * @details Read the function name as feature name specified in the argument, then return one of the + * "This function is available"/"This function is unavailable"/"This function does not exist" + * of the feature as the following check-result: + * - vehicle parameter:CAN information availability(destination package) judge + * - vehicle parameter:country code + * - Whether or not supported the features corresponding to the country code in this API + * + * When CAN information availability (destination package) in vehicle parameters is + * "Control ON/OFF according to CAN information" or "Country code", return "This function is available" + * if this function is called when the country code from CAN is unacquired or undetermined country code. + */ +/* ====================================================================== */ +u_int8_t VP_FuncCheck_CanRcv( u_int8_t FunctionName ) +{ +#ifndef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE + u_int8_t result; + + switch(FunctionName) { + case XM_AUDIO: + result = FUNCTION_CHECK_RESULT_NG; + break; + + case VP_CANRCV__CWORD27_: + case WIFI_HOTSPOT: + case AREA1_STD_TRAF_LIMIT: + case HD_DATA: + case WIFI_5G: + result = FUNCTION_CHECK_RESULT_OK; + break; + default: + result = FUNCTION_CHECK_RESULT_UNKNOWN; + break; + } + + return result; +#else + + /* ====================================================================== */ + /* Internal table definition */ + /* ====================================================================== */ + /** Vehicle Parameter "CAN information Support/Not Support"- processing selector translation table */ + const TABLE_INDEX_INFO TABLE_STATUS_INFO_CAN_JUDGE[] = + { + { "available" , CAN_FUNC_CHEK_AVAILABLE }, // Yes + { "unavailable" , CAN_FUNC_CHEK_UNAVAILABLE }, // None + { "CAN_judge" , CAN_FUNC_CHEK_COUNTRY_CODE }, // Control ON/OFF according to CAN information + { "country_ID" , CAN_FUNC_CHEK_COUNTRY_CODE } // Country code + }; + + /* ====================================================================== */ + /* Table Size Definition */ + /* ====================================================================== */ + const unsigned int LENGTHOF_TABLE_INDEX_INFO_CAN_JUDGE = ( sizeof(TABLE_STATUS_INFO_CAN_JUDGE ) / sizeof( TABLE_INDEX_INFO ) ); + + /* ====================================================================== */ + /* Internal variable declarations */ + /* ====================================================================== */ + u_int8_t result = FUNCTION_CHECK_RESULT_UNKNOWN; + + unsigned int idx_func = 0; + + unsigned int can_judge_status = CAN_FUNC_CHEK_COUNTRY_CODE; + char VP_canjudge[ VP_MAX_LENGTH ]; + char VP_area[ VP_MAX_LENGTH ]; + + /* ====================================================================== */ + /* Process */ + /* ====================================================================== */ + /* Get vehicle parameter */ + VP_GetEnv( VEHICLEPARAMETERLIBRARY_AREA , &(VP_area[0]) ); + + DEBUG_PRINTF( "AREA = %s; " , VP_area ) + + /* Get feature name index */ + idx_func = getIndexOfFunc( FunctionName ); + + DEBUG_PRINTF( "Function = %d; " , FunctionName ) + DEBUG_PRINTF( "idx_func = %d\n" , idx_func ) + + /* Judge as other than area1 because it is not a area1 */ + if ( strncmp( VP_area, "AREA1", VP_MAX_LENGTH ) != RET_STD_LIB_STRING_STR_CMP_OK ) + { + result = FUNCTION_CHECK_RESULT_OUT_OF_AREA1; + } + else + { + /* If the feature is unknown, it is judged to be unknown before checking CAN information. */ + if ( VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN == idx_func ) + { + result = FUNCTION_CHECK_RESULT_UNKNOWN; + } + else + { + /* Get vehicle parameter */ /* It is unnecessary to get the parameter every time, but because there is no process to check the change, it is gotten every time as a precaution. */ + VP_GetEnv( VP__CWORD31__TELEMATICS_FUNCTION , &(VP_canjudge[0]) ); + + /* Choose processing according to CAN information Support/Not Support. */ + can_judge_status = getIndexOfTable( + &(VP_canjudge[0]), + &(TABLE_STATUS_INFO_CAN_JUDGE[0]), + LENGTHOF_TABLE_INDEX_INFO_CAN_JUDGE, + DEFAULT_CAN_JUDGE_STATUS + ); + + DEBUG_PRINTF( "VP_canjudge = %s; ", VP_canjudge ) + + /* When judging from CAN information or country code */ + if ( CAN_FUNC_CHEK_COUNTRY_CODE == can_judge_status ) + { + DEBUG_PRINT( "CAN judge : C_CODE or CAN_JUDGE" ) + result = getResult_CanJudge( idx_func ); + } + else + { + /* For available/unavailable */ + /* Standard travel restriction of AREA1 */ + if ( AREA1_STD_TRAF_LIMIT == idx_func ) + { + result = FUNCTION_CHECK_RESULT_OK; + } + else + { + switch( can_judge_status ) + { + case CAN_FUNC_CHEK_UNAVAILABLE: + DEBUG_PRINT( "CAN judge : UNAVAILABLE" ) + result = FUNCTION_CHECK_RESULT_NG; + break; + + case CAN_FUNC_CHEK_AVAILABLE: + default: /* If the default value of canjudge_status are set correctly, the default cannot be selected */ + DEBUG_PRINT( "CAN judge : AVAILABLE" ) + result = FUNCTION_CHECK_RESULT_OK; + break; + } + } + } + } + } + DEBUG_PRINTF( "RESULT = %d\n", result ) + + return result; + +#endif +} + +/* ====================================================================== */ +/* Internal function definitions */ +/* ====================================================================== */ +#ifdef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE +/* ====================================================================== */ +/** + * @brief Get function existence in consideration of country code + * @detials Internal-use functions - Processing when CAN information availability is "Country Code" + * @param[in] idx_func Table index corresponding to the feature (takes as its argument the value after conversion to a table index, not the feature name) + * @return Availability of the feature in current vehicle parameters + */ +/* ====================================================================== */ +MT_STATIC u_int8_t getResult_CanJudge( unsigned int idx_func ) +{ + /* ====================================================================== */ + /* Internal constant definition */ + /* ====================================================================== */ + static const char MULTIPLE_COUNTRY_CODE_DESIG[] = "^[0-9]{3}(;[0-9]{3})+;{0,1}"; /**< Regular Expression String for Multiple Countries (Attributes). Make sure at least two country codes are stored / delimited */ + + /* ====================================================================== */ + /* Internal table definitions */ + /* ====================================================================== */ + /** Feature table index conversion table (country code) */ + const TABLE_INDEX_INFO TABLE_INDEX_INFO_DESTINATION[] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + { "101" , VP_FUNC_TABLE_DEST_INDEX_A }, // Detination A + { "102" , VP_FUNC_TABLE_DEST_INDEX_B } // Detination B + }; + + /** @todo The consideration. For the feature table by country code, if it can be summarized the GRADE A1/GRADE A2 and GRADE B1/GRADE B2, + It can be also summarized the translation table. + However, it must be able to guarantee that there are no differences in the table format in L/T. */ + /** Index Ttranslation Table for feature availability table (for grade A) */ + const TABLE_INDEX_INFO TABLE_INDEX_INFO_GRADE_A[] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + { "A1" , VP_FUNC_TABLE_GRADE_A1 }, // GRADE A1 + { "A2" , VP_FUNC_TABLE_GRADE_A2 } // GRADE A2 + }; + + /** Index Translation Table for feature availability table (for grade B) */ + const TABLE_INDEX_INFO TABLE_INDEX_INFO_GRADE_B[] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + { "B1" , VP_FUNC_TABLE_GRADE_B1 }, // GRADE B1 + { "B2" , VP_FUNC_TABLE_GRADE_B2 }, // GRADE B2 + }; + + /** Index Translation Table for feature availability table (brand) */ + const TABLE_INDEX_INFO TABLE_INDEX_INFO_BRAND[] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + { "A" , VP_FUNC_TABLE_BRAND_A }, // BRAND A + { "B" , VP_FUNC_TABLE_BRAND_B } // BRAND B + }; + + /* ====================================================================== */ + /** + * @brief Feature availability table for BRAND A + * @details Array of type u_int8_t accessed by the following index + */ + /* ====================================================================== */ + const u_int8_t VP_FUNC_CHECK_CANRCV_TABLE_A[ VP_FUNC_TABLE_DEST_INDEX_MAX ] + [ VP_FUNC_TABLE_GRADE_A_INDEX_MAX ] + [ VP_FUNC_TABLE_FUNCTION_INDEX_MAX ] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + /* Destination A */ + { + // Unknown , XM Audio , _CWORD27_ , Wifi HotSpot , Travel Restriction , HD Data Wifi 5G + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK }, // GRADE A1 + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK } // GRADE A2 + }, + + /* Destination B */ + { + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK }, // GRADE A1 + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_NG } // GRADE A2 + } + }; + + /* ====================================================================== */ + /** + * @brief Feature availability table for BRAND B + */ + /* ====================================================================== */ + const u_int8_t VP_FUNC_CHECK_CANRCV_TABLE_B[ VP_FUNC_TABLE_DEST_INDEX_MAX ] + [ VP_FUNC_TABLE_GRADE_B_INDEX_MAX ] + [ VP_FUNC_TABLE_FUNCTION_INDEX_MAX ] = + { + /* + * Note. + * This feature needs to be defined by the vendor. + */ + /* Destination A */ + { + // Unknown , XM Audio , _CWORD27_ , Wifi HotSpot , Travel Restriction , HD Data , Wifi 5G + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK }, // GRADE B1 + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK }, // GRADE B2 + }, + + /* Detination B */ + { + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK }, // GRADE B1 + { FUNCTION_CHECK_RESULT_UNKNOWN, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_OK, FUNCTION_CHECK_RESULT_NG, FUNCTION_CHECK_RESULT_NG }, // GRADE B2 + } + }; + + /* ====================================================================== */ + /* Table Size Definitions */ + /* ====================================================================== */ + const unsigned int SIZE_TABLE_INDEX_INFO_BRAND = ( sizeof(TABLE_INDEX_INFO_BRAND ) / sizeof( TABLE_INDEX_INFO ) ); + const unsigned int SIZE_TABLE_INDEX_INFO_GRADE_A = ( sizeof(TABLE_INDEX_INFO_GRADE_A ) / sizeof( TABLE_INDEX_INFO ) ); + const unsigned int SIZE_TABLE_INDEX_INFO_GRADE_B = ( sizeof(TABLE_INDEX_INFO_GRADE_B ) / sizeof( TABLE_INDEX_INFO ) ); + const unsigned int SIZE_TABLE_INDEX_INFO_DESTINATION = ( sizeof(TABLE_INDEX_INFO_DESTINATION) / sizeof( TABLE_INDEX_INFO ) ); + + /* ====================================================================== */ + /* Variable declarations */ + /* ====================================================================== */ + u_int8_t result = FUNCTION_CHECK_RESULT_UNKNOWN; + + VP_FCCR_BOOL isMultipleCountry = B_FALSE; + + unsigned int idx_dest = 0; + unsigned int idx_brand = 0; + unsigned int idx_grade = 0; + + char VP_destination[ VP_MAX_LENGTH ]; + char VP_brand[ VP_MAX_LENGTH ]; + char VP_grade[ VP_MAX_LENGTH ]; + + /* ====================================================================== */ + /* Static assertion */ + /* ====================================================================== */ + /* The following are expected to be identical */ + VP_DEBUG_STATIC_ASSERT( SIZE_TABLE_INDEX_INFO_BRAND == VP_FUNC_TABLE_BRAND_INDEX_MAX ) + VP_DEBUG_STATIC_ASSERT( SIZE_TABLE_INDEX_INFO_GRADE_A == VP_FUNC_TABLE_GRADE_A_INDEX_MAX ) + + /* Country code does not match because there are multiple countries. */ + VP_DEBUG_STATIC_ASSERT( VP_FUNC_TABLE_DEST_INDEX_MAX > SIZE_TABLE_INDEX_INFO_DESTINATION ) + + /* ====================================================================== */ + /* Process */ + /* ====================================================================== */ + + /* Argument check */ + if ( VP_FUNC_TABLE_FUNC_TYPE_INDEX_MAX <= idx_func ) + { + DEBUG_PRINTF( "ERROR : tebale index overed idx_func = %d\n", idx_func ) + + // Return unknown if the table size is exceeded. (However, this function can be called only from the API at the moment.) + result = FUNCTION_CHECK_RESULT_UNKNOWN; + } + else + { + + /* Get vehicle parameter */ + VP_GetEnv( VP__CWORD31__DESTINATION, &(VP_destination[0]) ); + VP_GetEnv( VEHICLEPARAMETERLIBRARY_BRAND , &(VP_brand[0]) ); + VP_GetEnv( VP_VEHICLEPARAMETERLIBRARY_GRADE , &(VP_grade[0]) ); + + DEBUG_PRINTF( "VP_destination = %s\n", VP_destination ) + + /* Append NULL at the end just in case. (so as not to cause any problems using the strlen or regcomp later) */ + VP_destination[ VP_MAX_LENGTH - 1 ] = '\0'; + VP_brand[ VP_MAX_LENGTH - 1 ] = '\0'; + VP_grade[ VP_MAX_LENGTH - 1 ] = '\0'; + + /* Check if the country code is NULL */ + if ( VP_destination[0] == '\0' ) + { + /* If NULL, set the index for the country code of the US. */ + idx_dest = VP_FUNC_TABLE_DEST_INDEX_A; + DEBUG_PRINTF( "[debug]idx_dest = %d\n", idx_dest ) + } + else + { + /* Check whether it is a member (multiple countries) */ + isMultipleCountry = hasMultipleCoutnry( &(VP_destination[0]), &(MULTIPLE_COUNTRY_CODE_DESIG[0]) ); + + /* Get the index for a country code */ + if ( B_TRUE == isMultipleCountry ) + { + /* If it is dependent (multiple countries), set the index for the country code of the dependent */ + DEBUG_PRINT( "isMultipleCountry = TRUE" ) + + idx_dest = VP_FUNC_TABLE_DEST_INDEX_B; + } + else + { + /* If it is not dependent (multiple countries), it searches the translation table and sets the index. */ + DEBUG_PRINT( "isMultipleCountry = FALSE" ) + + idx_dest = getIndexOfTable( &(VP_destination[0]), &(TABLE_INDEX_INFO_DESTINATION[0]), SIZE_TABLE_INDEX_INFO_DESTINATION, DEFAULT_TABLE_INDEX_DEST ); + } + } + DEBUG_PRINTF( "idx_dest = %d\n", idx_dest ) + + /* Get brand index */ + idx_brand = getIndexOfTable( &(VP_brand[0]) , &(TABLE_INDEX_INFO_BRAND[0]) , SIZE_TABLE_INDEX_INFO_BRAND , DEFAULT_TABLE_INDEX_BRAND ); + + /* + * Get grade index + * Setting Defaults for each brand + * e.g. The default is A, so if it is not B, it is determined to be A. + */ + if ( VP_FUNC_TABLE_BRAND_B == idx_brand ) + { + DEBUG_PRINT( "idx_brand = B") + + idx_grade = getIndexOfTable( &(VP_grade[0]) , &(TABLE_INDEX_INFO_GRADE_B[0]) , SIZE_TABLE_INDEX_INFO_GRADE_B , DEFAULT_TABLE_INDEX_GRADE_B ); + + /* Table access */ + result = VP_FUNC_CHECK_CANRCV_TABLE_B[idx_dest][idx_grade][idx_func]; + + } + else + { + DEBUG_PRINT( "idx_brand = A") + + idx_grade = getIndexOfTable( &(VP_grade[0]) , &(TABLE_INDEX_INFO_GRADE_A[0]) , SIZE_TABLE_INDEX_INFO_GRADE_A , DEFAULT_TABLE_INDEX_GRADE_A ); + + /* Table access */ + result = VP_FUNC_CHECK_CANRCV_TABLE_A[idx_dest][idx_grade][idx_func]; + + } + + //DEBUG_PRINTF( "RESULT = %d\n", result ) + } + + return result; +} + + +/* ====================================================================== */ +/** + * @brief Feature-Table Index Translation Function + * @detials Internal-use functions. It is translate the feature definition number to an index for the table. + * @param[in] Feature name defined by the func define + * @return The table index corresponding to the feature. If the given country code is invalid, return the index given by default_idx + */ + /* ====================================================================== */ +MT_STATIC unsigned int getIndexOfFunc( u_int8_t func ) +{ + /* ====================================================================== */ + /* Internal table definitions */ + /* ====================================================================== */ + /** Index translation table for feature table (Features) */ + const VP_FUNC_TABLE_FUNC_TYPE GET_INDEX_OF_FUNC[] = { + VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN , //#define VP_FUNCCHECK_CANRCV_UNKNOWN ((u_int8_t)0) /* Unknown Features */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO , //#define XM_AUDIO ((u_int8_t)1) /* XM Audio */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ , //#define _CWORD27_ ((u_int8_t)3) /* _CWORD27_ */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT , //#define WIFI_HOTSPOT ((u_int8_t)4) /* WiFi HotSpot */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION , //#define AREA1_STD_TRAF_LIMIT ((u_int8_t)5) /* Standard Travel Restriction of AREA1 */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA , //#define HD_DATA ((u_int8_t)6) /* HD Data (Include traffic) */ + VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G //#define WIFI_5G ((u_int8_t)7) /* WiFi 5G */ + + }; + + + /* ====================================================================== */ + /* Variable declarations */ + /* ====================================================================== */ + const unsigned int index_table_size = sizeof( GET_INDEX_OF_FUNC ) / sizeof( VP_FUNC_TABLE_FUNC_TYPE ); + + u_int8_t table_index = VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN; + + /* ====================================================================== */ + /* Static assertions */ + /* ====================================================================== */ + /* In the current configuration, the feature's defined value and index match, so the translation table size should also match (remove this assertion if there is no match) */ + VP_DEBUG_STATIC_ASSERT( index_table_size == VP_FUNC_TABLE_FUNCTION_INDEX_MAX ) + + /* Translation tables or the enumeration pair (VP_FUNC_TABLE_FUNC_TYPE) must also be modified when the definition value changes. + It may also be changed, added, or deleted following asserts as appropriate according to the defined value. */ + VP_DEBUG_STATIC_ASSERT( XM_AUDIO == VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO ) + + VP_DEBUG_STATIC_ASSERT( VP_CANRCV__CWORD27_ == VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ ) + VP_DEBUG_STATIC_ASSERT( WIFI_HOTSPOT == VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT ) + VP_DEBUG_STATIC_ASSERT( AREA1_STD_TRAF_LIMIT == VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION ) + VP_DEBUG_STATIC_ASSERT( HD_DATA == VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA ) + VP_DEBUG_STATIC_ASSERT( WIFI_5G == VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G ) + + + /* ====================================================================== */ + /* Process */ + /* ====================================================================== */ + + /* Argument check: Treat as unknown feature if it is larger than index translation table */ + if ( index_table_size <= func ) + { + table_index = VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN; + } + else + { + table_index = (u_int8_t)(GET_INDEX_OF_FUNC[func]); + } + + return table_index; + +} + +/* ====================================================================== */ +/** + * @brief Vehicle parameter string to integer conversion function + * @detials Internal-use function. Convert the given string (vehicle parameter) into an index for the table. + * The value gotten using VP_GetEnv() is assumed. Thus, the maximum length is VP_MAX_LENGTH. + * Return the value set in default_index if the conversion is failed. + * @param[in] vp_param_str String as source of convetion to the table index + * @param[in] table_index_info String corresponding to table index and an array of structs with table indexes set + * @param[in] info_size Size of the table_index_info array + * @param[in] default_index Default index. Return this value if none of table_index_info matches + * @return The table index corresponding to the vehicle parameter string given by the argument. Return the value given by the default_index argument if the given country code is invalid. + */ + /* ====================================================================== */ +MT_STATIC unsigned int getIndexOfTable( const char vp_param_str[], const TABLE_INDEX_INFO table_index_info[], unsigned int info_size, unsigned int default_index ) +{ + unsigned int table_index = 0; + + table_index = default_index; /* Set as initial value so that it can return the set default if it is unknown */ + + //DEBUG_PRINTF("info_size = %d\n", info_size) + + /* NULL checking */ + if ( NULL != vp_param_str ) + { + if ( NULL != table_index_info ) + { + unsigned int i = 0; + + for ( i = 0; i < info_size; i++ ) + { + if ( RET_STD_LIB_STRING_STR_CMP_OK == strncmp( &(vp_param_str[0]), &((table_index_info[i]).code_str[0]), VP_MAX_LENGTH ) ) + { + table_index = (table_index_info[i]).index; + + break; + } + } + } + else + { + DEBUG_PRINT( "ERROR!! the Bad Teble overd." ) + } + } + + return table_index; +} + +/* ====================================================================== */ +/** + * @brief Function to check whether country code is multiple countries or not + * @detials Internal-use functions. Check if the country code given in the argument contains more than one country. + * The determination whether multiple country code or not shall be true if it exactly matches the specified + * regular expression which is a characteristic of multiple countries. + * The exact match determination shall be the exact match if the length of the matched character matches + * the length of the character passed in the argument. + * @param[in] dest_str Country code string. The value gotten using VP_GetEnv() is assumed. Therefore, the maximum length is VP_MAX_LENGTH. + * @param[in] multiple_country_code_desig String for determining multiple country codes. Regular expression strings if a regular expression library is used. Otherwise, a single-character string representing the delimiter. + * If it gets trapped inside a function, it will have to stub the regcomp during function unit tests, which is very cumbersome and can be removed as arguments. + * @return True if country code indicates multiple countries, otherwise false + */ +/* ====================================================================== */ +MT_STATIC VP_FCCR_BOOL hasMultipleCoutnry( const char dest_str[], const char multiple_country_code_desig[] ) +{ + /* ====================================================================== */ + /* Variable declarations */ + /* ====================================================================== */ + VP_FCCR_BOOL isMultiple = B_FALSE; + + /* ====================================================================== */ + /* Processing */ + /* ====================================================================== */ + + /* NULL checking for arguments */ + if ( ( NULL != dest_str ) && ( NULL != multiple_country_code_desig ) ) + { + regex_t preg; + + if ( 0 == regcomp( &preg, multiple_country_code_desig, REG_EXTENDED ) ) + { + regmatch_t pmatch = { 0, 0 }; + + if ( REG_NOMATCH != regexec( &preg, &(dest_str[0]), 1, &pmatch, 0) ) + { + /** @note Exactly match is considered if the end-of-match offset matches the string length. + * Assumed that it should not be used as the end-of-line character so that "$" is not included in the C base character set. + */ + if ( (strnlen( dest_str, VP_MAX_LENGTH ) == (unsigned int)(pmatch.rm_eo) ) ) + { + isMultiple = B_TRUE; + } + else + { + isMultiple = B_FALSE; + } + + DEBUG_PRINT( "FOUND" ) + } + else + { + isMultiple = B_FALSE; + + DEBUG_PRINT( "NOT FOUND" ) + } + + regfree( &preg ); + } + else + { + /* In the case of a library error, + * return false so that the default value that is set by high layer works. + */ + + /** @todo Should output using FRAMEWORKUNIFIEDLOG for library errors? */ + isMultiple = B_FALSE; + + DEBUG_PRINT( "FOUND" ) + } + } + + return isMultiple; + +} +#endif diff --git a/service/other/vehicle_parameter_library/library/src/VP_GetEnv.c b/service/other/vehicle_parameter_library/library/src/VP_GetEnv.c new file mode 100755 index 0000000..c6cd6a7 --- /dev/null +++ b/service/other/vehicle_parameter_library/library/src/VP_GetEnv.c @@ -0,0 +1,291 @@ +/* + * @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 VP_GetEnv.c + * @brief API to get vehicle parameter environment variable + */ +/* ====================================================================== */ + + +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <other_service/VP_GetEnv.h> +#include <native_service/ns_backup.h> +#include <native_service/ns_backup_id.h> + +#include "VP_FuncCheck_CanRcv_private.h" + +// copy from vpsvc.h +#define VPSVC_COUNTRY_MAX (0x10) // Maximal number of country codes for 1 destination + +// copy from VehicleSens_Vpupdate.cpp + +#define VP_VEHICLEPARAMETERLIBRARY_DEST_LEN_MIN 5 // At least 5 characters for 1 destination(e.g. "I:104") +#define VP_VEHICLEPARAMETERLIBRARY_DEST_NUM_MAX (VP_MAX_LENGTH/VP_VEHICLEPARAMETERLIBRARY_DEST_LEN_MIN) +#define DS_PACK2_LEN_MAX 2+1 // Max. digits of destination package 2(+\0) + +typedef struct { + char dest_bdb[2]; // Destination symbol + char ds_pack2[DS_PACK2_LEN_MAX]; // Destination package 2 + uint8_t coutry_num; // Number of Country Codes + uint16_t country_no[VPSVC_COUNTRY_MAX]; // Country Code +} VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE_t; + +VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE_t g_vp_vehicleparameterlibrary_dest[VP_VEHICLEPARAMETERLIBRARY_DEST_NUM_MAX]; // Destination information get from environment variables +static uint32_t g_vp_vehicleparameterlibrary_dest_num; // Number of destination information get from environment variables + +static void AnalyzeVpVehicleparameterlibraryDestEnv(void) { + char p_env_variable[VP_MAX_LENGTH] = {}; + char dest_buf[VP_MAX_LENGTH] = { 0 }; // Destination data for environment variables + char *c_code_ascii; // Country Code(ASCII) + char *dest_bdb_buf; // Destination symbol + uint32_t dest_num = 0; // Number of destinations + int country_num = 0; // Number of Country Codes per Destination + char *token1, *saveptr1; // Destination break token + char *token2, *saveptr2; // Delimiter tokens in each destination + VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE_t *p_dest; + uint16_t *p_country; + + g_vp_vehicleparameterlibrary_dest_num = 0; + memset(&g_vp_vehicleparameterlibrary_dest, 0x00, sizeof(VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE_t)); + + // Get environment variables + VP_GetEnv(VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE, p_env_variable); + if (0 == strncmp(p_env_variable, "", VP_MAX_LENGTH)) { + DEBUG_PRINT("VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE is NULL"); + return; + } + + DEBUG_PRINTF("VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE=[%s]\n", p_env_variable); + + // Begin analysis First, separate with "," + token1 = strtok_r(p_env_variable, ",", &saveptr1); + while (token1 != NULL) { + snprintf(dest_buf, VP_MAX_LENGTH, "%s", token1); + DEBUG_PRINTF("dest_buf\t[%s]", dest_buf); + p_dest = &g_vp_vehicleparameterlibrary_dest[dest_num]; + + // Get the country code 000-999 + country_num = 0; + c_code_ascii = strchr(dest_buf, (int32_t)(':')); + if (c_code_ascii != NULL) { + c_code_ascii += 1; + token2 = strtok_r(c_code_ascii, "/", &saveptr2); + while (token2 != NULL) { + p_country = &(p_dest->country_no[country_num]); + errno = 0; + long int val = strtol(token2, (char **)NULL, 10); + if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) + || (errno != 0 && val == 0)) { + DEBUG_PRINTF("country No format error [%s]", token2); + return; + } + *p_country = (uint16_t)val; + + if (country_num >= VPSVC_COUNTRY_MAX) { + DEBUG_PRINTF("country num over [%s]", token2); + return; + } + country_num++; + token2 = strtok_r(NULL, "/", &saveptr2); + } + p_dest->coutry_num = (uint8_t)(country_num); + DEBUG_PRINTF("country_num\t[%d]", country_num); + } + + // Get destination symbol (may not be available) + dest_bdb_buf = strchr(dest_buf, (int32_t)('&')); + if (dest_bdb_buf != NULL) { + p_dest->dest_bdb[0] = *(dest_bdb_buf + 1); + DEBUG_PRINTF("dest_bdb\t[%s]", p_dest->dest_bdb); + } else { + DEBUG_PRINT("dest_bdb is noting"); + } + + // Get destination packages + token2 = strtok_r(dest_buf, "&:", &saveptr2); + snprintf(p_dest->ds_pack2, DS_PACK2_LEN_MAX, "%s", token2); + DEBUG_PRINTF("ds_pack2\t[%s]\n", p_dest->ds_pack2); + + dest_num++; + token1 = strtok_r(NULL, ",", &saveptr1); + } + + g_vp_vehicleparameterlibrary_dest_num = dest_num; +} + +// based VP_DspackToCountryCode +// dest [in] Destination codes read from the bkup_manager +// country_code [out] Country code string, separated by ";" for multi-country codes +static BOOL VP_DspackToCountryCode(uint8_t* dest, char *country_code) { + BOOL ret = FALSE; + VP_VEHICLEPARAMETERLIBRARY_DEST_C_CODE_t *p; + typedef struct { + char dest_bdb[2]; // Destination symbol + char ds_pack2[DS_PACK2_LEN_MAX]; // Destination package 2 + } VEHICLE_CAN_DEST_t; + VEHICLE_CAN_DEST_t can_dest = {}; + + AnalyzeVpVehicleparameterlibraryDestEnv(); + + // Setting CAN data + can_dest.dest_bdb[0] = (int8_t)dest[0]; // Get destination symbol + + if (isalpha(dest[2]) != 0) { // Get destination packages + can_dest.ds_pack2[0] = (int8_t)dest[2]; + } else { + DEBUG_PRINTF("ds_pack2 is neither Alpha character[%c]", (int32_t)dest[2]); + return ret; + } + + // Comparison with vehicle parameter + for (uint32_t i = 0; i < g_vp_vehicleparameterlibrary_dest_num; i++) { + p = &g_vp_vehicleparameterlibrary_dest[i]; + // Determination of destination packages + if (strncmp(p->ds_pack2, can_dest.ds_pack2, sizeof(can_dest.ds_pack2)) != 0) { + continue; + } + + // Determination of destination symbol + if (p->dest_bdb[0] == 0) { + ret = TRUE; // When the destination code judgment is not required + break; + } + + if (strncmp(p->dest_bdb, can_dest.dest_bdb, sizeof(can_dest.dest_bdb)) == 0) { + ret = TRUE; + break; + } + } + + // Returned as a country code string + if (ret == TRUE) { + snprintf(country_code, VP_MAX_LENGTH, "%03d", p->country_no[0]); + for (uint32_t i = 1; i < p->coutry_num; i++) { + char buf[VP_MAX_LENGTH] = {}; + snprintf(buf, VP_MAX_LENGTH, "%s;%03d", country_code, p->country_no[i]); + strncpy(country_code, buf, VP_MAX_LENGTH); + } + } + return ret; +} +// end of copy from VehicleSens_Vpupdate.cpp + +// copy from vehicle unit +typedef struct { + uint8_t uc_hv; /* hv */ + uint8_t uc_hv_status; /* hv status */ + uint8_t uc_2wd4wd; /* 2wd4wd */ + uint8_t uc_2wd4wd_status; /* 2wd4wd status */ + uint8_t uc_dest[3]; /* Destination */ + uint8_t uc_dest_status; /* Destination status */ + uint8_t uc_stwheel; /* STEERING_WHEEL */ + uint8_t uc_stwheel_status; /* STEERING_WHEEL status */ + uint8_t uc_reserve[6]; /* Reserve */ +} VEHICLESENS_NON_VOLATILE_DATA; + +/* ====================================================================== */ +/** + * @fn + * void VP_GetVp_CWORD31_Destination(char *pEnvBuff) + * @breaf Get environment variables + * @param[out] (pEnvBuff) Start address of the area to store the get environment variable value + * @return None + * @detail Read and analyze D_BK_ID_VEHICLE_STABLE_DATA from BackupManager. + * The country code string is stored in the argument and returned. + */ +/* ====================================================================== */ +static void VP_GetVp_CWORD31_Destination(char *pEnvBuff) +{ + int32_t ret_api = BKUP_RET_NORMAL; + VEHICLESENS_NON_VOLATILE_DATA pstback_up_data; + memset(&pstback_up_data, 0x00, sizeof(VEHICLESENS_NON_VOLATILE_DATA)); + char env_string[VP_MAX_LENGTH]; + + VP_GetEnv(VP__CWORD31__TELEMATICS_FUNCTION, env_string); + + if ('\0' == env_string[0]) { + *pEnvBuff = '\0'; + return; + } else { + // read from backup + ret_api = Backup_DataRd(D_BK_ID_VEHICLE_STABLE_DATA, + 0, + &pstback_up_data, + sizeof(VEHICLESENS_NON_VOLATILE_DATA)); + if (BKUP_RET_NORMAL != ret_api) { + *pEnvBuff = '\0'; + return; + } + } + + if (0 == strncmp(env_string, "country_ID", strlen("country_ID"))) { + uint32_t country_code = 0; + country_code += (pstback_up_data.uc_dest[1]); // countory_code 3rd and 2nd digit + country_code = (country_code << 4); // shift + country_code += (pstback_up_data.uc_dest[2] >> 4); // countory_code 1st digit + snprintf(pEnvBuff, VP_MAX_LENGTH, "%x", country_code); + } else if(0 == strncmp(env_string, "CAN_judge", strlen("CAN_judge"))) { + VP_DspackToCountryCode(pstback_up_data.uc_dest, pEnvBuff); + } else { + *pEnvBuff = '\0'; + } +} + +/* ====================================================================== */ +/** + * @fn + * void VP_GetEnv(char *pEnvStr, char *pEnvBuff ) + * @breaf Get Environment Variable + * @param[in] (pEnvStr) Pointer to the string of the environment variable name to be gotten + * @param[out] (pEnvBuff) Start address of the area to store the gotten value of the environment variable + * @return None + * @detail Read the value (string) of the environment variable specified by the argument and stores it in the specified address. + */ +/* ====================================================================== */ +void VP_GetEnv(const char *pEnvStr, char *pEnvBuff ) +{ + const char *env_string; + size_t length; + + if ((pEnvStr != NULL) && (pEnvBuff != NULL)) { + if (0 == strncmp(pEnvStr, VP__CWORD31__DESTINATION, strlen(VP__CWORD31__DESTINATION))) { + VP_GetVp_CWORD31_Destination(pEnvBuff); + } else { + env_string = getenv(pEnvStr); + + if (env_string == NULL) { + *pEnvBuff = '\0'; + } else { + length = strlen( env_string ); + if (length < ((size_t)VP_MAX_LENGTH)) { + (void)strcpy(pEnvBuff, env_string); + } else { + (void)strncpy(pEnvBuff, env_string, (VP_MAX_LENGTH - 1)); + pEnvBuff[ VP_MAX_LENGTH - 1 ] = '\0'; + } + } + } + } else { + if(pEnvBuff != NULL) { + *pEnvBuff = '\0'; + } + } +} |