CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
arrays.h File Reference
#include <stdint.h>
Include dependency graph for arrays.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int16_t GEN_get_index_of_substring_in_array (const char *haystack_arr, int16_t haystack_arr_len, const char *needle_str)
 Returns the index of the first character of the first occurrence of a substring in an array.
 
int16_t GEN_get_index_of_subarray_in_array (const uint8_t *haystack_arr, int16_t haystack_arr_len, const uint8_t *needle_arr, int16_t needle_arr_len)
 Returns the index of the first element of the first occurrence of a sub-array in an array.
 
void GEN_uint64_to_str (uint64_t value, char *buffer)
 Converts a uint64_t to a string.
 
void GEN_uint64_to_padded_str (uint64_t value, uint8_t padding_len, char *buffer)
 Converts a uint64_t to a string, with leading zeros.
 
void GEN_int64_to_str (int64_t value, char *buffer)
 Converts an int64_t to a string.
 
uint8_t GEN_hex_str_to_byte_array (const char *hex_str, uint8_t output_byte_array[], uint16_t output_byte_array_size, uint16_t *output_byte_array_len)
 Converts a hex string to a byte array.
 
void GEN_byte_array_to_hex_str (const uint8_t *byte_array, uint32_t byte_array_len, char *dest_str, uint32_t dest_str_size)
 Writes a byte array to a hex string (no spaces between bytes).
 

Function Documentation

◆ GEN_byte_array_to_hex_str()

void GEN_byte_array_to_hex_str ( const uint8_t * byte_array,
uint32_t byte_array_len,
char * dest_str,
uint32_t dest_str_size )

Writes a byte array to a hex string (no spaces between bytes).

Parameters
byte_arrayInput byte array.
byte_array_lenLength of input byte_array.
dest_strThe destination to write a C-string to.
dest_str_sizeThe size of the dest_str array, allocated before calling. Must be at least byte_array_len * 3 + 1 to fit the entire string.
Here is the caller graph for this function:

◆ GEN_get_index_of_subarray_in_array()

int16_t GEN_get_index_of_subarray_in_array ( const uint8_t * haystack_arr,
int16_t haystack_arr_len,
const uint8_t * needle_arr,
int16_t needle_arr_len )

Returns the index of the first element of the first occurrence of a sub-array in an array.

Parameters
haystack_arrThe array to search within.
haystack_arr_lenThe length of the array to search within.
needle_arrThe substring/sub-array to search for.
needle_arr_lenThe length of the substring/sub-array to search for.
Returns
The index of the start of the first occurrence of the substring in the array, or -1 if not found

◆ GEN_get_index_of_substring_in_array()

int16_t GEN_get_index_of_substring_in_array ( const char * haystack_arr,
int16_t haystack_arr_len,
const char * needle_str )

Returns the index of the first character of the first occurrence of a substring in an array.

Parameters
haystack_arrThe array to search within.
haystack_arr_lenThe length of the array to search within.
needle_strThe substring to search for. Must be a null-terminated C-string.
Returns
The index of the start of the first occurrence of the needle_str in the array, or -1 if not found
Here is the caller graph for this function:

◆ GEN_hex_str_to_byte_array()

uint8_t GEN_hex_str_to_byte_array ( const char * hex_str,
uint8_t output_byte_array[],
uint16_t output_byte_array_size,
uint16_t * output_byte_array_len )

Converts a hex string to a byte array.

Parameters
hex_strThe input hex string. Can be upper or lower case. Can contain spaces and underscores between bytes.
output_byte_arrayPointer to the output destination byte array.
output_byte_array_sizeMaximum size of the output byte array.
output_byte_array_lenPointer to the output variable that will be set to the length of the output byte array.
Returns
0 if successful, >0 for error
Note
Delimiters between bytes are ignored, but delimiters within a byte are not allowed.

◆ GEN_int64_to_str()

void GEN_int64_to_str ( int64_t value,
char * buffer )

Converts an int64_t to a string.

Parameters
valueThe input value to convert.
bufferThe output buffer to write the string to. MUST BE AT LEAST 21 BYTES LONG.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GEN_uint64_to_padded_str()

void GEN_uint64_to_padded_str ( uint64_t value,
uint8_t padding_len,
char * buffer )

Converts a uint64_t to a string, with leading zeros.

Parameters
valueThe input value to convert.
padding_lenThe expected length of the output string.
bufferThe output buffer to write the string to. Must be padding_len bytes long.
Here is the caller graph for this function:

◆ GEN_uint64_to_str()

void GEN_uint64_to_str ( uint64_t value,
char * buffer )

Converts a uint64_t to a string.

Parameters
valueThe input value to convert.
bufferThe output buffer to write the string to. MUST BE AT LEAST 21 BYTES LONG.
Here is the caller graph for this function: