Remote control interface protocol for external control


  1. Overview
  2. Configuring external control
  3. Protocol commands



To understand the protocol and be able to avoid pitfalls, please read "General information" before attempting to build packets.
Go to top

Overview

The CLS system consisting of yokes / cyclics and pedals is intended to be used over CLS2Sim with supported flight simulation software.
If unsupported software is used, CLS2Sim has no way of communicating the steering values to the simulation.
Remote Control allows a 3rd-party application to define directional force on all axes of the CLS hardware, while receiving position information for said axes.
Using this, unsupported software can communicate with CLS2Sim and its hardware over a 3rd-party application.

Go to top

Configuration

To use this feature. "External Control" in the connection settings window must be checked.
All other commands as well as all other CLS2Sim functionality will be deactivated!




If external control is active, the main window will look like the image below.



Active/Passive mode

Axes that have their checkboxes checked are on active mode, the others are passive.

Active axes will use received forces to actively move into a direction defined by using positive or negative values for force.

Passive axes will want to remain at their position and use received forces to set their friction. (example: Collective)

Go to top

Protocol

Packet format

CLS external control for single seat


Request

Command
Type: Int32
Axis Forces
Type: Int32[4]
0xAF : External Control Single Seat [0]: elevator force pilot
[1]: aileron force pilot
[2]: rudder force pilot
[3]: collective force pilot


Response

Command
Type: Int32
Axis Positions
Type: Float[4] (0 - 1.0)
0xAF : External Control Single Seat [0]: elevator position pilot
[1]: aileron position pilot
[2]: rudder position pilot
[3]: collective position pilot


CLS external control for dual seat


Request

Command
Type: Int32
Axis Forces
Type: Int32[8]
0xAE : External Control Dual Seat [0]: elevator force pilot
[1]: elevator force copilot
[2]: aileron force pilot
[3]: aileron force copilot
[4]: rudder force pilot
[5]: rudder force copilot
[6]: collective force pilot
[7]: collective force copilot


Response

Command
Type: Int32
Axis Positions
Type: Float[8] (0 - 1.0)
0xAE : External Control Dual Seat [0]: elevator position pilot
[1]: elevator position copilot
[2]: aileron position pilot
[3]: aileron position copilot
[4]: rudder position pilot
[5]: rudder position copilot
[6]: collective position pilot
[7]: collective position copilot

Example python script for using dual seat external control

"""
Copyright 2017 Brunner Elektronik AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------------------------------

CLS2Sim 3.20 or newer required.
Python 3.X required.

Example script to demonstrate external control mode in a dual seat setup.

For packet information see:
https://cls2sim.brunner-innovation.swiss/RCInterface.htm
https://cls2sim.brunner-innovation.swiss/externalcontrol.htm
"""

import socket
import struct
import time

timeout = 8

# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Set TTL to 5 to allow jumping over routers
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 5)

# Set socket timeout
sock.settimeout(timeout)

# IP address of machine running CLS2Sim
host = '127.0.0.1'
# Default UDP port configured in CLS2Sim
port = 15090

# Initialize variables
force = [0,0,0,0,0,0,0,0]
pos = [0,0,0,0,0,0,0,0]

# set maximum force
maxForce = 2000

# main loop
while True:
# calculate new forces
for i in range(0,8):
force[i] = int((pos[i] - 0.5) * maxForce * 2)

# Construct a packet consisting of one unsigned integer (command) and 8 signed integers (force data)
request = struct.pack('<Iiiiiiiii', 0xAE, force[0], force[1], force[2], force[3], force[4], force[5], force[6], force[7]), (host, port)
# Send packet
sock.sendto(request)

# Receive response
response, address = sock.recvfrom(8192)
# Read current positions from response, one unsigned integer(command) and 8 floats (position data)
result, pos[0], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6], pos[7] = struct.unpack('<Iffffffff', response)

# Print force for aileron pilot and aileron copilot axes
print(force[2], force[3])

# wait at least 1 ms
time.sleep(0.001)

©,2017 Brunner Elektronik AG
CH-8335 Hittnau 
http://www.brunner-innovation.swiss