c_tlm_var.h File Reference
#include "c_list.h"
#include "c_tlm_comp.h"
Include dependency graph for c_tlm_var.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tlm_reg_var_type
 

Macros

#define TLM_REG_VAR(comp, var, type)   tlm_variable_register(comp, #var, &var, sizeof(var), 1, type)
 
#define TLM_REG_ARR(comp, var, type)   tlm_variable_register(comp, #var, &var[0], sizeof(var[0]), sizeof(var)/sizeof(var[0]), type)
 

Enumerations

enum  tlm_type {
  tlm_undefined = 0, tlm_int = 1, tlm_uint = 2, tlm_char = 3,
  tlm_float = 4, tlm_double = 5, tlm_string = 6, tlm_binary = 7,
  tlm_bit_or_bool = 8
}
 

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)
 

Detailed Description

This file allows variables to be registered under a component.

See also
Sample code of c_tlm_comp.h

Macro Definition Documentation

#define TLM_REG_ARR (   comp,
  var,
  type 
)    tlm_variable_register(comp, #var, &var[0], sizeof(var[0]), sizeof(var)/sizeof(var[0]), type)

Macro to register an array.

#define TLM_REG_VAR (   comp,
  var,
  type 
)    tlm_variable_register(comp, #var, &var, sizeof(var), 1, type)

Macro to register a variable. If a variable is called "var", then this macro will yield : tlm_variable_register(comp, "var", &var, sizeof(var), 1);

Enumeration Type Documentation

enum tlm_type

The type of the variable. This can be used by a telemetry decoder to print-out the data in human readable format.

Enumerator
tlm_undefined 
tlm_int 
tlm_uint 
tlm_char 
tlm_float 
tlm_double 
tlm_string 
tlm_binary 
tlm_bit_or_bool 

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"