Connectivity Middleware Utilities Library

General Description

The string utilities module is a collection of string conversion helpers to convert between integer and strings.

Functions

uint32_t cy_generic_string_to_unsigned (const char *str)
 Convert a decimal or hexidecimal string to an integer. More...
 
uint8_t cy_string_to_signed (const char *string, uint16_t str_length, int32_t *value_out, uint8_t is_hex)
 Converts a decimal/hexidecimal string (with optional sign) to a signed long int Better than strtol or atol or atoi because the return value indicates if an error occurred. More...
 
uint8_t cy_string_to_unsigned (const char *string, uint8_t str_length, uint32_t *value_out, uint8_t is_hex)
 Converts a decimal/hexidecimal string to an unsigned long int Better than strtol or atol or atoi because the return value indicates if an error occurred. More...
 

Function Documentation

◆ cy_generic_string_to_unsigned()

uint32_t cy_generic_string_to_unsigned ( const char *  str)

Convert a decimal or hexidecimal string to an integer.

Parameters
[in]strThe string containing the value.
Returns
The value represented by the string.

◆ cy_string_to_signed()

uint8_t cy_string_to_signed ( const char *  string,
uint16_t  str_length,
int32_t *  value_out,
uint8_t  is_hex 
)

Converts a decimal/hexidecimal string (with optional sign) to a signed long int Better than strtol or atol or atoi because the return value indicates if an error occurred.

Parameters
[in]string: The string buffer to be converted
[in]str_length: The maximum number of characters to process in the string buffer
[out]value_out: The unsigned in that will receive value of the the decimal string
[in]is_hex: 0 = Decimal string, 1 = Hexidecimal string
Returns
the number of characters successfully converted (including sign). i.e. 0 = error

◆ cy_string_to_unsigned()

uint8_t cy_string_to_unsigned ( const char *  string,
uint8_t  str_length,
uint32_t *  value_out,
uint8_t  is_hex 
)

Converts a decimal/hexidecimal string to an unsigned long int Better than strtol or atol or atoi because the return value indicates if an error occurred.

Parameters
[in]string: The string buffer to be converted
[in]str_length: The maximum number of characters to process in the string buffer
[out]value_out: The unsigned in that will receive value of the the decimal string
[in]is_hex: 0 = Decimal string, 1 = Hexidecimal string
Returns
the number of characters successfully converted. i.e. 0 = error