#include <map>
#include <string>
using namespace trek;
typedef std::map< std::string, CommandResponse * > CMD_RESP_MAP;
int main(void)
{
int32_t ret_value;
if( ret_value )
{
printf( "Error %d: Could not connect to destination.\n", ret_value );
return 1;
}
if( ret_value )
{
printf( "Error %d: Could not get status message list.\n", ret_value );
return 1;
}
printf(
"There are %u status messages for this destination.\n", status_list.
Size() );
for( uint32_t ii = 0; ii < status_list.
Size(); ii++ )
{
printf(
"Status Message: %s\n", status_list.
GetAt(ii) );
char info[1024];
uint32_t info_space = 1024;
pc,
info,
&info_space );
if( ret_value )
{
printf(
"Error %d: Could not retrieve status message %s.\n", ret_value, status_list.
GetAt(ii) );
}
else
{
for( uint32_t jj = 0; jj < param_list.
Size(); jj++ )
{
if( ret_value )
printf(
"Error %d: Unexpected error when finding parameter %s.\n", ret_value, param_list.
GetAt(jj) );
else
}
}
}
if( ret_value )
{
printf( "Error %d: Could not get command response list.\n", ret_value );
return 1;
}
CMD_RESP_MAP response_map;
for( uint32_t ii = 0; ii < resp_list.
Size(); ii++ )
{
*cmd_response_ptr );
if( ret_value )
{
printf(
"Error %d: Could not retrieve response %s.\n", ret_value, resp_list.
GetAt(ii) );
}
else
response_map[resp_list.
GetAt(ii)] = cmd_response_ptr;
}
uint32_t token;
if( ret_value )
printf( "Error %d: Could not initiate command.\n", ret_value );
ret_value = api.
GetTrack( token, track_item );
if( ret_value )
printf( "Error %d: Could not track command.\n", ret_value );
else
{
{
response_item resp_item;
CMD_RESP_MAP::iterator response_map_it;
response_map_it = response_map.find( resp_item.name );
if( response_map_it != response_map.end() )
{
struct response_info resp_info;
response_map_it->second->GetErrorDetails( resp_item.value, &resp_info );
printf( "Response %s: %s.\n", resp_item.name, resp_info.info );
}
}
}
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
Provides access to command features of TReK.
Definition: command_api.h:34
int32_t GetCommandResponse(const char *name, CommandResponse &resp)
Get the details for a command response.
Definition: command_api.cpp:1606
int32_t GetCommandResponseList(StringArray &resp_list)
Get a list of possible command responses for the command source.
Definition: command_api.cpp:1522
int32_t GetTrack(uint32_t token, TrackItem &track_item)
Find out any command track information for this 'token'.
Definition: command_api.cpp:2610
int32_t GetStatusMessageList(StringArray &status_list)
Get a list of messages that the user can send.
Definition: command_api.cpp:852
int32_t GetStatusMessage(const char *name, ParameterCollection &pc, char *info, uint32_t *space_available)
Get the specified status message details.
Definition: command_api.cpp:944
int32_t InitiateCommand(const char *name, uint32_t &token)
Sends a request to the final destination to uplink a command.
Definition: command_api.cpp:2516
This class holds all of the responses associated with a single command uplink.
Definition: command_response.h:28
This class describes a parameter collection composed of one or more parameters.
Definition: parameter_collection.h:24
virtual int32_t FindParameter(const char *name, Parameter **param_ptr)
Finds the specified parameter in the collection.
Definition: parameter_collection.cpp:423
virtual void GetSortedParameterList(StringArray ¶m_list, bool full_name=true, bool mod_only=false)
Returns a list of all parameters within a collection sorted by their start location.
Definition: parameter_collection.cpp:713
This class describes a single parameter within a telemetry or command message including its value.
Definition: parameter.h:95
const char * GetValueAsString(uint16_t sample_number=1)
Returns the value of the parameter as a string.
Definition: parameter.cpp:11511
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
This class holds all of the responses associated with a single command uplink. Only methods that are ...
Definition: track_item.h:30
uint32_t GetNumberOfResponses()
Returns the number of responses available.
Definition: track_item.cpp:118
int32_t GetResponse(uint32_t index, struct response_item &item)
Gets the information about the specified response as a structure.
Definition: track_item.cpp:140
Defines the trek::CommandApi class.
Defines the trek::CommandResponse class.
Defines the trek::Packet class.
Defines the trek::ParameterCollection class.
Defines the trek::StringArray class.
Defines the trek::TrackItem class.