diff --git a/src/wmbus.cc b/src/wmbus.cc index 4da2436..2f541ac 100644 --- a/src/wmbus.cc +++ b/src/wmbus.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2022 Fredrik Öhrström (gpl-3.0-or-later) + Copyright (C) 2017-2023 Fredrik Öhrström (gpl-3.0-or-later) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4143,6 +4143,16 @@ bool BusDeviceCommonImplementation::handleTelegram(AboutTelegram &about, vector< return true; } + if (about.type == FrameType::WMBUS) + { + size_t len = frame[0]+1; + if (frame.size() > 0 && len != frame.size()) + { + warning("(wmbus) telegram length byte (the first) 0x%02x (%d) is probably wrong. Expected 0x%02x (%zu) based on the length of the telegram.\n", + frame[0], frame[0], len, len); + } + } + for (auto f : telegram_listeners_) { if (f) diff --git a/src/wmbus_simulator.cc b/src/wmbus_simulator.cc index 4cef33c..d98b689 100644 --- a/src/wmbus_simulator.cc +++ b/src/wmbus_simulator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2020 Fredrik Öhrström (gpl-3.0-or-later) + Copyright (C) 2019-2023 Fredrik Öhrström (gpl-3.0-or-later) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/test_listen_to_all.sh b/tests/test_listen_to_all.sh index 12cc13d..6152a10 100755 --- a/tests/test_listen_to_all.sh +++ b/tests/test_listen_to_all.sh @@ -70,6 +70,7 @@ Received telegram from: 58234965 type: Heat meter (0xc3) ver: 0x27 driver: vario451 +(wmbus) telegram length byte (the first) 0x31 (49) is probably wrong. Expected 0x32 (50) based on the length of the telegram. Received telegram from: 11776622 manufacturer: (TCH) Techem Service (0x5068) type: Heat Cost Allocator (0x80) diff --git a/tests/test_logfile.sh b/tests/test_logfile.sh index 8c4a8e1..5449535 100755 --- a/tests/test_logfile.sh +++ b/tests/test_logfile.sh @@ -55,7 +55,7 @@ RES=$(cat $TEST/thelog2.txt | tr '\n' ' ' | tr -d ' ' | sed 's/|+1 /|+0 /g' ) # The sed replacement reduces the risk of a failing test when the second counter happens to flip within the test run. -EXP=$(printf 'telegram=|A244EE4D785634123C067A8F000000_0C1348550000426CE1F14C130000000082046C21298C0413330000008D04931E3A3CFE3300000033000000330000003300000033000000330000003300000033000000330000003300000033000000330000004300000034180000046D0D0B5C2B03FD6C5E150082206C5C290BFD0F0200018C4079678885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|A244EE4D111111113C077AAC000000_0C1389490000426CE1F14C130000000082046C21298C0413010000008D04931E3A3CFE0100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000001600000031130000046D0A0C5C2B03FD6C60150082206C5C290BFD0F0200018C4079629885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|1E44AE4C9956341268077A36001000_2F2F0413181E0000023B00002F2F2F2F|+0 telegram=|1844AE4C4455223368077A55000000_041389E20100023B0000|+0' | tr '\n' ' ' | tr -d ' ') +EXP=$(printf 'telegram=|A244EE4D785634123C067A8F000000_0C1348550000426CE1F14C130000000082046C21298C0413330000008D04931E3A3CFE3300000033000000330000003300000033000000330000003300000033000000330000003300000033000000330000004300000034180000046D0D0B5C2B03FD6C5E150082206C5C290BFD0F0200018C4079678885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|A244EE4D111111113C077AAC000000_0C1389490000426CE1F14C130000000082046C21298C0413010000008D04931E3A3CFE0100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000001600000031130000046D0A0C5C2B03FD6C60150082206C5C290BFD0F0200018C4079629885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|1E44AE4C9956341268077A36001000_2F2F0413181E0000023B00002F2F2F2F|+0 telegram=|1844AE4C4455223368077A55000000_041389E20100023B0000|+0(wmbus)telegramlengthbyte(thefirst)0x31(49)isprobablywrong.Expected0x32(50)basedonthelengthofthetelegram.' | tr '\n' ' ' | tr -d ' ') if [ "$RES" != "$EXP" ] then