[openrtm-commit:02621] r2998 - trunk/OpenRTM-aist/src/lib/coil/vxworks/coil

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 6月 1日 (木) 12:07:43 JST


Author: miyamoto
Date: 2017-06-01 12:07:43 +0900 (Thu, 01 Jun 2017)
New Revision: 2998

Modified:
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h
Log:
[compat, VxWorks] support RTP.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,14 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file  MutexPosix.h
- * @brief RT-Middleware Service interface
+ * @file  Mutex_vxworks.cpp
+ * @brief Condition variable for VxWorks
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,14 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file  Condition_posix.h
- * @brief Condition variable for POSIX
+ * @file  Condition_vxworks.h
+ * @brief Condition variable for VxWorks
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.
@@ -23,12 +22,21 @@
 #include <pthread.h>
 #include <algorithm>
 #include <ctime>
-#if defined(VXWORKS_66) && !defined(__RTP__)
+
+#ifdef __RTP__
+#include <semLib.h>
+#include <sysLib.h>
+#include <taskLib.h>
+#else
+#ifdef VXWORKS_66
 #include <timers.h>
 #else
 #include <sys/time.h>
 #endif
+#endif
 
+
+
 namespace coil
 {
   /*!
@@ -67,7 +75,11 @@
     Condition(M& mutex)
       : m_mutex(mutex)
     {
+#ifdef __RTP__
+      m_cond = semCCreate(SEM_Q_PRIORITY, 0);
+#else
       ::pthread_cond_init(&m_cond, 0);
+#endif
     }
 
     /*!
@@ -87,7 +99,11 @@
      */
     ~Condition()
     {
+#ifdef __RTP__
+      semDelete(m_cond);
+#else
       ::pthread_cond_destroy(&m_cond);
+#endif
     }
 
     /*!
@@ -107,7 +123,11 @@
      */
     inline void signal()
     {
+#ifdef __RTP__
+      semGive(m_cond);
+#else
       ::pthread_cond_signal(&m_cond);
+#endif
     }
 
     /*!
@@ -127,7 +147,11 @@
      */
     inline void broadcast()
     {
+#ifdef __RTP__
+      semFlush(m_cond);
+#else
       ::pthread_cond_broadcast(&m_cond);
+#endif
     }
 
     /*!
@@ -151,7 +175,20 @@
      */
     bool wait()
     {
+#ifdef __RTP__
+      //taskLock();
+      m_mutex.unlock();
+      STATUS status = semTake(m_cond, WAIT_FOREVER);
+      //taskUnlock();
+      if(status != OK)
+      {
+            return -1;
+      }
+      m_mutex.lock();
+      return 0;
+#else
       return 0 == ::pthread_cond_wait(&m_cond, &m_mutex.mutex_);
+#endif
     }
 
     /*!
@@ -181,7 +218,25 @@
      */
     bool wait(long second, long nano_second = 0)
     {
-#if defined(VXWORKS_66) && !defined(__RTP__)
+#ifdef __RTP__
+      //taskLock();
+      m_mutex.unlock();
+      long timeout = (second*1000 + nano_second/1000000l);
+      int ticks = (timeout*sysClkRateGet()) / 1000l;
+      STATUS status = semTake(m_cond, ticks);
+      //taskUnlock();
+
+      m_mutex.lock();
+      if(status != OK)
+      {
+            return -1;
+      }
+      else
+      {
+            return 0;
+      }
+#else
+#ifdef VXWORKS_66
       timespec abstime;
       ::clock_gettime(CLOCK_REALTIME, &abstime);
       abstime.tv_sec  += second;
@@ -199,12 +254,17 @@
         abstime.tv_sec ++;
       }
       return 0 == ::pthread_cond_timedwait(&m_cond, &m_mutex.mutex_, &abstime);
+#endif
     }
 
   private:
     Condition(const M&);
     Condition& operator=(const M &);
+#ifdef __RTP__
+    SEM_ID m_cond;
+#else
     pthread_cond_t m_cond;
+#endif
     M& m_mutex;
   };
 };

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,11 +3,11 @@
  * @file DynamicLib.cpp
  * @brief DynamicLib class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008 Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,11 +3,11 @@
  * @file DynamicLib_posix.h
  * @brief DynamicLib class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008 Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file File_posix.h
+ * @file File_vxworks.h
  * @brief File functions
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,12 +3,11 @@
  * @file  MutexPosix.h
  * @brief RT-Middleware Service interface
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,14 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file  Mutex_posix.h
- * @brief coil POSIX mutex class
+ * @file  Mutex_vxworks.h
+ * @brief coil VxWorks mutex class
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.
@@ -17,10 +16,15 @@
  *
  */
 
+
 #ifndef COIL_MUTEX_H
 #define COIL_MUTEX_H
 
+
 #include <pthread.h>
+#ifdef __RTP__
+#include <semLib.h>
+#endif
 
 namespace coil
 {
@@ -61,7 +65,11 @@
      */
     Mutex(const char * const name = 0)
     {
+#ifdef __RTP__
+      mutex_ = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE);
+#else
       ::pthread_mutex_init(&mutex_, 0);
+#endif
     }
 
     /*!
@@ -81,7 +89,11 @@
      */
     ~Mutex()
     {
+#ifdef __RTP__
+      semDelete(mutex_);
+#else
       ::pthread_mutex_destroy(&mutex_);
+#endif
     }
 
     /*!
@@ -101,7 +113,11 @@
      */
     inline void lock()
     {
+#ifdef __RTP__
+      semTake(mutex_, WAIT_FOREVER);
+#else
       ::pthread_mutex_lock(&mutex_);
+#endif
     }
 
     /*!
@@ -121,7 +137,12 @@
      */
     inline bool trylock()
     {
+#ifdef __RTP__
+      STATUS status = semTake(mutex_, NO_WAIT);
+      return (status == OK);
+#else
       return ::pthread_mutex_trylock(&mutex_);
+#endif
     }
 
     /*!
@@ -141,7 +162,11 @@
      */
     inline void unlock()
     {
+#ifdef __RTP__
+      semGive(mutex_);
+#else
       ::pthread_mutex_unlock(&mutex_);
+#endif
     }
 
     /*!
@@ -155,7 +180,11 @@
      *
      * @endif
      */
+#ifdef __RTP__
+    SEM_ID mutex_;
+#else
     pthread_mutex_t mutex_;
+#endif
 
   private:
     Mutex(const Mutex&);

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file OS_posix.h
+ * @file OS_vxworks.h
  * @brief OS class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,12 +3,11 @@
  * @file  Process.h
  * @brief Process handling functions
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2010
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,12 +3,11 @@
  * @file  Process.h
  * @brief Process handling functions
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2010
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,12 +3,11 @@
  * @file  Signal_posix.cpp
  * @brief SignalAction class
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,14 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file  Signal_posix.h
+ * @file  Signal_vxworks.h
  * @brief SignalAction class
  * @date  $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Noriaki Ando
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file Task_posix.cpp
+ * @file Task_vxworks.cpp
  * @brief Task class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file Task_posix.h
+ * @file Task_vxworks.h
  * @brief Task class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp	2017-06-01 03:07:43 UTC (rev 2998)
@@ -3,11 +3,11 @@
  * @file Timevalue.h
  * @brief Timevalue class
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h	2017-05-31 05:08:08 UTC (rev 2997)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h	2017-06-01 03:07:43 UTC (rev 2998)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /*!
- * @file Time_posix.h
+ * @file Time_vxworks.h
  * @brief Time functions
  * @date $Date$
- * @author Noriaki Ando <n-ando at aist.go.jp>
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
  *
- * Copyright (C) 2008
- *     Task-intelligence Research Group,
- *     Intelligent Systems Research Institute,
+ * Copyright (C) 2017
+ *     Nobuhiko Miyamoto
+ *     Robot Innovation Research Center
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.
@@ -28,11 +28,13 @@
 
 #include <sys/types.h>
 #include <time.h>
-#include <iostream>
 #include <coil/config_coil.h>
 #include <coil/TimeValue.h>
 
-#ifndef __RTP__
+#ifdef __RTP__
+#include <taskLib.h>
+#include <sysLib.h>
+#else
 #include <selectLib.h>
 #endif
 
@@ -62,7 +64,19 @@
    */
   inline unsigned int sleep(unsigned int seconds)
   {
+#ifdef __RTP__
+    int tps = sysClkRateGet();
+    if(taskDelay(seconds*tps) == OK)
+    {
+        return 0;
+    }
+    else
+    {
+        return -1;
+    }
+#else
     return ::sleep(seconds);
+#endif
   }
 
   /*!
@@ -88,10 +102,22 @@
    */
   inline int sleep(TimeValue interval)
   {
+#ifdef __RTP__
+    int tps = sysClkRateGet();
+    if(taskDelay((double)interval.sec()*tps + (double)(interval.usec()*tps)/1000000l) == OK)
+    {
+        return 0;
+    }
+    else
+    {
+        return -1;
+    }
+#else
     timeval tv;
     tv.tv_sec = interval.sec();
     tv.tv_usec = interval.usec();
     return ::select(0, 0, 0, 0, &tv);
+#endif
   }
 
   /*!
@@ -117,8 +143,20 @@
    */
   inline int usleep(unsigned int usec)
   {
-	  struct timespec req = {0,usec * 1000};
-	  return ::nanosleep(&req, NULL);
+#ifdef __RTP__
+    int tps = sysClkRateGet();
+    if(taskDelay((double)(usec*tps)/1000000000l) == OK)
+    {
+        return 0;
+    }
+    else
+    {
+        return -1;
+    }
+#else
+    struct timespec req = {0,usec * 1000};
+    return ::nanosleep(&req, NULL);
+#endif
   }
 
   /*!



More information about the openrtm-commit mailing list