Index: trunk/ReleaseNotes
===================================================================
--- trunk/ReleaseNotes	(revision 413)
+++ trunk/ReleaseNotes	(revision 414)
@@ -1,3 +1,5 @@
 * Actual Version:
+
+- added possibility to autodetect gcs ip when using autodetect as address parameter, see demos. This only works when ssh connected to a target (not in simulation)
 
 -----------------------------------------------------------
Index: trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_ardrone2.sh
===================================================================
--- trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_ardrone2.sh	(revision 413)
+++ trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_ardrone2.sh	(revision 414)
@@ -1,1 +1,1 @@
-./CircleFollower_nrt -a 192.168.147.193 -p 9000 -l /tmp -x CircleFollower_ardrone2.xml -n Drone_0 -t ardrone2
+./CircleFollower_nrt -a autodetect -p 9000 -l /tmp -x CircleFollower_ardrone2.xml -n Drone_0 -t ardrone2
Index: trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_bebop.sh
===================================================================
--- trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_bebop.sh	(revision 413)
+++ trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_bebop.sh	(revision 414)
@@ -1,1 +1,1 @@
-./CircleFollower_nrt -a 192.168.42.24 -p 9000 -l /tmp -x CircleFollower_bebop.xml -n Drone_0 -t bebop
+./CircleFollower_nrt -a autodetect -p 9000 -l /tmp -x CircleFollower_bebop.xml -n Drone_0 -t bebop
Index: trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_hdsx8.sh
===================================================================
--- trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_hdsx8.sh	(revision 413)
+++ trunk/demos/CircleFollower/uav/resources/armv7a-neon/CircleFollower_hdsx8.sh	(revision 414)
@@ -1,1 +1,1 @@
-./CircleFollower_rt -a 192.168.147.217 -p 9000 -l /tmp -x CircleFollower_hdsx8.xml -n x8_0 -t hds_x8
+./CircleFollower_rt -a autodetect -p 9000 -l /tmp -x CircleFollower_hdsx8.xml -n x8_0 -t hds_x8
Index: trunk/demos/DemoGps/uav/resources/armv7a-neon/Gps_bebop.sh
===================================================================
--- trunk/demos/DemoGps/uav/resources/armv7a-neon/Gps_bebop.sh	(revision 413)
+++ trunk/demos/DemoGps/uav/resources/armv7a-neon/Gps_bebop.sh	(revision 414)
@@ -1,1 +1,1 @@
-./DemoGps_nrt -a 192.168.42.24 -p 9000 -l /tmp -x Gps_bebop.xml -n Drone_0 -t bebop
+./DemoGps_nrt -a autodetect -p 9000 -l /tmp -x Gps_bebop.xml -n Drone_0 -t bebop
Index: trunk/demos/DemoOpticalFlow/uav/resources/armv7a-neon/OpticalFlow_ardrone2.sh
===================================================================
--- trunk/demos/DemoOpticalFlow/uav/resources/armv7a-neon/OpticalFlow_ardrone2.sh	(revision 413)
+++ trunk/demos/DemoOpticalFlow/uav/resources/armv7a-neon/OpticalFlow_ardrone2.sh	(revision 414)
@@ -1,1 +1,1 @@
-./DemoOpticalFlow_nrt -a 192.168.147.217 -p 9000 -l /tmp -x OpticalFlow_ardrone2.xml -n Drone_0 -t ardrone2 -v ./dspcv_dsp.out
+./DemoOpticalFlow_nrt -a autodetect -p 9000 -l /tmp -x OpticalFlow_ardrone2.xml -n Drone_0 -t ardrone2 -v ./dspcv_dsp.out
Index: trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_ardrone2.sh
===================================================================
--- trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_ardrone2.sh	(revision 413)
+++ trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_ardrone2.sh	(revision 414)
@@ -1,1 +1,1 @@
-./MixedReality_uav_real_nrt -a 192.168.147.193 -p 9000 -l /tmp -x MixedReality_ardrone2.xml -n Drone_0 -t ardrone2
+./MixedReality_uav_real_nrt -a autodetect -p 9000 -l /tmp -x MixedReality_ardrone2.xml -n Drone_0 -t ardrone2
Index: trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_bebop.sh
===================================================================
--- trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_bebop.sh	(revision 413)
+++ trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_bebop.sh	(revision 414)
@@ -1,1 +1,1 @@
-./MixedReality_uav_real_nrt -a 192.168.42.24 -p 9000 -l /tmp -x MixedReality_bebop.xml -n Drone_0 -t bebop
+./MixedReality_uav_real_nrt -a autodetect -p 9000 -l /tmp -x MixedReality_bebop.xml -n Drone_0 -t bebop
Index: trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_hdsx8.sh
===================================================================
--- trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_hdsx8.sh	(revision 413)
+++ trunk/demos/MixedReality/real/uav/resources/armv7a-neon/MixedReality_hdsx8.sh	(revision 414)
@@ -1,1 +1,1 @@
-./MixedReality_uav_real_rt -a 192.168.147.217 -p 9000 -l /tmp -x MixedReality_hdsx8.xml -n x8_0 -t hds_x8
+./MixedReality_uav_real_rt -a autodetect -p 9000 -l /tmp -x MixedReality_hdsx8.xml -n x8_0 -t hds_x8
Index: trunk/demos/PidStandalone/uav/resources/armv7a-neon/demo_pid_ardrone2.sh
===================================================================
--- trunk/demos/PidStandalone/uav/resources/armv7a-neon/demo_pid_ardrone2.sh	(revision 413)
+++ trunk/demos/PidStandalone/uav/resources/armv7a-neon/demo_pid_ardrone2.sh	(revision 414)
@@ -1,1 +1,1 @@
-./PidStandalone_nrt -a 192.168.147.192 -p 9000 -l /tmp -x reglages_ardrone2.xml -n Drone_0 -t ardrone2
+./PidStandalone_nrt -a autodetect -p 9000 -l /tmp -x reglages_ardrone2.xml -n Drone_0 -t ardrone2
Index: trunk/demos/SimpleFleet/uav/resources/armv7a-neon/SimpleFleet.sh
===================================================================
--- trunk/demos/SimpleFleet/uav/resources/armv7a-neon/SimpleFleet.sh	(revision 413)
+++ trunk/demos/SimpleFleet/uav/resources/armv7a-neon/SimpleFleet.sh	(revision 414)
@@ -1,1 +1,1 @@
-./SimpleFleet_nrt -a 192.168.147.193 -p 9000 -l /tmp -x SimpleFleet_ardrone2.xml -n Drone_0 -t ardrone2 -b 172.26.223.255:20010
+./SimpleFleet_nrt -a autodetect -p 9000 -l /tmp -x SimpleFleet_ardrone2.xml -n Drone_0 -t ardrone2 -b 172.26.223.255:20010
Index: trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 413)
+++ trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 414)
@@ -221,4 +221,8 @@
     return;
   }
