Index: trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 186)
+++ trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 213)
@@ -141,5 +141,5 @@
 void FrameworkManager_impl::ConnectionLost(void) {
   Err("connection lost\n");
-  gcs_watchdog->SafeStop();
+  if(gcs_watchdog!=NULL) gcs_watchdog->SafeStop();
   connection_lost = true;
 }
@@ -148,5 +148,4 @@
   // Printf("destruction FrameworkManager_impl\n");
   int status;
-	char errorMsg[256];
 	
   SafeStop();
@@ -162,8 +161,10 @@
     status = DeletePipe(&cmd_pipe);
     if (status != 0) {
+      char errorMsg[256];
       Err("Error deleting pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     }
     status = DeletePipe(&data_pipe);
     if (status != 0) {
+      char errorMsg[256];
       Err("Error deleting pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     }
@@ -172,4 +173,5 @@
     status = rt_heap_delete(&log_heap);
     if (status != 0) {
+      char errorMsg[256];
       Err("rt_heap_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     }
@@ -237,7 +239,5 @@
   // watchdog for connection with ground station
   connection_lost = false;
-  gcs_watchdog = new Watchdog(
-      this, std::bind(&FrameworkManager_impl::ConnectionLost, this),
-      watchdogTimeout);
+  gcs_watchdog = new Watchdog(this, std::bind(&FrameworkManager_impl::ConnectionLost, this),watchdogTimeout);
   gcs_watchdog->Start();
 }
@@ -340,5 +340,5 @@
       }
       case WATCHDOG_HEADER: {
-        gcs_watchdog->Touch();
+        if(gcs_watchdog!=NULL) gcs_watchdog->Touch();
         break;
       }
@@ -411,6 +411,5 @@
   Printf("sending %s, size: %i\n", filename.c_str(), size);
   // send file information
-  UDT::sendmsg(file_sock, buf, sizeof(uint8_t) + sizeof(int) + name.size(), -1,
-               true);
+  UDT::sendmsg(file_sock, buf, sizeof(uint8_t) + sizeof(int) + name.size(), -1,true);
 
   more_buf = (char *)realloc((void *)buf, size);
@@ -464,11 +463,11 @@
   }
 
-    //wait end ACK
-    int nb_read = UDT::recvmsg(file_sock,&buf,1);
-    if(nb_read<0) {
+  //wait end ACK
+  int nb_read = UDT::recvmsg(file_sock,&buf,1);
+  if(nb_read<0) {
     Err("UDT::recvmsg error (%s)\n",UDT::getlasterror().getErrorMessage());
-    } else if (nb_read != 1)  {
+  } else if (nb_read != 1)  {
     Err("UDT::recvmsg error, sent %i/%i\n",nb_read,1);
-    }
+  }
 }
 
@@ -567,6 +566,5 @@
 #endif
 
-void FrameworkManager_impl::SetupLogger(string log_path) {
-  char errorMsg[256];
+void FrameworkManager_impl::SetupLogger(string log_path,uint32_t stackSize) {
 	
 	if (logger_defined == true) {
@@ -579,4 +577,5 @@
   int status = CreatePipe(&cmd_pipe, "log_cmd");
   if (status != 0) {
+    char errorMsg[256];
     Err("Error creating pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     return;
@@ -585,4 +584,5 @@
   status = CreatePipe(&data_pipe, "log_data");
   if (status != 0) {
+    char errorMsg[256];
     Err("Error creating pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     return;
@@ -592,6 +592,7 @@
   string tmp_name;
   tmp_name = self->ObjectName() + "-log_heap";
-  status = rt_heap_create(&log_heap, tmp_name.c_str(), LOG_HEAP, H_FIFO);
+  status = rt_heap_create(&log_heap, tmp_name.c_str(), RT_LOG_HEAP, H_FIFO);
   if (status != 0) {
+    char errorMsg[256];
     Err("rt_heap_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     return;
@@ -601,31 +602,33 @@
   continuer = true;
 
-#ifdef NRT_STACK_SIZE
   // Initialize thread creation attributes
   pthread_attr_t attr;
-  if (pthread_attr_init(&attr) != 0) {
-    Err("pthread_attr_init error\n");
-    return;
-  }
-
-  if (pthread_attr_setstacksize(&attr, NRT_STACK_SIZE) != 0) {
-    Err("pthread_attr_setstacksize error\n");
-    return;
-  }
-
-  if (pthread_create(&log_th, &attr, write_log_user, (void *)this) < 0)
-#else
-  if (pthread_create(&log_th, NULL, write_log_user, (void *)this) < 0)
-#endif
-  {
-    Err("pthread_create error\n");
-    return;
-  }
-#ifdef NRT_STACK_SIZE
-  if (pthread_attr_destroy(&attr) != 0) {
-    Err("pthread_attr_destroy error\n");
-    return;
-  }
-#endif
+  status=pthread_attr_init(&attr);
+  if (status != 0) {
+    char errorMsg[256];
+    Err("pthread_attr_init error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+    return;
+  }
+
+  status=pthread_attr_setstacksize(&attr, stackSize);
+  if (status != 0) {
+    char errorMsg[256];
+    Err("pthread_attr_setstacksize error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+    return;
+  }
+
+  status=pthread_create(&log_th, &attr, write_log_user, (void *)this);
+  if (status < 0) {
+    char errorMsg[256];
+    Err("pthread_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+    return;
+  }
+
+  status=pthread_attr_destroy(&attr);
+  if (status != 0) {
+    char errorMsg[256];
+    Err("pthread_attr_destroy error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+    return;
+  }
 
   logger_defined = true;
@@ -781,5 +784,4 @@
   int cmd_pipe = -1;
   int data_pipe = -1;
-  string filename;
   fd_set set;
   struct timeval timeout;
@@ -790,17 +792,20 @@
 
 #ifdef __XENO__
-	char errorMsg[256];
-  filename = NRT_PIPE_PATH + caller->self->ObjectName() + "-log_cmd";
   while (cmd_pipe < 0) {
+    string filename = NRT_PIPE_PATH + caller->self->ObjectName() + "-log_cmd";
     cmd_pipe = open(filename.c_str(), O_RDWR);
-    if (cmd_pipe < 0 && errno != ENOENT)
+    if (cmd_pipe < 0 && errno != ENOENT) {
+      char errorMsg[256];
       caller->self->Err("open rt_pipe error: %s %s\n", filename.c_str(), strerror_r(errno, errorMsg, sizeof(errorMsg)));
+    }
     usleep(1000);
   }
-  filename = NRT_PIPE_PATH + caller->self->ObjectName() + "-log_data";
   while (data_pipe < 0) {
+    string filename = NRT_PIPE_PATH + caller->self->ObjectName() + "-log_data";
     data_pipe = open(filename.c_str(), O_RDWR);
-    if (data_pipe < 0 && errno != ENOENT)
+    if (data_pipe < 0 && errno != ENOENT) {
+      char errorMsg[256];
       caller->self->Err("open rt_pipe error: %s %s\n", filename.c_str(), strerror_r(errno, errorMsg, sizeof(errorMsg)));
+    }
     usleep(1000);
   }
@@ -829,7 +834,6 @@
         read(cmd_pipe, &tmp, sizeof(log_desc_t));
 
-        if (tmp.running == true) // start logging
-        {
-          filename = caller->log_path + "/" + caller->FileName(tmp.device) + ".dbt";
+        if (tmp.running == true) {// start logging
+          string filename = caller->log_path + "/" + caller->FileName(tmp.device) + ".dbt";
           printf("Creating log file %s (log size %i)\n", filename.c_str(), (int)tmp.size);
           tmp.dbtFile = inithdFile((char *)filename.c_str(), UAV, tmp.size);
@@ -840,20 +844,19 @@
             xmlSaveFile(filename.c_str(), caller->file_doc);
           }
-        } else // stop logging
-        {
-            //disable watchdog temporarly
-            //this is necessary because GCS is no longer sending the heartbeat when receiving files...
-            //TODO: add a thread in GCS for receiving file
-            //but be careful that with a xbee modem for exemple, sending files can saturate communication and
-            //avoid the heartbeat to be received... so disabling watchdog is not a so bad option...
-            if(caller->gcs_watchdog!=NULL) {
-                caller->gcs_watchdog->SafeStop();
-                caller->gcs_watchdog->Join();
-            }
+        } else {// stop logging
+          //disable watchdog temporarly
+          //this is necessary because GCS is no longer sending the heartbeat when receiving files...
+          //TODO: add a thread in GCS for receiving file
+          //but be careful that with a xbee modem for exemple, sending files can saturate communication and
+          //avoid the heartbeat to be received... so disabling watchdog is not a so bad option...
+          if(caller->gcs_watchdog!=NULL) {
+              caller->gcs_watchdog->SafeStop();
+              caller->gcs_watchdog->Join();
+          }
           for (size_t i = 0; i < logs.size(); i++) {
             if (logs.at(i).dbtFile != NULL) {
               close_hdfile(logs.at(i).dbtFile);
 
-              filename = caller->FileName(logs.at(i).device) + ".dbt";
+              string filename = caller->FileName(logs.at(i).device) + ".dbt";
               caller->SendFile(caller->log_path, filename);
 
@@ -875,8 +878,8 @@
 
           logs.clear();
-            //enable watchdog again
-            if(caller->gcs_watchdog!=NULL) {
-                caller->gcs_watchdog->Start();
-            }
+          //enable watchdog again
+          if(caller->gcs_watchdog!=NULL) {
+              caller->gcs_watchdog->Start();
+          }
         }
       }
