Store computed reception time in the message struct so we don't rely on

the message being emitted immediately.

Fix computation of reception time so it's more sensible (the block timestamp
is some time after reception of the _end_ of the block, not the start) - this
means that message-emission times are always later than message-reception
times in SBS output, which is a bit more sensible.

Use clock_gettime in preference to ftime.
This commit is contained in:
Oliver Jowett 2015-02-08 17:46:01 +00:00
parent 1584955080
commit 4e177c2d64
7 changed files with 76 additions and 31 deletions

13
util.h
View file

@ -22,6 +22,19 @@
#include <stdint.h>
/* Returns system time in milliseconds */
uint64_t mstime(void);
/* Returns the time elapsed, in nanoseconds, from t1 to t2,
* where t1 and t2 are 12MHz counters,
* accounting for wrapping.
*/
uint64_t receiveclock_ns_elapsed(uint64_t t1, uint64_t t2);
/* Normalize the value in ts so that ts->nsec lies in
* [0,999999999]
*/
struct timespec;
void normalize_timespec(struct timespec *ts);
#endif