+  if(address=="autodetect") {
+    Printf("autodetecting gcs ip address based on ssh connection\n");
+    address=AutoDetectGCS(); 
+  }
   this->address=address;
   this->port=port;
@@ -246,4 +250,20 @@
   gcs_watchdog = new Watchdog(this, std::bind(&FrameworkManager_impl::SetConnectionLost, this),watchdogTimeout);
   gcs_watchdog->Start();
+}
+
+string FrameworkManager_impl::AutoDetectGCS(void) {
+    FILE *fp;
+    char result[15];
+
+    //get only first result and remove line feed
+    fp = popen("who | awk '{ print $7; }' | head -n 1 | tr -d '\n'", "r");
+    if (fp == NULL) {
+        Err("Failed to run autodetect command\n" );
+    }
+
+    fgets(result, sizeof(result), fp);
+    pclose(fp);
+    
+    return result;
 }
 
@@ -295,4 +315,10 @@
 // it switches back to RT in ProcessXML when mutex are locked
 void FrameworkManager_impl::Run(void) {
+    
+  if (self->ErrorOccured() == true) {
+    return ;
+  }
+
+
   while (!ToBeStopped()) {
     ssize_t bytesRead;
Index: trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h	(revision 413)
+++ trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h	(revision 414)
@@ -90,4 +90,5 @@
   void SaveXmlChange(char *buf);
   void SaveXml(void);
+  std::string AutoDetectGCS(void);
   size_t rcv_buf_size;
   char *rcv_buf;
