Rename --device= to --overridedevice=

pull/618/head
Fredrik Öhrström 2022-09-21 16:49:51 +02:00
rodzic 2e8f6e5430
commit 2ce3f33151
9 zmienionych plików z 23 dodań i 14 usunięć

1
.gitignore vendored
Wyświetl plik

@ -2,6 +2,7 @@ build/
build_debug
build_arm/
build_arm_debug/
packaging/
testaes/
testoutput/
tests_tmp/

Wyświetl plik

@ -1,4 +1,6 @@
Version: 1.10.0 2022-09-14
Rename option --device=xyz to --overridedevice=xyz and add better error message
if it is used without --useconfig=xyz. --device still works but will eventually be removed.
OPTIONAL fields were only printed in the json, if they appeared in the telegram,
even if the field had received a value before. Now a field will be printed

Wyświetl plik

@ -255,20 +255,20 @@ wmbusmeters --useconfig=/home/me/.config/wmbusmeters
If you already have config with a device specified, and you want to use
the config with another device. You might have multiple meters in the config
that you want to listen to. Then you can add `--device` to override the settings
that you want to listen to. Then you can add `--overridedevice` to override the settings
in the config. Like this:
```shell
wmbusmeters --useconfig=/home/me/.config/wmbusmeters --device=rtlwmbus
wmbusmeters --useconfig=/home/me/.config/wmbusmeters --overridedevice=rtlwmbus
```
You must have both `--useconfig=` and `--device=` for it to work.
You must have both `--useconfig=` and `--overridedevice=` for it to work.
The files/dir should then be located here:
`/home/me/.config/wmbusmeters/wmbusmeters.conf` and
`/home/me/.config/wmbusmeters/wmbusmeters.d`
The option `--useconfig=` can only be combined with a few other options: `--device= --listento= --exitafter= --oneshot= --silent --normal --verbose --debug --trace`
The option `--useconfig=` can only be combined with a few other options: `--overridedevice= --listento= --exitafter= --oneshot= --silent --normal --verbose --debug --trace`
When running using config files then you can trigger a reload of the config files
using `sudo killall -HUP wmbusmetersd` or `killall -HUP wmbusmeters`
@ -293,7 +293,7 @@ As {options} you can use:
--analyze=<driver> Analyze a telegram and use only this driver.
--analyze=<driver>:<key> Analyze a telegram and use only this driver with this key.
--debug for a lot of information
--device=<device> override device in config files. Use only in combination with --useconfig= option
--overridedevice=<device> override device in config files. Use only in combination with --useconfig= option
--donotprobe=<tty> do not auto-probe this tty. Use multiple times for several ttys or specify "all" for all ttys.
--exitafter=<time> exit program after time, eg 20h, 10m 5s
--format=<hr/json/fields> for human readable, json or semicolon separated fields

Wyświetl plik

@ -67,6 +67,11 @@ static shared_ptr<Configuration> parseNormalCommandLine(Configuration *c, int ar
c->need_help = true;
return shared_ptr<Configuration>(c);
}
if (!strncmp(argv[i], "--device=", 9) || // Deprecated
!strncmp(argv[i], "--overridedevice=", 17))
{
error("You can only use --overridedevice=xyz with --useconfig=xyz\n");
}
if (!strcmp(argv[i], "--silent")) {
c->silent = true;
i++;
@ -732,7 +737,8 @@ shared_ptr<Configuration> parseCommandLineWithUseConfig(Configuration *c, int ar
i++;
continue;
}
if (!strncmp(argv[i], "--device=", 9))
if (!strncmp(argv[i], "--device=", 9) || // Deprecated
!strncmp(argv[i], "--overridedevice=", 17))
{
c->overrides.device_override = string(argv[i]+9);
debug("(useconfig) device override \"%s\"\n", c->overrides.device_override.c_str());
@ -772,7 +778,7 @@ shared_ptr<Configuration> parseCommandLineWithUseConfig(Configuration *c, int ar
}
error("Usage error: --useconfig=... can only be used in combination with:\n"
"--device= --listento= --exitafter= --oneshot= --logfile= --silent --normal --verbose --debug --trace\n");
"--overridedevice= --listento= --exitafter= --oneshot= --logfile= --silent --normal --verbose --debug --trace\n");
break;
}

