Added getPOSI and getCTRL support to the C client.
This commit is contained in:
@@ -521,6 +521,38 @@ int getDREFs(XPCSocket sock, const char* drefs[], float* values[], unsigned char
|
||||
/*****************************************************************************/
|
||||
/**** POSI functions ****/
|
||||
/*****************************************************************************/
|
||||
int getPOSI(XPCSocket sock, float values[7], char ac)
|
||||
{
|
||||
// Setup send command
|
||||
unsigned char buffer[6] = "GETP";
|
||||
buffer[5] = ac;
|
||||
|
||||
// Send command
|
||||
if (sendUDP(sock, buffer, 6) < 0)
|
||||
{
|
||||
printError("getPOSI", "Failed to send command.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get response
|
||||
unsigned char readBuffer[34];
|
||||
int readResult = readUDP(sock, readBuffer, 34);
|
||||
if (readResult < 0)
|
||||
{
|
||||
printError("getPOSI", "Failed to read response.");
|
||||
return -2;
|
||||
}
|
||||
if (readResult != 34)
|
||||
{
|
||||
printError("getPOSI", "Unexpected response length.");
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Copy response into values
|
||||
memcpy(values, readBuffer + 6, 7 * sizeof(float));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sendPOSI(XPCSocket sock, float values[], int size, char ac)
|
||||
{
|
||||
// Validate input
|
||||
@@ -565,6 +597,41 @@ int sendPOSI(XPCSocket sock, float values[], int size, char ac)
|
||||
/*****************************************************************************/
|
||||
/**** CTRL functions ****/
|
||||
/*****************************************************************************/
|
||||
int getCTRL(XPCSocket sock, float values[7], char ac)
|
||||
{
|
||||
// Setup send command
|
||||
unsigned char buffer[6] = "GETC";
|
||||
buffer[5] = ac;
|
||||
|
||||
// Send command
|
||||
if (sendUDP(sock, buffer, 6) < 0)
|
||||
{
|
||||
printError("getCTRL", "Failed to send command.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get response
|
||||
unsigned char readBuffer[31];
|
||||
int readResult = readUDP(sock, readBuffer, 31);
|
||||
if (readResult < 0)
|
||||
{
|
||||
printError("getCTRL", "Failed to read response.");
|
||||
return -2;
|
||||
}
|
||||
if (readResult != 31)
|
||||
{
|
||||
printError("getCTRL", "Unexpected response length.");
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Copy response into values
|
||||
memcpy(values, readBuffer + 5, 4 * sizeof(float));
|
||||
values[4] = readBuffer[21];
|
||||
values[5] = *((float*)(readBuffer + 22));
|
||||
values[6] = *((float*)(readBuffer + 27));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sendCTRL(XPCSocket sock, float values[], int size, char ac)
|
||||
{
|
||||
// Validate input
|
||||
|
||||
@@ -196,6 +196,14 @@ int getDREFs(XPCSocket sock, const char* drefs[], float* values[], unsigned char
|
||||
|
||||
// Position
|
||||
|
||||
/// Gets the position and orientation of the specified aircraft.
|
||||
///
|
||||
/// \param sock The socket used to send the command and receive the response.
|
||||
/// \param values An array to store the position information returned by the
|
||||
/// plugin. The format of values is [Lat, Lon, Alt, Pitch, Roll, Yaw, Gear]
|
||||
/// \returns 0 if successful, otherwise a negative value.
|
||||
int getPOSI(XPCSocket sock, float values[7], char ac);
|
||||
|
||||
/// Sets the position and orientation of the specified aircraft.
|
||||
///
|
||||
/// \param sock The socket to use to send the command.
|
||||
@@ -209,6 +217,16 @@ int sendPOSI(XPCSocket sock, float values[], int size, char ac);
|
||||
|
||||
// Controls
|
||||
|
||||
/// Gets the control surface information for the specified aircraft.
|
||||
///
|
||||
/// \param sock The socket used to send the command and receive the response.
|
||||
/// \param values An array to store the position information returned by the
|
||||
/// plugin. The format of values is [Elevator, Aileron, Rudder,
|
||||
/// Throttle, Gear, Flaps, Speed Brakes]
|
||||
/// \param ac The aircraft to set the control surfaces of. 0 is the main/player aircraft.
|
||||
/// \returns 0 if successful, otherwise a negative value.
|
||||
int getCTRL(XPCSocket sock, float values[7], char ac);
|
||||
|
||||
/// Sets the control surfaces of the specified aircraft.
|
||||
///
|
||||
/// \param sock The socket to use to send the command.
|
||||
|
||||
Reference in New Issue
Block a user