Skip to content

sendCTRL

Christopher Teubert edited this page Sep 21, 2015 · 5 revisions
      Sets control surface information on the specified aircraft.

In the C client, the psendCTRL function omits the ac parameter and sets the control information of the player aircraft.

In other clients, the ac parameter is optional and defaults to 0 (the player aircraft).

Syntax

Language Signature
C int sendCTRL(XPCSocket sock, float values[], int size, char ac)
MATLAB sendCTRL( values, ac, socket )
Java void sendCTRL(float[] values, int ac)
Python sendCTRL(self, values, ac = 0)
Parameters

sock (C): The socket used to send the command.

values: The control surface values to set. values is a array containing up to 6 elements. If less than 6 elements are specified or any elment is set to -998, those values will not be changed. The elements in values corespond to the following:

  • Latitudinal Stick [-1,1]
  • Longitudinal Stick [-1,1]
  • Rudder Pedals [-1, 1]
  • Throttle [0, 1]
  • Gear (0=up, 1=down)
  • Flaps [0, 1]

size (C): The number of elements in values.

ac: The aircraft to set the control surfaces of. 0 is the main/player aircraft.

socket (MATLAB): An optional reference to a socket opened with openUDP that should be used to send the command.

Return value

C: A negative value if an error occurs, otherwise 0.

Exceptions

C Error Code Java Exception Python Error Description
-1 IllegalArgumentException ValueError The specified aircraft number is invalid
-2 IllegalArgumentException ValueError The number of values specified is too large
-3 IOException OSError The client was unable to send the command

Examples

C
#include "xplaneConnect.h"

XPCSocket sock = aopenUDP("127.0.0.1", 49007);

// Set control surfaces for level flight
float values[] = {0.0F, 0.0F, 0.0F, 0.8F, 0.0F, 0.0F};
sendCTRL(sock, values, 6, 0);

closeUDP(sock);

MATLAB

import XPlaneConnect.*

% Set control surfaces for level flight
values = [0.0F, 0.0F, 0.0F, 0.8F, 0.0F, 0.0F];
sendCTRL(values, 0);
Java
import gov.nasa.xpc.XPlaneConnect;

try(XPlaneConnect xpc = new XPlaneConnect())
{
    // Set control surfaces for level flight
    float values[] = {0.0F, 0.0F, 0.0F, 0.8F, 0.0F, 0.0F};
    xpc.sendCTRL(values, 0);
}

Python

import xpc

with xpc.XPlaneConnect() as client:
    # Set control surfaces for level flight
    values = [0.0F, 0.0F, 0.0F, 0.8F, 0.0F, 0.0F]
    client.sendCTRL(values)