2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file VP_FuncCheck_CanRcv.c
19 * @brief Get function existence API
23 /* ====================================================================== */
25 /* ====================================================================== */
30 #include <other_service/VP_GetEnv.h>
31 #include "VP_FuncCheck_CanRcv_private.h"
33 /* ====================================================================== */
34 /* Enumeration types */
35 /* ====================================================================== */
36 typedef enum VPFuncTableDestIndexTag{
39 * This feature needs to be defined by the vendor.
41 VP_FUNC_TABLE_DEST_INDEX_A ,
42 VP_FUNC_TABLE_DEST_INDEX_B ,
44 VP_FUNC_TABLE_DEST_INDEX_MAX /**< Number of choices (index maximum value: 1) */
45 } VP_FUNC_TABLE_DEST_INDEX;
47 typedef enum VPFuncTableBrandTag{
50 * This feature needs to be defined by the vendor.
52 VP_FUNC_TABLE_BRAND_A,
53 VP_FUNC_TABLE_BRAND_B,
55 VP_FUNC_TABLE_BRAND_INDEX_MAX /**< Number of choices (index maximum value: 1) */
56 } VP_FUNC_TABLE_BRAND;
58 typedef enum VPFuncTableGradeLTag{
61 * This feature needs to be defined by the vendor.
63 VP_FUNC_TABLE_GRADE_A1,
64 VP_FUNC_TABLE_GRADE_A2,
66 VP_FUNC_TABLE_GRADE_A_INDEX_MAX /**< Number of choices (index maximum value: 1) */
67 } VP_FUNC_TABLE_GRADE_A;
69 typedef enum VPFuncTableGradeTTag{
72 * This feature needs to be defined by the vendor.
74 VP_FUNC_TABLE_GRADE_B1,
75 VP_FUNC_TABLE_GRADE_B2,
77 VP_FUNC_TABLE_GRADE_B_INDEX_MAX /**< Number of choices (index maximum value: 1) */
78 } VP_FUNC_TABLE_GRADE_B;
80 typedef enum VPFuncTableFuncTypeIndexTag{
81 VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN , /**< Unknown function */
82 VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO , /**< XM Audio */
83 VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ , /**< _CWORD27_ */
84 VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT , /**< Wifi Hotspot */
85 VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION , /**< Travel Restriction */
86 VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA , /**< HD Data */
87 VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G , /**< Wifi 5G */
89 VP_FUNC_TABLE_FUNC_TYPE_INDEX_MAX /**< Number of choices (index maximum value: 1) */
90 } VP_FUNC_TABLE_FUNC_TYPE;
92 /** Processing definitions for CAN information availability */
93 typedef enum CANFuncCheckSwitchTag{
94 CAN_FUNC_CHEK_AVAILABLE ,
95 CAN_FUNC_CHEK_UNAVAILABLE ,
96 CAN_FUNC_CHEK_COUNTRY_CODE
97 } CAN_FUNC_CHEK_SWITCH;
101 /**< Definition of number of functions (required for initial definition of function availability table) */
103 #define VP_FUNC_TABLE_FUNCTION_INDEX_MAX ((unsigned int)7)
105 /* ====================================================================== */
106 /* Macro definitions */
107 /* ====================================================================== */
108 /* Definition for return value from string functions */
109 #define RET_STD_LIB_STRING_STR_CMP_OK ((int)0) /**< The return value of the strncmp. this value is returned when matched. */
111 /* Default index values */
112 #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. */
113 #define DEFAULT_TABLE_INDEX_BRAND (VP_FUNC_TABLE_BRAND_A)
114 #define DEFAULT_TABLE_INDEX_GRADE_A (VP_FUNC_TABLE_GRADE_A1)
115 #define DEFAULT_TABLE_INDEX_GRADE_B (VP_FUNC_TABLE_GRADE_B1)
116 #define DEFAULT_CAN_JUDGE_STATUS (CAN_FUNC_CHEK_COUNTRY_CODE)
118 /* ====================================================================== */
119 /* Constant definitions */
120 /* ====================================================================== */
122 /* ====================================================================== */
124 /* ====================================================================== */
126 /* ====================================================================== */
127 /* Internal function prototype declarations */
128 /* ====================================================================== */
129 #ifdef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE
130 MT_STATIC u_int8_t getResult_CanJudge( unsigned int idx_func );
131 MT_STATIC unsigned int getIndexOfFunc( u_int8_t func );
132 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 );
133 MT_STATIC VP_FCCR_BOOL hasMultipleCoutnry( const char dest_str[] , const char multiple_country_code_desig[] );
135 /* ====================================================================== */
136 /* Public function definitions */
137 /* ====================================================================== */
140 * u_int8_t VP_FuncCheck_CanRcv( u_int8_t FunctionName )
141 * @brief Get function existence API(Public)
142 * @param[in] (FunctionName) Function Name (Number)
143 * @return FUNCTION_CHECK_RESULT_OK :This function is available
144 * FUNCTION_CHECK_RESULT_NG :This function is unavailable
145 * FUNCTION_CHECK_RESULT_UNKNOWN :This function does not exist
146 * @details Read the function name as feature name specified in the argument, then return one of the
147 * "This function is available"/"This function is unavailable"/"This function does not exist"
148 * of the feature as the following check-result:
149 * - vehicle parameter:CAN information availability(destination package) judge
150 * - vehicle parameter:country code
151 * - Whether or not supported the features corresponding to the country code in this API
153 * When CAN information availability (destination package) in vehicle parameters is
154 * "Control ON/OFF according to CAN information" or "Country code", return "This function is available"
155 * if this function is called when the country code from CAN is unacquired or undetermined country code.
157 /* ====================================================================== */
158 u_int8_t VP_FuncCheck_CanRcv( u_int8_t FunctionName )
160 #ifndef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE
163 switch(FunctionName) {
165 result = FUNCTION_CHECK_RESULT_NG;
168 case VP_CANRCV__CWORD27_:
170 case AREA1_STD_TRAF_LIMIT:
173 result = FUNCTION_CHECK_RESULT_OK;
176 result = FUNCTION_CHECK_RESULT_UNKNOWN;
183 /* ====================================================================== */
184 /* Internal table definition */
185 /* ====================================================================== */
186 /** Vehicle Parameter "CAN information Support/Not Support"- processing selector translation table */
187 const TABLE_INDEX_INFO TABLE_STATUS_INFO_CAN_JUDGE[] =
189 { "available" , CAN_FUNC_CHEK_AVAILABLE }, // Yes
190 { "unavailable" , CAN_FUNC_CHEK_UNAVAILABLE }, // None
191 { "CAN_judge" , CAN_FUNC_CHEK_COUNTRY_CODE }, // Control ON/OFF according to CAN information
192 { "country_ID" , CAN_FUNC_CHEK_COUNTRY_CODE } // Country code
195 /* ====================================================================== */
196 /* Table Size Definition */
197 /* ====================================================================== */
198 const unsigned int LENGTHOF_TABLE_INDEX_INFO_CAN_JUDGE = ( sizeof(TABLE_STATUS_INFO_CAN_JUDGE ) / sizeof( TABLE_INDEX_INFO ) );
200 /* ====================================================================== */
201 /* Internal variable declarations */
202 /* ====================================================================== */
203 u_int8_t result = FUNCTION_CHECK_RESULT_UNKNOWN;
205 unsigned int idx_func = 0;
207 unsigned int can_judge_status = CAN_FUNC_CHEK_COUNTRY_CODE;
208 char VP_canjudge[ VP_MAX_LENGTH ];
209 char VP_area[ VP_MAX_LENGTH ];
211 /* ====================================================================== */
213 /* ====================================================================== */
214 /* Get vehicle parameter */
215 VP_GetEnv( VEHICLEPARAMETERLIBRARY_AREA , &(VP_area[0]) );
217 DEBUG_PRINTF( "AREA = %s; " , VP_area )
219 /* Get feature name index */
220 idx_func = getIndexOfFunc( FunctionName );
222 DEBUG_PRINTF( "Function = %d; " , FunctionName )
223 DEBUG_PRINTF( "idx_func = %d\n" , idx_func )
225 /* Judge as other than area1 because it is not a area1 */
226 if ( strncmp( VP_area, "AREA1", VP_MAX_LENGTH ) != RET_STD_LIB_STRING_STR_CMP_OK )
228 result = FUNCTION_CHECK_RESULT_OUT_OF_AREA1;
232 /* If the feature is unknown, it is judged to be unknown before checking CAN information. */
233 if ( VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN == idx_func )
235 result = FUNCTION_CHECK_RESULT_UNKNOWN;
239 /* 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. */
240 VP_GetEnv( VP__CWORD31__TELEMATICS_FUNCTION , &(VP_canjudge[0]) );
242 /* Choose processing according to CAN information Support/Not Support. */
243 can_judge_status = getIndexOfTable(
245 &(TABLE_STATUS_INFO_CAN_JUDGE[0]),
246 LENGTHOF_TABLE_INDEX_INFO_CAN_JUDGE,
247 DEFAULT_CAN_JUDGE_STATUS
250 DEBUG_PRINTF( "VP_canjudge = %s; ", VP_canjudge )
252 /* When judging from CAN information or country code */
253 if ( CAN_FUNC_CHEK_COUNTRY_CODE == can_judge_status )
255 DEBUG_PRINT( "CAN judge : C_CODE or CAN_JUDGE" )
256 result = getResult_CanJudge( idx_func );
260 /* For available/unavailable */
261 /* Standard travel restriction of AREA1 */
262 if ( AREA1_STD_TRAF_LIMIT == idx_func )
264 result = FUNCTION_CHECK_RESULT_OK;
268 switch( can_judge_status )
270 case CAN_FUNC_CHEK_UNAVAILABLE:
271 DEBUG_PRINT( "CAN judge : UNAVAILABLE" )
272 result = FUNCTION_CHECK_RESULT_NG;
275 case CAN_FUNC_CHEK_AVAILABLE:
276 default: /* If the default value of canjudge_status are set correctly, the default cannot be selected */
277 DEBUG_PRINT( "CAN judge : AVAILABLE" )
278 result = FUNCTION_CHECK_RESULT_OK;
285 DEBUG_PRINTF( "RESULT = %d\n", result )
292 /* ====================================================================== */
293 /* Internal function definitions */
294 /* ====================================================================== */
295 #ifdef VP_FUNCCHECK_CANRCV_CANRCV_ACTIVATE
296 /* ====================================================================== */
298 * @brief Get function existence in consideration of country code
299 * @detials Internal-use functions - Processing when CAN information availability is "Country Code"
300 * @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)
301 * @return Availability of the feature in current vehicle parameters
303 /* ====================================================================== */
304 MT_STATIC u_int8_t getResult_CanJudge( unsigned int idx_func )
306 /* ====================================================================== */
307 /* Internal constant definition */
308 /* ====================================================================== */
309 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 */
311 /* ====================================================================== */
312 /* Internal table definitions */
313 /* ====================================================================== */
314 /** Feature table index conversion table (country code) */
315 const TABLE_INDEX_INFO TABLE_INDEX_INFO_DESTINATION[] =
319 * This feature needs to be defined by the vendor.
321 { "101" , VP_FUNC_TABLE_DEST_INDEX_A }, // Detination A
322 { "102" , VP_FUNC_TABLE_DEST_INDEX_B } // Detination B
325 /** @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,
326 It can be also summarized the translation table.
327 However, it must be able to guarantee that there are no differences in the table format in L/T. */
328 /** Index Ttranslation Table for feature availability table (for grade A) */
329 const TABLE_INDEX_INFO TABLE_INDEX_INFO_GRADE_A[] =
333 * This feature needs to be defined by the vendor.
335 { "A1" , VP_FUNC_TABLE_GRADE_A1 }, // GRADE A1
336 { "A2" , VP_FUNC_TABLE_GRADE_A2 } // GRADE A2
339 /** Index Translation Table for feature availability table (for grade B) */
340 const TABLE_INDEX_INFO TABLE_INDEX_INFO_GRADE_B[] =
344 * This feature needs to be defined by the vendor.
346 { "B1" , VP_FUNC_TABLE_GRADE_B1 }, // GRADE B1
347 { "B2" , VP_FUNC_TABLE_GRADE_B2 }, // GRADE B2
350 /** Index Translation Table for feature availability table (brand) */
351 const TABLE_INDEX_INFO TABLE_INDEX_INFO_BRAND[] =
355 * This feature needs to be defined by the vendor.
357 { "A" , VP_FUNC_TABLE_BRAND_A }, // BRAND A
358 { "B" , VP_FUNC_TABLE_BRAND_B } // BRAND B
361 /* ====================================================================== */
363 * @brief Feature availability table for BRAND A
364 * @details Array of type u_int8_t accessed by the following index
366 /* ====================================================================== */
367 const u_int8_t VP_FUNC_CHECK_CANRCV_TABLE_A[ VP_FUNC_TABLE_DEST_INDEX_MAX ]
368 [ VP_FUNC_TABLE_GRADE_A_INDEX_MAX ]
369 [ VP_FUNC_TABLE_FUNCTION_INDEX_MAX ] =
373 * This feature needs to be defined by the vendor.
377 // Unknown , XM Audio , _CWORD27_ , Wifi HotSpot , Travel Restriction , HD Data Wifi 5G
378 { 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
379 { 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
384 { 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
385 { 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
389 /* ====================================================================== */
391 * @brief Feature availability table for BRAND B
393 /* ====================================================================== */
394 const u_int8_t VP_FUNC_CHECK_CANRCV_TABLE_B[ VP_FUNC_TABLE_DEST_INDEX_MAX ]
395 [ VP_FUNC_TABLE_GRADE_B_INDEX_MAX ]
396 [ VP_FUNC_TABLE_FUNCTION_INDEX_MAX ] =
400 * This feature needs to be defined by the vendor.
404 // Unknown , XM Audio , _CWORD27_ , Wifi HotSpot , Travel Restriction , HD Data , Wifi 5G
405 { 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
406 { 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
411 { 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
412 { 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
416 /* ====================================================================== */
417 /* Table Size Definitions */
418 /* ====================================================================== */
419 const unsigned int SIZE_TABLE_INDEX_INFO_BRAND = ( sizeof(TABLE_INDEX_INFO_BRAND ) / sizeof( TABLE_INDEX_INFO ) );
420 const unsigned int SIZE_TABLE_INDEX_INFO_GRADE_A = ( sizeof(TABLE_INDEX_INFO_GRADE_A ) / sizeof( TABLE_INDEX_INFO ) );
421 const unsigned int SIZE_TABLE_INDEX_INFO_GRADE_B = ( sizeof(TABLE_INDEX_INFO_GRADE_B ) / sizeof( TABLE_INDEX_INFO ) );
422 const unsigned int SIZE_TABLE_INDEX_INFO_DESTINATION = ( sizeof(TABLE_INDEX_INFO_DESTINATION) / sizeof( TABLE_INDEX_INFO ) );
424 /* ====================================================================== */
425 /* Variable declarations */
426 /* ====================================================================== */
427 u_int8_t result = FUNCTION_CHECK_RESULT_UNKNOWN;
429 VP_FCCR_BOOL isMultipleCountry = B_FALSE;
431 unsigned int idx_dest = 0;
432 unsigned int idx_brand = 0;
433 unsigned int idx_grade = 0;
435 char VP_destination[ VP_MAX_LENGTH ];
436 char VP_brand[ VP_MAX_LENGTH ];
437 char VP_grade[ VP_MAX_LENGTH ];
439 /* ====================================================================== */
440 /* Static assertion */
441 /* ====================================================================== */
442 /* The following are expected to be identical */
443 VP_DEBUG_STATIC_ASSERT( SIZE_TABLE_INDEX_INFO_BRAND == VP_FUNC_TABLE_BRAND_INDEX_MAX )
444 VP_DEBUG_STATIC_ASSERT( SIZE_TABLE_INDEX_INFO_GRADE_A == VP_FUNC_TABLE_GRADE_A_INDEX_MAX )
446 /* Country code does not match because there are multiple countries. */
447 VP_DEBUG_STATIC_ASSERT( VP_FUNC_TABLE_DEST_INDEX_MAX > SIZE_TABLE_INDEX_INFO_DESTINATION )
449 /* ====================================================================== */
451 /* ====================================================================== */
454 if ( VP_FUNC_TABLE_FUNC_TYPE_INDEX_MAX <= idx_func )
456 DEBUG_PRINTF( "ERROR : tebale index overed idx_func = %d\n", idx_func )
458 // Return unknown if the table size is exceeded. (However, this function can be called only from the API at the moment.)
459 result = FUNCTION_CHECK_RESULT_UNKNOWN;
464 /* Get vehicle parameter */
465 VP_GetEnv( VP__CWORD31__DESTINATION, &(VP_destination[0]) );
466 VP_GetEnv( VEHICLEPARAMETERLIBRARY_BRAND , &(VP_brand[0]) );
467 VP_GetEnv( VP_VEHICLEPARAMETERLIBRARY_GRADE , &(VP_grade[0]) );
469 DEBUG_PRINTF( "VP_destination = %s\n", VP_destination )
471 /* Append NULL at the end just in case. (so as not to cause any problems using the strlen or regcomp later) */
472 VP_destination[ VP_MAX_LENGTH - 1 ] = '\0';
473 VP_brand[ VP_MAX_LENGTH - 1 ] = '\0';
474 VP_grade[ VP_MAX_LENGTH - 1 ] = '\0';
476 /* Check if the country code is NULL */
477 if ( VP_destination[0] == '\0' )
479 /* If NULL, set the index for the country code of the US. */
480 idx_dest = VP_FUNC_TABLE_DEST_INDEX_A;
481 DEBUG_PRINTF( "[debug]idx_dest = %d\n", idx_dest )
485 /* Check whether it is a member (multiple countries) */
486 isMultipleCountry = hasMultipleCoutnry( &(VP_destination[0]), &(MULTIPLE_COUNTRY_CODE_DESIG[0]) );
488 /* Get the index for a country code */
489 if ( B_TRUE == isMultipleCountry )
491 /* If it is dependent (multiple countries), set the index for the country code of the dependent */
492 DEBUG_PRINT( "isMultipleCountry = TRUE" )
494 idx_dest = VP_FUNC_TABLE_DEST_INDEX_B;
498 /* If it is not dependent (multiple countries), it searches the translation table and sets the index. */
499 DEBUG_PRINT( "isMultipleCountry = FALSE" )
501 idx_dest = getIndexOfTable( &(VP_destination[0]), &(TABLE_INDEX_INFO_DESTINATION[0]), SIZE_TABLE_INDEX_INFO_DESTINATION, DEFAULT_TABLE_INDEX_DEST );
504 DEBUG_PRINTF( "idx_dest = %d\n", idx_dest )
506 /* Get brand index */
507 idx_brand = getIndexOfTable( &(VP_brand[0]) , &(TABLE_INDEX_INFO_BRAND[0]) , SIZE_TABLE_INDEX_INFO_BRAND , DEFAULT_TABLE_INDEX_BRAND );
511 * Setting Defaults for each brand
512 * e.g. The default is A, so if it is not B, it is determined to be A.
514 if ( VP_FUNC_TABLE_BRAND_B == idx_brand )
516 DEBUG_PRINT( "idx_brand = B")
518 idx_grade = getIndexOfTable( &(VP_grade[0]) , &(TABLE_INDEX_INFO_GRADE_B[0]) , SIZE_TABLE_INDEX_INFO_GRADE_B , DEFAULT_TABLE_INDEX_GRADE_B );
521 result = VP_FUNC_CHECK_CANRCV_TABLE_B[idx_dest][idx_grade][idx_func];
526 DEBUG_PRINT( "idx_brand = A")
528 idx_grade = getIndexOfTable( &(VP_grade[0]) , &(TABLE_INDEX_INFO_GRADE_A[0]) , SIZE_TABLE_INDEX_INFO_GRADE_A , DEFAULT_TABLE_INDEX_GRADE_A );
531 result = VP_FUNC_CHECK_CANRCV_TABLE_A[idx_dest][idx_grade][idx_func];
535 //DEBUG_PRINTF( "RESULT = %d\n", result )
542 /* ====================================================================== */
544 * @brief Feature-Table Index Translation Function
545 * @detials Internal-use functions. It is translate the feature definition number to an index for the table.
546 * @param[in] Feature name defined by the func define
547 * @return The table index corresponding to the feature. If the given country code is invalid, return the index given by default_idx
549 /* ====================================================================== */
550 MT_STATIC unsigned int getIndexOfFunc( u_int8_t func )
552 /* ====================================================================== */
553 /* Internal table definitions */
554 /* ====================================================================== */
555 /** Index translation table for feature table (Features) */
556 const VP_FUNC_TABLE_FUNC_TYPE GET_INDEX_OF_FUNC[] = {
557 VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN , //#define VP_FUNCCHECK_CANRCV_UNKNOWN ((u_int8_t)0) /* Unknown Features */
558 VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO , //#define XM_AUDIO ((u_int8_t)1) /* XM Audio */
559 VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ , //#define _CWORD27_ ((u_int8_t)3) /* _CWORD27_ */
560 VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT , //#define WIFI_HOTSPOT ((u_int8_t)4) /* WiFi HotSpot */
561 VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION , //#define AREA1_STD_TRAF_LIMIT ((u_int8_t)5) /* Standard Travel Restriction of AREA1 */
562 VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA , //#define HD_DATA ((u_int8_t)6) /* HD Data (Include traffic) */
563 VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G //#define WIFI_5G ((u_int8_t)7) /* WiFi 5G */
568 /* ====================================================================== */
569 /* Variable declarations */
570 /* ====================================================================== */
571 const unsigned int index_table_size = sizeof( GET_INDEX_OF_FUNC ) / sizeof( VP_FUNC_TABLE_FUNC_TYPE );
573 u_int8_t table_index = VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN;
575 /* ====================================================================== */
576 /* Static assertions */
577 /* ====================================================================== */
578 /* 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) */
579 VP_DEBUG_STATIC_ASSERT( index_table_size == VP_FUNC_TABLE_FUNCTION_INDEX_MAX )
581 /* Translation tables or the enumeration pair (VP_FUNC_TABLE_FUNC_TYPE) must also be modified when the definition value changes.
582 It may also be changed, added, or deleted following asserts as appropriate according to the defined value. */
583 VP_DEBUG_STATIC_ASSERT( XM_AUDIO == VP_FUNC_TABLE_FUNC_TYPE_INDEX_XM_AUDIO )
585 VP_DEBUG_STATIC_ASSERT( VP_CANRCV__CWORD27_ == VP_FUNC_TABLE_FUNC_TYPE_INDEX_VP_CANRCV__CWORD27_ )
586 VP_DEBUG_STATIC_ASSERT( WIFI_HOTSPOT == VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_HOTSPOT )
587 VP_DEBUG_STATIC_ASSERT( AREA1_STD_TRAF_LIMIT == VP_FUNC_TABLE_FUNC_TYPE_INDEX_RESTRICT_FUNCTION )
588 VP_DEBUG_STATIC_ASSERT( HD_DATA == VP_FUNC_TABLE_FUNC_TYPE_INDEX_HD_DATA )
589 VP_DEBUG_STATIC_ASSERT( WIFI_5G == VP_FUNC_TABLE_FUNC_TYPE_INDEX_WIFI_5G )
592 /* ====================================================================== */
594 /* ====================================================================== */
596 /* Argument check: Treat as unknown feature if it is larger than index translation table */
597 if ( index_table_size <= func )
599 table_index = VP_FUNC_TABLE_FUNC_TYPE_INDEX_UNKNOWN;
603 table_index = (u_int8_t)(GET_INDEX_OF_FUNC[func]);
610 /* ====================================================================== */
612 * @brief Vehicle parameter string to integer conversion function
613 * @detials Internal-use function. Convert the given string (vehicle parameter) into an index for the table.
614 * The value gotten using VP_GetEnv() is assumed. Thus, the maximum length is VP_MAX_LENGTH.
615 * Return the value set in default_index if the conversion is failed.
616 * @param[in] vp_param_str String as source of convetion to the table index
617 * @param[in] table_index_info String corresponding to table index and an array of structs with table indexes set
618 * @param[in] info_size Size of the table_index_info array
619 * @param[in] default_index Default index. Return this value if none of table_index_info matches
620 * @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.
622 /* ====================================================================== */
623 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 )
625 unsigned int table_index = 0;
627 table_index = default_index; /* Set as initial value so that it can return the set default if it is unknown */
629 //DEBUG_PRINTF("info_size = %d\n", info_size)
632 if ( NULL != vp_param_str )
634 if ( NULL != table_index_info )
638 for ( i = 0; i < info_size; i++ )
640 if ( RET_STD_LIB_STRING_STR_CMP_OK == strncmp( &(vp_param_str[0]), &((table_index_info[i]).code_str[0]), VP_MAX_LENGTH ) )
642 table_index = (table_index_info[i]).index;
650 DEBUG_PRINT( "ERROR!! the Bad Teble overd." )
657 /* ====================================================================== */
659 * @brief Function to check whether country code is multiple countries or not
660 * @detials Internal-use functions. Check if the country code given in the argument contains more than one country.
661 * The determination whether multiple country code or not shall be true if it exactly matches the specified
662 * regular expression which is a characteristic of multiple countries.
663 * The exact match determination shall be the exact match if the length of the matched character matches
664 * the length of the character passed in the argument.
665 * @param[in] dest_str Country code string. The value gotten using VP_GetEnv() is assumed. Therefore, the maximum length is VP_MAX_LENGTH.
666 * @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.
667 * 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.
668 * @return True if country code indicates multiple countries, otherwise false
670 /* ====================================================================== */
671 MT_STATIC VP_FCCR_BOOL hasMultipleCoutnry( const char dest_str[], const char multiple_country_code_desig[] )
673 /* ====================================================================== */
674 /* Variable declarations */
675 /* ====================================================================== */
676 VP_FCCR_BOOL isMultiple = B_FALSE;
678 /* ====================================================================== */
680 /* ====================================================================== */
682 /* NULL checking for arguments */
683 if ( ( NULL != dest_str ) && ( NULL != multiple_country_code_desig ) )
687 if ( 0 == regcomp( &preg, multiple_country_code_desig, REG_EXTENDED ) )
689 regmatch_t pmatch = { 0, 0 };
691 if ( REG_NOMATCH != regexec( &preg, &(dest_str[0]), 1, &pmatch, 0) )
693 /** @note Exactly match is considered if the end-of-match offset matches the string length.
694 * Assumed that it should not be used as the end-of-line character so that "$" is not included in the C base character set.
696 if ( (strnlen( dest_str, VP_MAX_LENGTH ) == (unsigned int)(pmatch.rm_eo) ) )
702 isMultiple = B_FALSE;
705 DEBUG_PRINT( "FOUND" )
709 isMultiple = B_FALSE;
711 DEBUG_PRINT( "NOT FOUND" )
718 /* In the case of a library error,
719 * return false so that the default value that is set by high layer works.
722 /** @todo Should output using FRAMEWORKUNIFIEDLOG for library errors? */
723 isMultiple = B_FALSE;
725 DEBUG_PRINT( "FOUND" )