From 9ae5931db7b94ac77c5cc08fc3597f8734ee244b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 12 Jul 2008 10:49:48 +0200 Subject: [PATCH] Fix time --- src/control.h | 5 ++++- src/control_parser.c | 2 +- src/control_parser.rl | 2 +- src/path.c | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/control.h b/src/control.h index 8590f07..b7f780a 100644 --- a/src/control.h +++ b/src/control.h @@ -6,6 +6,7 @@ #include #include #include +#include #define INLINE static inline #define UNUSED(x) ((void)(x)) @@ -192,7 +193,9 @@ INLINE void vehicle_hard_right(trial *t) { INLINE timestamp getcurts(trial *t) { struct timeval tv; gettimeofday(&tv, NULL); - return (tv.tv_sec - t->started.tv_sec) * 1000 + (tv.tv_usec - t->started.tv_sec) / 1000; + timestamp ts = (tv.tv_sec - t->started.tv_sec) * 1000 + (tv.tv_usec - t->started.tv_usec) / 1000; + printf("Timestamp: %u\n", ts); + return ts; } #endif diff --git a/src/control_parser.c b/src/control_parser.c index 94f9aaf..1e4e64b 100644 --- a/src/control_parser.c +++ b/src/control_parser.c @@ -387,9 +387,9 @@ _match: if (!t->alive) { t->vehicle.accel = ctx->tm->vehicle.accel; t->vehicle.turn = ctx->tm->vehicle.turn; + gettimeofday(&t->started, NULL); } t->last_ts = ctx->tm->ts; - gettimeofday(&t->started, NULL); ctx->tm = NULL; t->alive = 1; } diff --git a/src/control_parser.rl b/src/control_parser.rl index 21e0752..221bd06 100644 --- a/src/control_parser.rl +++ b/src/control_parser.rl @@ -39,9 +39,9 @@ static timestamp extract_ts(context *ctx, char *fpc) { if (!t->alive) { t->vehicle.accel = ctx->tm->vehicle.accel; t->vehicle.turn = ctx->tm->vehicle.turn; + gettimeofday(&t->started, NULL); } t->last_ts = ctx->tm->ts; - gettimeofday(&t->started, NULL); ctx->tm = NULL; t->alive = 1; } diff --git a/src/path.c b/src/path.c index b85766a..850f670 100644 --- a/src/path.c +++ b/src/path.c @@ -59,7 +59,7 @@ void path_execute(trial* t,path* p){ return; } - now = timestamp_get_curts(t); + now = getcurts(t); /*fprintf(stderr,"Now: %d TS: %d\n",now,clock());*/ /*magic number for latency, send messages that much earlier*/ while(tmp != NULL && now - 20 > tmp->ts){