mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
csv: added offset field and padding non existant fields
This commit is contained in:
parent
59ec38172b
commit
92c910ca2e
1 changed files with 15 additions and 0 deletions
15
lib/io/csv.c
15
lib/io/csv.c
|
@ -35,9 +35,18 @@ size_t csv_sprint_single(char *buf, size_t len, struct sample *s, int flags)
|
|||
|
||||
if (flags & SAMPLE_HAS_ORIGIN)
|
||||
off += snprintf(buf + off, len - off, "%ld%c%09ld", s->ts.origin.tv_sec, CSV_SEPARATOR, s->ts.origin.tv_nsec);
|
||||
else
|
||||
off += snprintf(buf + off, len - off, "nan%cnan", CSV_SEPARATOR);
|
||||
|
||||
if (flags & SAMPLE_HAS_RECEIVED)
|
||||
off += snprintf(buf + off, len - off, "%c%f", CSV_SEPARATOR, time_delta(&s->ts.origin, &s->ts.received));
|
||||
else
|
||||
off += snprintf(buf + off, len - off, "%cnan", CSV_SEPARATOR);
|
||||
|
||||
if (flags & SAMPLE_HAS_SEQUENCE)
|
||||
off += snprintf(buf + off, len - off, "%c%u", CSV_SEPARATOR, s->sequence);
|
||||
else
|
||||
off += snprintf(buf + off, len - off, "%cnan", CSV_SEPARATOR);
|
||||
|
||||
for (int i = 0; i < s->length; i++) {
|
||||
switch ((s->format >> i) & 0x1) {
|
||||
|
@ -76,6 +85,12 @@ size_t csv_sscan_single(const char *buf, size_t len, struct sample *s, int flags
|
|||
|
||||
s->flags |= SAMPLE_HAS_ORIGIN;
|
||||
|
||||
double offset __attribute__((unused)) = strtof(ptr, &end);
|
||||
if (end == ptr || *end == '\n')
|
||||
goto out;
|
||||
|
||||
ptr = end;
|
||||
|
||||
s->sequence = strtoul(ptr, &end, 10);
|
||||
if (end == ptr || *end == '\n')
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Reference in a new issue