le_hex.h File Reference
Go to the source code of this file.
Functions | |
int32_t | le_hex_StringToBinary (const char *stringPtr, uint32_t stringLength, uint8_t *binaryPtr, uint32_t binarySize) |
int32_t | le_hex_BinaryToString (const uint8_t *binaryPtr, uint32_t binarySize, char *stringPtr, uint32_t stringSize) |
int | le_hex_HexaToInteger (const char *stringPtr) |
Detailed Description
Legato Hex string API include file.
Copyright (C) Sierra Wireless Inc.
Function Documentation
◆ le_hex_BinaryToString()
int32_t le_hex_BinaryToString | ( | const uint8_t * | binaryPtr, |
uint32_t | binarySize, | ||
char * | stringPtr, | ||
uint32_t | stringSize | ||
) |
Convert a byte array into a string of uppercase hexadecimal characters.
- Returns
- number of characters written to stringPtr or -1 if stringSize is too small for binarySize
- Note
- the string written to stringPtr will be NULL terminated.
- Parameters
-
[in] binaryPtr binary array to convert [in] binarySize size of binary array [out] stringPtr hex string array, terminated with '\0'. [in] stringSize size of string array. Must be >= (2 * binarySize) + 1
◆ le_hex_HexaToInteger()
int le_hex_HexaToInteger | ( | const char * | stringPtr | ) |
Convert a NULL terminated string of valid hexadecimal characters [0-9a-fA-F] into an integer.
- Returns
- Positive integer corresponding to the hexadecimal input string
- -1 if the input contains an invalid character or the value will not fit in an integer
- Parameters
-
[in] stringPtr string of hex chars to convert into an int
◆ le_hex_StringToBinary()
int32_t le_hex_StringToBinary | ( | const char * | stringPtr, |
uint32_t | stringLength, | ||
uint8_t * | binaryPtr, | ||
uint32_t | binarySize | ||
) |
Convert a string of valid hexadecimal characters [0-9a-fA-F] into a byte array where each element of the byte array holds the value corresponding to a pair of hexadecimal characters.
- Returns
- number of bytes written into binaryPtr
- -1 if the binarySize is too small or stringLength is odd or stringPtr contains an invalid character
- Note
- The input string is not required to be NULL terminated.
- Parameters
-
[in] stringPtr string to convert [in] stringLength string length [out] binaryPtr binary result [in] binarySize size of the binary table. Must be >= stringLength / 2