From 68e17af07069b6cbd61f2fb685005d0a0766f98c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 29 Apr 2016 09:03:48 +1000 Subject: [PATCH] SITL: allow for changing FlightAxis controller IP --- libraries/SITL/SIM_FlightAxis.cpp | 11 ++++++----- libraries/SITL/SIM_FlightAxis.h | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libraries/SITL/SIM_FlightAxis.cpp b/libraries/SITL/SIM_FlightAxis.cpp index 70064afe18..87832710f0 100644 --- a/libraries/SITL/SIM_FlightAxis.cpp +++ b/libraries/SITL/SIM_FlightAxis.cpp @@ -31,9 +31,6 @@ extern const AP_HAL::HAL& hal; -#define FLIGHTAXIS_SERVER_IP "192.168.2.48" -#define FLIGHTAXIS_SERVER_PORT 18083 - namespace SITL { // the asprintf() calls are not worth checking for SITL @@ -46,6 +43,10 @@ FlightAxis::FlightAxis(const char *home_str, const char *frame_str) : rate_hz = 250 / target_speedup; heli_demix = strstr(frame_str, "helidemix") != NULL; rev4_servos = strstr(frame_str, "rev4") != NULL; + const char *colon = strchr(frame_str, ':'); + if (colon) { + controller_ip = colon+1; + } } /* @@ -87,7 +88,7 @@ char *FlightAxis::soap_request(const char *action, const char *fmt, ...) // open SOAP socket to FlightAxis SocketAPM sock(false); - if (!sock.connect(FLIGHTAXIS_SERVER_IP, FLIGHTAXIS_SERVER_PORT)) { + if (!sock.connect(controller_ip, controller_port)) { free(req1); return nullptr; } @@ -151,7 +152,7 @@ Connection: Keep-Alive void FlightAxis::exchange_data(const struct sitl_input &input) { if (!controller_started) { - printf("Starting controller\n"); + printf("Starting controller at %s\n", controller_ip); // call a restore first. This allows us to connect after the aircraft is changed in RealFlight char *reply = soap_request("RestoreOriginalControllerDevice", R"( diff --git a/libraries/SITL/SIM_FlightAxis.h b/libraries/SITL/SIM_FlightAxis.h index 635077d5ed..719f0133a4 100644 --- a/libraries/SITL/SIM_FlightAxis.h +++ b/libraries/SITL/SIM_FlightAxis.h @@ -155,6 +155,9 @@ private: uint64_t activation_frame_counter = 0; double last_frame_count_s = 0; Vector3f position_offset; + + const char *controller_ip = "127.0.0.1"; + uint16_t controller_port = 18083; };