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:
parent
c59e0948c3
commit
18096feb49
2 changed files with 8 additions and 2 deletions
|
@ -31,6 +31,7 @@ struct node;
|
|||
|
||||
struct signal {
|
||||
char *name; /**< The name of the signal. */
|
||||
char *unit;
|
||||
enum {
|
||||
SIGNAL_FORMAT_INTEGER,
|
||||
SIGNAL_FORMAT_REAL
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue