From b226287cec6f69e88f21f002c2a484cf62df4d7c Mon Sep 17 00:00:00 2001
From: Tommy Persson <tommy.persson@liu.se>
Date: Fri, 30 Aug 2019 15:37:51 +0200
Subject: [PATCH] AdPort spec now working all the time.

---
 README.md       | 4 ----
 src/axis_imu.cc | 8 ++++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 4468e59..4b073b9 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,6 @@ Usage:
 rosrun axis_imu axis_imu _frame_id:=imu_frame _rate:=100 _root_passwd:=pass _camera_ip:=192.168.7.205 _driver_ip:=192.168.7.160 _port:=5000 _pos_enabled:=0
 ```
 
-The port specification only works the first time.  To get it to work
-again go to the app section in the camera and stop and start the
-motionloggerudp app.
-
 The orientation is not filled in since I do not get sensible values
 from my camera. The POSITION is really the pan tilt value so should
 not be used as imu rotaation.
diff --git a/src/axis_imu.cc b/src/axis_imu.cc
index 9433ce3..d8335db 100644
--- a/src/axis_imu.cc
+++ b/src/axis_imu.cc
@@ -307,13 +307,13 @@ int main(int argc, char *argv[]) {
   curl = curl_easy_init();
 
   if (curl) {
-    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
     /* example.com is redirected, so we tell libcurl to follow redirection */ 
     curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
     //    curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
     curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
     curl_easy_setopt(curl, CURLOPT_USERNAME, "root");
     curl_easy_setopt(curl, CURLOPT_PASSWORD, root_passwd.c_str());
+    curl_easy_setopt(curl, CURLOPT_URL, stopurl.c_str());
  
     /* Perform the request, res will get the return code */ 
     res = curl_easy_perform(curl);
@@ -325,9 +325,9 @@ int main(int argc, char *argv[]) {
       ROS_INFO("Curl call succeeded");
     }
 
-#if 0
-    sleep(3);
+    //sleep(3);
     curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+    res = curl_easy_perform(curl);    
     /* Check for errors */ 
     if(res != CURLE_OK) {
       fprintf(stderr, "curl_easy_perform() failed: %s\n",
@@ -335,7 +335,7 @@ int main(int argc, char *argv[]) {
     } else {
       ROS_INFO("Curl call succeeded");
     }
-#endif    
+
     /* always cleanup */ 
     curl_easy_cleanup(curl);
   } else {
-- 
GitLab