mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-16 00:00:02 +01:00
json: fix flag checks
This commit is contained in:
parent
65828daed4
commit
0c400f7df0
1 changed files with 14 additions and 8 deletions
|
@ -54,11 +54,15 @@ static json_t * json_pack_timestamps(struct io *io, struct sample *smp)
|
|||
{
|
||||
json_t *json_ts = json_object();
|
||||
|
||||
if (io->flags & 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));
|
||||
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));
|
||||
}
|
||||
|
||||
if (io->flags & 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));
|
||||
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));
|
||||
}
|
||||
|
||||
return json_ts;
|
||||
}
|
||||
|
@ -101,13 +105,15 @@ static int json_pack_sample(struct io *io, json_t **j, struct sample *smp)
|
|||
|
||||
json_smp = json_pack_ex(&err, 0, "{ s: o }", "ts", json_pack_timestamps(io, smp));
|
||||
|
||||
if (io->flags & smp->flags & SAMPLE_HAS_SEQUENCE) {
|
||||
json_t *json_sequence = json_integer(smp->sequence);
|
||||
if (io->flags & SAMPLE_HAS_SEQUENCE) {
|
||||
if (smp->flags & SAMPLE_HAS_SEQUENCE) {
|
||||
json_t *json_sequence = json_integer(smp->sequence);
|
||||
|
||||
json_object_set(json_smp, "sequence", json_sequence);
|
||||
json_object_set(json_smp, "sequence", json_sequence);
|
||||
}
|
||||
}
|
||||
|
||||
if (io->flags & smp->flags & SAMPLE_HAS_DATA) {
|
||||
if (io->flags & SAMPLE_HAS_DATA) {
|
||||
json_t *json_data = json_array();
|
||||
|
||||
for (unsigned i = 0; i < smp->length; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue