#include <stdio.h>
using namespace trek;
int main()
{
uint8_t buf[4096];
uint32_t buf_len;
uint32_t token = 0;
uint32_t last_token = 0;
int ret_value;
int next_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 definition.\n", ret_value );
return 1;
}
if( ret_value )
{
printf( "Error %d: Could not register for packet semaphore. Is the key correct?\n", ret_value );
return 1;
}
uint32_t event_triggered = 0;
do
{
do
{
buf_len = 4096;
next_ret_value = tlm_api.
GetNextPacket(
"PdssPayload.RT.PL.7", token, buf, buf_len );
{
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 );
}
else
{
if( last_token == token )
{
}
else
{
last_token = token;
printf( "Printing all parameter values\n" );
}
}
}
else
{
printf( "Error %d: Could not get the next packet.\n", ret_value );
}
if( ret_value )
{
printf( "Error %d: Error when attempting to wait for packet.\n", ret_value );
}
event_triggered++;
} while( event_triggered < 100 );
if( ret_value )
{
printf( "Error %d: Could not unregister packet semaphore.\n", ret_value );
return 1;
}
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:131
int32_t Disconnect()
Disconnects from the destination.
Definition: api_client.cpp:344
int32_t Cleanse()
Cleans up any resources from crashed user programs.
Definition: api_client.cpp:469
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
const char * PrintValues()
Returns a string with the value of all parameters in the packet.
Definition: packet.cpp:2898
This class provides a wrapper for std::vector and std::string so different versions of the standard t...
Definition: string_array.h:19
Provides access to telemetry features of TReK.
Definition: telemetry_api.h:44
int32_t RegisterPacketSemaphore(const char *pkt_key)
Registers a semaphore to be signaled when a packet arrives.
Definition: telemetry_api.cpp:706
int32_t GetNextPacket(const char *pkt_key, uint32_t &token, uint8_t *buf, uint32_t &len)
Gets a copy of the next packet available from the data store.
Definition: telemetry_api.cpp:502
int32_t GetPacketDefinition(const char *pkt_key, Packet &pkt)
Retrieve the Packet definition for the specified key.
Definition: telemetry_api.cpp:296
int32_t WaitForPacket(const char *pkt_key, uint32_t timeout=0)
Waits for the specified packet to arrive.
Definition: telemetry_api.cpp:823
int32_t UnregisterPacketSemaphore(const char *pkt_key)
Unregisters the packet arrival semaphore.
Definition: telemetry_api.cpp:1104
Defines the trek::Packet class.
Defines the trek::Parameter class.
Defines the trek::TelemetryApi class.
Error codes for the Telemetry API (starts at 28001)
#define TLM_API_MORE_DATA_AVAILABLE
(Considered Success) The function completed successfully and you can make another call to get even mo...
Definition: telemetry_api_error_codes.h:38
#define TLM_API_MISSING_DATA
(Considered Success) Some of the requested data was missing. Oldest available data returned.
Definition: telemetry_api_error_codes.h:37
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8