]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robofsm: Fix problem with timespec_substract function.
authorMichal Vokac <vokac.m@gmail.com>
Fri, 3 Jun 2011 09:37:56 +0000 (11:37 +0200)
committerMichal Vokac <vokac.m@gmail.com>
Fri, 3 Jun 2011 09:37:56 +0000 (11:37 +0200)
timespec_substract function slightly changed value in start time structure,
(it puts negative value in start time nsec variable) which causes problem when WAIT macro (clock_nanosleep function) was called again.

src/robofsm/match-timing.c

index aa898d4ae97f1de8bee7247a359af72b7e37225e..27b92f1abb20e5f2e05222ea26929ff105a9e446 100644 (file)
@@ -85,8 +85,9 @@ timespec_subtract (struct timespec *result,
 
 float robot_current_time()
 {
-       struct timespec now, diff;
+       struct timespec now, diff, start_local;
+        start_local = start;
        clock_gettime(CLOCK_MONOTONIC, &now);
-       timespec_subtract(&diff, &now, &start);
+       timespec_subtract(&diff, &now, &start_local);
        return diff.tv_sec + diff.tv_nsec/1000000000.0;
 }