[Bug 1066] New: Timer did not elapsed each time after re-arm

Andreas Schwark <[email protected]> Fri, 10 Jul 2015 10:25:39 +0200
Newsgroups gmane.science.robotics.orocos.devel
Message-ID <[email protected]/>
http://bugs.orocos.org/show_bug.cgi?id=1066

           Summary: Timer did not elapsed each time after re-arm
           Product: Toolchain
           Version: unspecified
          Platform: All
        OS/Version: Xenomai 2.x
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: RTT
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
   Estimated Hours: 0.0


If you arm a timer (RTT::Timer) after the timer elapsed, then sometimes the
timer will not elapsed again. In that case the timer is armed and the remaining
time is 0. 

I've checked the RTT::Timer class (rtt/rtt/os/Timer.cpp) and maybe I found the
following mistake in Timer::loop(): 

The variable ret is not set correctly if wake_up_time is greater than
rtos_get_time_ns(). 
msem.waitUNtil returns a boolean value (0 or 1) and so ret is set to 0 or 1. If
I set ret to -1 or 1 then the problems seem to be solved.

original code:
...
if ( wake_up_time > rtos_get_time_ns() )
   ret = msem.waitUntil( wake_up_time ); // case of no timers or running timers
else
   ret = -1; // case of timer overrun.
...

changed code:
...
if ( wake_up_time > rtos_get_time_ns() )
{
   if(!msem.waitUntil( wake_up_time ))   // case of no timers or running timers
   {
      ret = -1;
   }
}
else
{
   ret = -1; // case of timer overrun.
}

-- 
Configure bugmail: http://bugs.orocos.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.
-- 
Orocos-Dev mailing list
[email protected]
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev