c_tlm_stream.h File Reference

Telemetry stream and decode. More...

#include "c_tlm_comp.h"
#include <stdio.h>
Include dependency graph for c_tlm_stream.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* stream_callback_type) (const char *str, void *arg)
 

Functions

void tlm_stream_one (tlm_component *comp, stream_callback_type stream, void *print_ascii, void *arg)
 
void tlm_stream_all (stream_callback_type stream_func, void *arg, bool ascii)
 
void tlm_stream_one_file (tlm_component *comp_ptr, FILE *file)
 
void tlm_stream_all_file (FILE *file)
 
bool tlm_stream_decode_file (FILE *file)
 

Detailed Description

Telemetry stream and decode.

Telemetry stream sends encoded ASCII data stream to the provided stream function. Example stream :

 START:my_component:3
 a:4:1:1:DE,AD,BE,EF
 b:2:1:1:02,00
 c:1:1:1:11
 END:my_component

Typedef Documentation

typedef void(* stream_callback_type) (const char *str, void *arg)

Each stream starts with the tag START and ends with END After the colon is the name of the component and then the number of variables registered in this component. Then the variables' data follows :

  • The name of the variable
  • Number of bytes per variable
  • Number of elements per array (1 for a single variable)
  • Variable type.
    See also
    tlm_type at c_tlm_var.h
  • HEX bytes

Telemetry decode will do the opposite. It will decode an incoming stream, and based on the stream, it will find the component and the registered variable and set the value of the variable based on the stream. This functionality can be used to take a saved data stream, and set the variables' data value based on the stream. In particular, the registered variables' values can be restored based on a previously saved telemetry stream from a disk etc.

Here is an example of saving the stream into a C++ string :

1 void string_stream(const char* s, void *arg) {
2  std::string *str = (std::string*)arg;
3  (*str) += s;
4 }
5 
6 std::string str = "";
7 tlm_stream_one(my_comp, string_stream, &str);

Typedef of the stream callback function

Parameters
strThe ASCII string containing partial stream

Function Documentation

void tlm_stream_all ( stream_callback_type  stream_func,
void *  arg,
bool  ascii 
)

Streams the telemetry for ALL registered components and their variables

Parameters
stream_funcThe callback stream function that will receive the strings to print
argThis argument will be passed to your stream function as its argument
asciiIf true, ASCII values are printed, rather than hex value of the data
void tlm_stream_all_file ( FILE *  file)

Streams all components to a file

Parameters
fileCould be stdout, stderr, or an opened file handle Example: To printf the telemetry, just use "tlm_stream_all_file(stdio);"
bool tlm_stream_decode_file ( FILE *  file)

This is similar to tlm_stream_decode(char*) except that it decodes stream from an opened file handle. The file will be read until fgets() fails.

Returns
true when telemetry decode finds correct stream header.
void tlm_stream_one ( tlm_component comp,
stream_callback_type  stream,
void *  print_ascii,
void *  sca 
)

Streams the telemetry for one component and its variables

Parameters
streamThe callback stream function that will receive the strings to print
print_asciiIf non-null, the data will be printed as ASCII values rather than hex values
argThis argument will be passed to your stream function as its argument

Callback function for each component

Parameters
scaStream callback argument
void tlm_stream_one_file ( tlm_component comp_ptr,
FILE *  file 
)

Streams your provided component telemetry into a file pointer

Parameters
comp_ptrThe telemetry component pointer
fileCould be stdout, stderr, or an opened file handle