#include <stdio.h>
using namespace trek;
int main()
{
uint8_t buf[4096];
uint32_t buf_len;
uint32_t token = 0;
int ret_value;
ret_value = tlm_api.
Connect(
"DefaultDataStore");
if( ret_value )
{
printf( "Error %d: Could not connect to data store.\n", ret_value );
return 1;
}
if( ret_value )
{
printf( "Error %d: Could not get packet list.\n", ret_value );
return 1;
}
for( uint32_t ii = 0; ii < pkt_key_list.
Size(); ii++ )
printf(
"Packet key %u: %s\n", ii+1, pkt_key_list.
GetAt(ii) );
if( ret_value )
{
printf( "Error %d: Could not get packet definition.\n", ret_value );
return 1;
}
buf_len = 4096;
ret_value = tlm_api.
GetNewestPacket(
"PdssPayload.RT.PL.7", token, buf, buf_len );
if( ret_value )
{
printf( "Error %d: Could not get the latest packet.\n", ret_value );
return 1;
}
uint32_t last_bit_used;
ret_value = pkt.
Extract( buf, buf_len, last_bit_used );
if( ret_value )
{
printf( "Error %d: Could not extract parameter data from the packet.\n", ret_value );
return 1;
}
if( ret_value )
{
printf( "Error %d: Could not find parameter.\n", ret_value );
return 1;
}
int32_t int_value;
ret_value = param_ptr->
GetValue( int_value );
if( ret_value )
{
printf( "Error %d: Could not get parameter value.\n", ret_value );
return 1;
}
printf( "Value is: %d.\n", int_value );
if( ret_value )
{
printf( "Error %d: API did not disconnect properly.\n", ret_value );
return 1;
}
return 0;
}
int32_t Connect(const char *name)
Connects this instance of the API to TReK for the specified destination.
Definition: api_client.cpp:130
int32_t Disconnect()
Disconnects from the destination.
Definition: api_client.cpp:343
int32_t Cleanse()
Cleans up any resources from crashed user programs.
Definition: api_client.cpp:468
This class describes a packet composed of one or more parameters.
Definition: packet.h:72
int32_t Extract(uint8_t *input_ptr, uint32_t input_length, uint32_t &last_bit_used)
Extracts all of the parameters in the packet from the specified buffer.
Definition: packet.cpp:1714
int32_t FindParameter(const char *name, Parameter **param_ptr)
Finds the specified parameter name in the packet.
Definition: packet.cpp:2348
This class describes a single parameter within a telemetry or command message including its value.
Definition: parameter.h:95
int32_t GetValue(int8_t &input, uint16_t sample_number=1)
Gets the value of a parameter as an 8-bit signed integer.
Definition: parameter.cpp:8546
This class provides a wrapper for std::vector and std::string so different versions of the standard t...
Definition: string_array.h:19
uint32_t Size()
Returns the number of items in the string array.
Definition: string_array.cpp:67
const char * GetAt(uint32_t index)
Returns the string at the given location.
Definition: string_array.cpp:89
Provides access to telemetry features of TReK.
Definition: telemetry_api.h:44
int32_t GetPacketDefinition(const char *pkt_key, Packet &pkt)
Retrieve the Packet definition for the specified key.
Definition: telemetry_api.cpp:296
int32_t GetNewestPacket(const char *pkt_key, uint32_t &token, uint8_t *buf, uint32_t &len)
Gets a copy of the newest packet available from the data store.
Definition: telemetry_api.cpp:396
int32_t GetSourceList(StringArray &pkt_key_list)
Gets the list of packet keys currently being processed.
Definition: telemetry_api.cpp:112
Defines the trek::Packet class.
Defines the trek::Parameter class.
Defines the trek::TelemetryApi class.