pull/473/head
Fredrik Öhrström 2022-02-05 18:11:34 +01:00
rodzic 0296eee881
commit 86b7163aa1
9 zmienionych plików z 109 dodań i 7 usunięć

Wyświetl plik

@ -1,4 +1,12 @@
You can now combine --useconfig=<dir> with --oneshot --exitafter=<time>
--silent --verbose --debug --normal --trace to override the config file settings.
(Already existing possible overrides was --device=<device> and --listento<mode>.)
This can be useful if you maintain a large set of meter configurations but want
to start wmbusmeters from a cronjob regularly. You can also add oneshot=true
and/or exitafter=30m to the conf file to get the same result.
Krzysztof Lewandowski added support for multiple tariffs in the amiplus driver. Thanks Krzysztof!
Bibo added support for the itron water meter. Thanks Bibo!

Wyświetl plik

@ -61,6 +61,9 @@ You can trigger a reload of the config files with `sudo killall -HUP wmbusmeters
(Note! make install only works for GNU/Linux. For MacOSX try to start
`wmbusmetersd /tmp/thepidfile` from a script instead.)
You can also start the daemon with another set of config files:
`wmbusmetersd --useconfig=/home/wmbusmeters /tmp/thepidfile`
Check the config file /etc/wmbusmeters.conf and edit the device. For example:
`auto:c1` or `im871a:c1,t1` or `im871a[457200101056]:t1` or `/dev/ttyUSB2:amb8465:c1,t1`
@ -155,7 +158,7 @@ If you cannot install as a daemon, then you can also start
wmbusmeters in your terminal using the config files in `/etc/wmbusmeters`.
```shell
wmbusmeters --useconfig=/
wmbusmeters --useconfig=/etc
```
Or you can start wmbusmeters with your own config files:
@ -176,8 +179,12 @@ wmbusmeters --useconfig=/home/me/.config/wmbusmeters --device=rtlwmbus
You must have both `--useconfig=` and `--device=` for it to work.
The files/dir should then be located here:
`/home/me/.config/wmbusmeters/etc/wmbusmeters.conf` and
`/home/me/.config/wmbusmeters/etc/wmbusmeters.d`
`/home/me/.config/wmbusmeters/wmbusmeters.conf` and
`/home/me/.config/wmbusmeters/wmbusmeters.d`
(For historical reasons wmbusmeters first looks for `/home/me/.config/wmbusmeters/wmbusmeters.conf`.)
The option `--useconfig=` can only be combined with a few other options: `--device= --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`

Wyświetl plik

@ -399,9 +399,13 @@ void handleExitAfter(Configuration *c, string after)
}
}
void handleOneshot(Configuration *c)
void handleOneshot(Configuration *c, string oneshot)
{
c->oneshot = true;
if (oneshot == "true") { c->oneshot = true; }
else if (oneshot == "false") { c->oneshot = false;}
else {
warning("No such oneshot setting: \"%s\"\n", oneshot.c_str());
}
}
void handleLogtelegrams(Configuration *c, string logtelegrams)
@ -672,7 +676,7 @@ shared_ptr<Configuration> loadConfiguration(string root, ConfigOverrides overrid
else if (p.first == "donotprobe") handleDoNotProbe(c, p.second);
else if (p.first == "listento") handleListenTo(c, p.second);
else if (p.first == "exitafter") handleExitAfter(c, p.second);
else if (p.first == "oneshot") handleOneshot(c);
else if (p.first == "oneshot") handleOneshot(c, p.second);
else if (p.first == "logtelegrams") handleLogtelegrams(c, p.second);
else if (p.first == "meterfiles") handleMeterfiles(c, p.second);
else if (p.first == "meterfilesaction") handleMeterfilesAction(c, p.second);
@ -746,7 +750,7 @@ shared_ptr<Configuration> loadConfiguration(string root, ConfigOverrides overrid
if (overrides.oneshot_override != "")
{
debug("(config) overriding oneshot with true\n");
handleOneshot(c);
handleOneshot(c, "true");
}
if (overrides.loglevel_override != "")

Wyświetl plik

@ -158,6 +158,9 @@ echo Slower tests...
tests/test_pipe.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_config_oneshot_exitafter.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_config_overrides.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi

Wyświetl plik

@ -0,0 +1,5 @@
loglevel=verbose
device=stdin:rtlwmbus
format=json
oneshot=true
exitafter=2

Wyświetl plik

@ -0,0 +1,4 @@
name=ApWater
driver=apator162
id=88888888
key=00000000000000000000000000000000

Wyświetl plik

@ -0,0 +1,4 @@
name=Vatten
driver=multical21
id=76348799
key=28F64A24988064A079AA2C807D6102AE

Wyświetl plik

@ -0,0 +1,4 @@
name=Wasser
driver=supercom587
id=77777777
key=5065747220486F6C79737A6577736B69

Wyświetl plik

@ -0,0 +1,63 @@
#!/bin/sh
PROG="$1"
if [ "$PROG" = "" ]
then
echo Please supply the binary to be tested as the first argument.
exit 1
fi
TEST=testoutput
rm -rf $TEST
mkdir -p $TEST
TESTNAME="Test config with oneshot"
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/config10 > $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
echo "ERROR: $TESTNAME ($0)"
echo "Expected stderr to print \"all meters have received at least one update\""
exit 1
fi
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]
then
echo "OK: $TESTNAME"
TESTRESULT="OK"
else
echo "ERROR: $TESTNAME"
exit 1
fi
TESTNAME="Test config with exitafter"
TESTRESULT="ERROR"
# Read from stdin
{ echo "Nada" ; sleep 4; } | $PROG --useconfig=tests/config10 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if ! grep -q "(serial) exit after " $TEST/test_stderr.txt
then
echo "ERROR: $TESTNAME ($0)"
echo "Expected stderr to print \"(serial) exit after\""
exit 1
else
echo "OK: $TESTNAME"
TESTRESULT=OK
fi
if [ "$TESTRESULT" = "ERROR" ]
then
echo "ERROR: $TESTNAME ($0)"
exit 1
fi