1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

json: fix packing of timestamp values

This commit is contained in:
Steffen Vogel 2019-04-17 18:18:40 +02:00
parent 0c400f7df0
commit d1da0f2f22

View file

@ -54,14 +54,20 @@ static json_t * json_pack_timestamps(struct io *io, struct sample *smp)
{
json_t *json_ts = json_object();
#ifdef __arm__ // TODO: check
const char *fmt = "[ i, i ]";
#else
const char *fmt = "[ I, I ]";
#endif
if (io->flags & SAMPLE_HAS_TS_ORIGIN) {
if (smp->flags & SAMPLE_HAS_TS_ORIGIN)
json_object_set(json_ts, "origin", json_pack("[ I, I ]", smp->ts.origin.tv_sec, smp->ts.origin.tv_nsec));
json_object_set(json_ts, "origin", json_pack(fmt, smp->ts.origin.tv_sec, smp->ts.origin.tv_nsec));
}
if (io->flags & SAMPLE_HAS_TS_RECEIVED) {
if (smp->flags & SAMPLE_HAS_TS_RECEIVED)
json_object_set(json_ts, "received", json_pack("[ I, I ]", smp->ts.received.tv_sec, smp->ts.received.tv_nsec));
json_object_set(json_ts, "received", json_pack(fmt, smp->ts.received.tv_sec, smp->ts.received.tv_nsec));
}
return json_ts;