c_tlm_var.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "c_tlm_var.h"
Include dependency graph for c_tlm_var.c:

Macros

#define tlm_variable_set_value_find_next_token(value)
 
#define tlm_variable_print_array(format, var, buffer)
 

Functions

bool tlm_variable_register (tlm_component *comp_ptr, const char *name, const void *data_ptr, const uint16_t data_size, const uint16_t arr_size, tlm_type type)
 
const tlm_reg_var_typetlm_variable_get_by_name (tlm_component *comp_ptr, const char *name)
 
const tlm_reg_var_typetlm_variable_get_by_comp_and_name (const char *comp_name, const char *name)
 
bool tlm_variable_set_value (const char *comp_name, const char *name, const char *value)
 
bool tlm_variable_get_value (const char *comp_name, const char *name, char *buffer, int len)
 
bool tlm_variable_print_value (const tlm_reg_var_type *reg_var, char *buffer, int len)
 

Macro Definition Documentation

#define tlm_variable_print_array (   format,
  var,
  buffer 
)
Value:
for ( i=1; i < reg_var->elm_arr_size; i++) { \
++var; \
size_t curr_len = strlen(buffer); \
snprintf(buffer+curr_len, len-curr_len, format, *data); \
} do{ } while(0)
unsigned int unsigned int len
Definition: startup.cpp:197
To use the FreeRTOS so play with it a little *uses roughly of and uses roughly of RAM *The larger the the larger recording buffer *You can choose ring buffer
Definition: readme.txt:4
#define tlm_variable_set_value_find_next_token (   value)
Value:
while (0 != *value) { \
if (',' == *value) { \
++value; \
break; \
} else { \
++value; \
} }

Function Documentation

const tlm_reg_var_type* tlm_variable_get_by_comp_and_name ( const char *  comp_name,
const char *  name 
)

Get the data pointer and the size of a previously registered variable. The tlm_reg_var_type structure contains the pointer and the size.

Parameters
comp_nameThe component name that contains the variable
nameThe registered name of the variable
const tlm_reg_var_type* tlm_variable_get_by_name ( tlm_component comp_ptr,
const char *  name 
)

Get the data pointer and the size of a previously registered variable. The tlm_reg_var_type structure contains the pointer and the size.

Parameters
comp_ptrThe component pointer that contains the variable
nameThe registered name of the variable
bool tlm_variable_get_value ( const char *  comp_name,
const char *  name,
char *  buffer,
int  len 
)

Gets a value to one of the telemetry variables

Parameters
comp_nameThe name of the component (this will be located by name)
nameThe name of the registered variable
bufferThe buffer at which to print the data
lenThe length of the buffer
bool tlm_variable_print_value ( const tlm_reg_var_type reg_var,
char *  buffer,
int  len 
)

Prints the value of the given variable

Parameters
reg_varA registered variable, possibly obtained from tlm_variable_get_by_name()
bufferThe buffer at which to print the data
lenThe length of the buffer
Returns
true upon success
bool tlm_variable_register ( tlm_component comp_ptr,
const char *  name,
const void *  data_ptr,
const uint16_t  data_size,
const uint16_t  arr_size,
tlm_type  type 
)

Adds a variable to a component.

Parameters
comp_ptrThe component pointer
nameThe name of the variable
data_ptrThe data pointer of the variable
data_sizeThe size of the variable
arr_sizeIf not an array, use zero. If registering an array, use the number of elements in the array.
typeThe type of the variable.
Returns
true upon success. If memory allocation fails, or if another variable is registered by the same name or same memory pointer, false is returned.
bool tlm_variable_set_value ( const char *  comp_name,
const char *  name,
const char *  value 
)

Sets a value to one of the telemetry variables. This is sort of a back-door way to force a value to the telemetry variable.

Parameters
comp_nameThe name of the component (this will be located by name)
nameThe name of the registered variable
valueThe string value. For example, to set an integer, just pass string value such as "123". To set boolean value, use "true" or "false"