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: fix parsing of format parameter

This commit is contained in:
Steffen Vogel 2019-04-17 18:35:22 +02:00
parent d1da0f2f22
commit b67acd52fb

View file

@ -73,7 +73,7 @@ static void usage()
print_copyright();
}
json_t * parse_cli(int argc, char *argv[])
json_t * parse_cli(int argc, char *argv[], char **format)
{
Logger logger = logging.get("signal");
@ -91,12 +91,16 @@ json_t * parse_cli(int argc, char *argv[])
/* Parse optional command line arguments */
int c;
char *endptr;
while ((c = getopt(argc, argv, "v:r:f:l:a:D:no:d:hV")) != -1) {
while ((c = getopt(argc, argv, "v:r:F:f:l:a:D:no:d:hV")) != -1) {
switch (c) {
case 'n':
rt = 0;
break;
case 'f':
*format = optarg;
break;
case 'l':
limit = strtoul(optarg, &endptr, 10);
goto check;
@ -113,7 +117,7 @@ json_t * parse_cli(int argc, char *argv[])
offset = strtof(optarg, &endptr);
goto check;
case 'f':
case 'F':
frequency = strtof(optarg, &endptr);
goto check;
@ -206,10 +210,6 @@ int main(int argc, char *argv[])
if (ret)
throw RuntimeError("Failed to intialize signals");
ft = format_type_lookup(format);
if (!ft)
throw RuntimeError("Invalid output format '{}'", format);
ret = memory_init(0);
if (ret)
throw RuntimeError("Failed to initialize memory");
@ -222,7 +222,7 @@ int main(int argc, char *argv[])
if (ret)
throw RuntimeError("Failed to initialize node");
cfg = parse_cli(argc, argv);
cfg = parse_cli(argc, argv, &format);
if (!cfg) {
usage();
exit(EXIT_FAILURE);
@ -234,6 +234,10 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
ft = format_type_lookup(format);
if (!ft)
throw RuntimeError("Invalid output format '{}'", format);
// nt == n._vt
ret = node_type_start(nt, nullptr);
if (ret)