Wyświetl plik

@ -74,7 +74,7 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test additional json from wmbusmeters.conf and from meter file"
TESTRESULT="ERROR"
$PROG --debug --useconfig=tests/config6 --device=simulations/simulation_shell.txt > $TEST/test_output.txt 2> $TEST/test_stderr.txt
$PROG --debug --useconfig=tests/config6 --overridedevice=simulations/simulation_shell.txt > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -12,7 +12,7 @@ echo "RUNNING $TESTNAME ..."
> /tmp/wmbusmeters_telegram_test
> /tmp/wmbusmeters_alarm_test
$PROG --useconfig=tests/config7 --device=simulations/simulation_alarm.txt 2> $TEST/test_stderr.txt | sed 's/....-..-..T..:..:..Z/1111-11-11T11:11:11Z/' > $TEST/test_output.txt
$PROG --useconfig=tests/config7 --overridedevice=simulations/simulation_alarm.txt 2> $TEST/test_stderr.txt | sed 's/....-..-..T..:..:..Z/1111-11-11T11:11:11Z/' > $TEST/test_output.txt
echo "STDERR---------------------------------"
cat $TEST/test_stderr.txt

Wyświetl plik

@ -19,7 +19,7 @@ TESTRESULT="ERROR"
cat simulations/serial_aes.msg | grep '^{' | tr -d '#' > $TEST/test_expected.txt
cat simulations/serial_aes.msg | grep '^[CT]' | tr -d '#' > $TEST/test_input.txt
cat $TEST/test_input.txt | $PROG --useconfig=tests/config9 --device=stdin:rtlwmbus --oneshot > $TEST/test_output.txt 2> $TEST/test_stderr.txt
cat $TEST/test_input.txt | $PROG --useconfig=tests/config9 --overridedevice=stdin:rtlwmbus --oneshot > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if ! grep -q "(main) all meters have received at least one update, stopping." $TEST/test_stderr.txt
then
@ -46,7 +46,7 @@ cat simulations/serial_aes.msg | grep '^{' | tr -d '#' > $TEST/test_expected.txt
cat simulations/serial_aes.msg | grep '^[CT]' | tr -d '#' > $TEST/test_input.txt
# Read from stdin
{ cat $TEST/test_input.txt ; sleep 4; } | $PROG --useconfig=tests/config9 --device=stdin:rtlwmbus --exitafter=1s > $TEST/test_output.txt 2> $TEST/test_stderr.txt
{ cat $TEST/test_input.txt ; sleep 4; } | $PROG --useconfig=tests/config9 --overridedevice=stdin:rtlwmbus --exitafter=1s > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if ! grep -q "(serial) exit after " $TEST/test_stderr.txt
then

Wyświetl plik

@ -9,7 +9,7 @@ TESTRESULT="ERROR"
cat simulations/simulation_extras.txt | grep '^{' > $TEST/test_expected.txt
$PROG --useconfig=tests/config8 --device=simulations/simulation_extras.txt 2> $TEST/test_stderr.txt > $TEST/test_output.txt
$PROG --useconfig=tests/config8 --overridedevice=simulations/simulation_extras.txt 2> $TEST/test_stderr.txt > $TEST/test_output.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -43,7 +43,7 @@ Add :verbose to any analyze to get more verbose analyze output.
\fB\--debug\fR for a lot of information
\fB\--device=\fR<device> override device in config files. Use only in combination with --useconfig= option
\fB\--overridedevice=\fR<device> override device in config files. Can only be used in combination with --useconfig= option
\fB\--donotprobe=\fR<tty> do not auto-probe this tty. Use multiple times for several ttys or specify "all" for all ttys