diff --git a/include/villas/signal.h b/include/villas/signal.h index 1ff1ae1a1..ec9e5b8f4 100644 --- a/include/villas/signal.h +++ b/include/villas/signal.h @@ -31,6 +31,7 @@ struct node; struct signal { char *name; /**< The name of the signal. */ + char *unit; enum { SIGNAL_FORMAT_INTEGER, SIGNAL_FORMAT_REAL diff --git a/lib/signal.c b/lib/signal.c index a13f677a1..5bc57cb99 100644 --- a/lib/signal.c +++ b/lib/signal.c @@ -40,14 +40,19 @@ int signal_parse(struct signal *s, json_t *cfg) int ret; json_error_t err; const char *name; + const char *unit = NULL; - ret = json_unpack_ex(cfg, &err, 0, "s: s", - "name", &name + ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: s }", + "name", &name, + "unit", &unit ); if (ret) return -1; s->name = strdup(name); + s->unit = unit + ? strdup(unit) + : NULL; return 0; }