Restore functionality so that ANYID works with auto driver.

pull/799/head
Fredrik Öhrström 2023-01-10 22:08:14 +01:00
rodzic 554b91bc6b
commit cf074a147a
2 zmienionych plików z 46 dodań i 11 usunięć

Wyświetl plik

@ -792,6 +792,7 @@ bool MeterCommonImplementation::isTelegramForMeter(Telegram *t, Meter *meter, Me
// this particular driver, mfct, media, version combo
// is not registered in the METER_DETECTION list in meters.h
/*
if (used_wildcard)
{
// The match for the id was not exact, thus the user is listening using a wildcard
@ -800,7 +801,7 @@ bool MeterCommonImplementation::isTelegramForMeter(Telegram *t, Meter *meter, Me
verbose("(meter) ignoring telegram from %s since it matched a wildcard id rule but driver (%s) does not match.\n",
t->idsc.c_str(), driver_name.c_str());
return false;
}
}*/
// The match was exact, ie the user has actually specified 12345678 and foo as driver even
// though they do not match. Lets warn and then proceed. It is common that a user tries a
@ -808,7 +809,7 @@ bool MeterCommonImplementation::isTelegramForMeter(Telegram *t, Meter *meter, Me
if (isVerboseEnabled() || isDebugEnabled() || !warned_for_telegram_before(t, t->dll_a))
{
string possible_drivers = t->autoDetectPossibleDrivers();
if (t->beingAnalyzed() == false)
if (t->beingAnalyzed() == false && driver_name != "auto")
{
warning("(meter) %s: meter detection did not match the selected driver %s! correct driver is: %s\n"
"(meter) Not printing this warning again for id: %02x%02x%02x%02x mfct: (%s) %s (0x%02x) type: %s (0x%02x) ver: 0x%02x\n",

Wyświetl plik

@ -5,7 +5,7 @@ PROG="$1"
mkdir -p testoutput
TEST=testoutput
TESTNAME="Test ANYID"
TESTNAME="Test ANYID with explicit driver"
TESTRESULT="ERROR"
cat <<EOF | jq --sort-keys . > $TEST/test_expected.txt
@ -14,6 +14,7 @@ EOF
$PROG --format=json 2A442D2C998734761B168D2091D37CAC21576C7802FF207100041308190000441308190000615B7F616713 \
Vatten multical21 ANYID NOKEY 2>&1 | jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
@ -27,16 +28,49 @@ then
fi
fi
# Now test that anyid and auto does not work...
$PROG --verbose 2A442D2C998734761B168D2091D37CAC21576C7802FF207100041308190000441308190000615B7F616713 \
Vatten auto ANYID NOKEY > $TEST/test_output.txt 2>&1
TESTNAME="Test ANYID with auto driver"
if ! grep -o "ignoring telegram from 76348799" $TEST/test_output.txt > /dev/null
# Now test that anyid and auto >does< work...
$PROG --format=json 2A442D2C998734761B168D2091D37CAC21576C7802FF207100041308190000441308190000615B7F616713 \
Vatten auto ANYID NOKEY 2>&1 | jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
echo "Expected telegram to be ignored with auto + ANYID is used!"
TESTRESULT="ERROR"
else
echo "OK: Ignoring auto + ANYID"
cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
if [ "$?" = "0" ]
then
echo OK: $TESTNAME
TESTRESULT="OK"
else
TESTRESULT="ERROR"
fi
fi
TESTNAME="Test ANYID with auto but no driver found!"
cat <<EOF > $TEST/test_expected.txt
(meter) Vatten: meter detection could not find driver for id: 76348799 mfct: (KIM) Unknown (0x2d2d) type: Cold water meter (0x16) ver: 0x1b
(meter) please consider opening an issue at https://github.com/weetmuts/wmbusmeters/
(meter) to add support for this unknown mfct,media,version combination
{"media":"cold water","meter":"auto","name":"Vatten","id":"76348799","timestamp":"1111-11-11T11:11:11Z"}
EOF
# Now test that anyid and auto >does< work...
$PROG --format=json 2A442D2D998734761B168D2091D37CAC21576C7802FF207100041308190000441308190000615B7F616713 \
Vatten auto ANYID NOKEY > $TEST/test_output.txt 2>&1
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
if [ "$?" = "0" ]
then
echo OK: $TESTNAME
TESTRESULT="OK"
else
TESTRESULT="ERROR"
fi
fi
if [ "$TESTRESULT" = "ERROR" ]