TReK .NET Framework  5.3.3
Telemetry/Command API
Command_Example/Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Command_Example
{
class Program
{
//For this program to work:
//
//add the following statment above: using trek
//add this reference file to your project: trek_command_dotnet_api.dll
//don't forget to add the other DLLs in the folder with your .exe file
static void Main(string[] args)
{
//This is a simple program to send a command.
//Uncomment one function at a time, then Run Application
var callFunction = new Program();
callFunction.Uplink_POIC_Command();
//callFunction.Build_and_Uplink_POIC_Command();
//callFunction.Uplink_User_Command();
}
public void Uplink_POIC_Command()
{
//Create and initialize variables
int return_code = 0; // Return code from TReK API
string destination = "test"; // Set Destination Name as shown in the Command Application
string command_name = "TEST_SWITCH"; // Set Command mnemonic as shown in the Command Application
//Make call to the command application
return_code = trek_cmd_user_api.Uplink_POIC_Command(destination, command_name);
//Check return to see if command sent successfully
if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_SUCCESS)
{
Console.WriteLine("Command successfully sent: {0}", return_code);
}
//Check return to see if command failed
else
{
Console.WriteLine("Error sending command: {0}", return_code);
}
Console.ReadKey();
}
public void Build_and_Uplink_POIC_Command()
{
//Create and initialize variables
int return_code = 0; // Return code from TReK API
string destination = "POIC"; // Set Destination Name as shown in the Command Application
string command_name = "CAMERA_MODE"; // Set Command mnemonic as shown in the Command Application
//Make call to the command application
return_code = trek_cmd_user_api.Build_And_Uplink_Command(destination, command_name);
//Check return to see if command sent successfully
if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_SUCCESS)
{
Console.WriteLine("Command built and uplinked\n");
}
else if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_DESTINATION_NOT_FOUND)
{
Console.WriteLine("Error destination not found: {0}", return_code);
}
else if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_FAIL)
{
Console.WriteLine("Error sending command: {0}", return_code);
}
Console.ReadKey();
}
public void Uplink_User_Command()
{
//Create and initialize variables
int return_code = 0; // Return code from TReK API
byte[] cmd_data = new byte[40]; //a 40-byte command
string destination = "POIC"; // Set Destination Name as shown in the Command Application
string command_name = "CAMERA_MODE"; // Set Command mnemonic as shown in the Command Application
//For this example set all data to 0 except first 4 bytes
Array.Clear(cmd_data, 0, cmd_data.Length); //Zero all elements
cmd_data[0] = 0x4A;
cmd_data[1] = 0x65;
cmd_data[2] = 0x66;
cmd_data[3] = 0x66;
//Make call to the command application
return_code = trek_cmd_user_api.Uplink_User_Command(destination, command_name, cmd_data, 40);
//Check return to see if command sent successfully
if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_SUCCESS)
{
Console.WriteLine("Command successfully sent: {0}");
}
else if (return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_DESTINATION_NOT_FOUND)
{
Console.WriteLine("Error sending command: {0}", return_code);
}
else if(return_code == (int)TREK_CMD_API_RETURN_CODES.cmd_API_FAIL)
{
Console.WriteLine("Error sending command: {0}", return_code);
}
Console.ReadKey();
}
}
}