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

signal: added unit field

This commit is contained in:
Steffen Vogel 2018-04-09 10:52:54 +02:00
parent c59e0948c3
commit 18096feb49
2 changed files with 8 additions and 2 deletions

View file

@ -31,6 +31,7 @@ struct node;
struct signal {
char *name; /**< The name of the signal. */
char *unit;
enum {
SIGNAL_FORMAT_INTEGER,
SIGNAL_FORMAT_REAL

View file

@ -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;
}