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; }