Index: trunk/lib/FlairCore/src/Thread.cpp
===================================================================
--- trunk/lib/FlairCore/src/Thread.cpp	(revision 306)
+++ trunk/lib/FlairCore/src/Thread.cpp	(revision 307)
@@ -98,10 +98,11 @@
 #else
   Time current = GetTime();
+
   if (current < time) {
     //usleep((time - current) / 1000);
+    Time tmp=time - current;
     struct timespec req;
-    req.tv_nsec = time - current;
-    req.tv_sec = req.tv_nsec / 1000000000;
-    req.tv_nsec %= 1000000000;
+    req.tv_sec = tmp / (Time)1000000000;
+    req.tv_nsec = tmp%(Time)1000000000;
     struct timespec rem;
     if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
@@ -113,19 +114,5 @@
 
 void Thread::SleepMS(uint32_t time) const {
-#ifdef __XENO__
-  int status = rt_task_sleep(time * 1000 * 1000);
-  if (status != 0) {
-		char errorMsg[256];
-    Err("erreur rt_task_sleep (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
-	}
-#else
-  //usleep(time * 1000);
-  struct timespec req;
-  req.tv_nsec = time * 1000000;
-  req.tv_sec = req.tv_nsec / 1000000000;
-  req.tv_nsec %= 1000000000;
-  struct timespec rem;
-  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
-#endif
+    SleepUS(time*1000);
 }
 
@@ -140,7 +127,6 @@
   //usleep(time);
   struct timespec req;
-  req.tv_nsec = time * 1000;
-  req.tv_sec = req.tv_nsec / 1000000000;
-  req.tv_nsec %= 1000000000;
+  req.tv_sec = (Time)time / (Time)1000;
+  req.tv_nsec = (Time)time%(Time)1000;
   struct timespec rem;
   if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
Index: trunk/lib/FlairCore/src/Thread_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/Thread_impl.cpp	(revision 306)
+++ trunk/lib/FlairCore/src/Thread_impl.cpp	(revision 307)
@@ -174,5 +174,5 @@
 
 #ifdef __XENO__
-  int status = rt_task_set_periodic(&task_rt, TM_NOW, period * 1000);
+  int status = rt_task_set_periodic(&task_rt, TM_NOW, (Time)period * (Time)1000);
   if (status != 0) {
 		char errorMsg[256];
@@ -181,9 +181,9 @@
 #else
   if (period_set) {
-    next_time -= period;
-    next_time += period * 1000;
-  } else next_time=GetTime()+period*1000;
-#endif
-  this->period = period * 1000;
+    next_time -= (Time)period;
+    next_time += (Time)period * (Time)1000;
+  } else next_time=GetTime()+(Time)period*(Time)1000;
+#endif
+  this->period = (Time)period * (Time)1000;
   period_set = true;
 }
@@ -192,23 +192,5 @@
 
 void Thread_impl::SetPeriodMS(uint32_t period) {
-  if (period == 0) {
-    self->Err("Period must be>0\n");
-    return;
-  }
-
-#ifdef __XENO__
-  int status = rt_task_set_periodic(&task_rt, TM_NOW, period * 1000 * 1000);
-  if (status != 0) {
-		char errorMsg[256];
-    self->Err("Error rt_task_set_periodic %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
-	}
-#else
-  if (period_set) {
-    next_time -= period;
-    next_time += period * 1000 * 1000;
-  } else next_time=GetTime()+period*1000*1000;
-#endif
-  this->period = period * 1000 * 1000;
-  period_set = true;
+  SetPeriodUS(period*1000);
 }
 
Index: trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 306)
+++ trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 307)
@@ -104,12 +104,13 @@
     // fps counter
     fpsCounter++;
-    if (fpsCounter == 100) {
+    if (GetTime() > (fpsPrev + 5 * (Time)1000000000)) {
+      // toute les 5 secondes
       fpsNow = GetTime();
       fps->SetText("fps: %.1f",
-       fpsCounter / ((float)(fpsNow - fpsPrev) / 1000000000.));
+      fpsCounter / ((float)(fpsNow - fpsPrev) / 1000000000.));
       fpsCounter = 0;
       fpsPrev = fpsNow;
-    }
-
+    } 
+    
     // cam properties
     if (gain->ValueChanged() == true && autogain->Value() == false)
Index: trunk/tools/Controller/DualShock3/src/DualShock3.cpp
===================================================================
--- trunk/tools/Controller/DualShock3/src/DualShock3.cpp	(revision 306)
+++ trunk/tools/Controller/DualShock3/src/DualShock3.cpp	(revision 307)
@@ -491,5 +491,7 @@
   if (bind(sk, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
     close(sk);
-    fatal("bind");
+    char errorMsg[256];
+    Thread::Err("bth bind, %s\n", strerror_r(errno, errorMsg, sizeof(errorMsg)));
+    return -1;
   }
 
Index: trunk/tools/FlairGCS/src/UdtSocket.cpp
===================================================================
--- trunk/tools/FlairGCS/src/UdtSocket.cpp	(revision 306)
+++ trunk/tools/FlairGCS/src/UdtSocket.cpp	(revision 307)
