Added improved verbose message for received telegrams with failed crc checks.

pull/22/head
weetmuts 2019-04-13 23:59:33 +02:00
rodzic 545654772b
commit 6d7c88f4ab
2 zmienionych plików z 16 dodań i 11 usunięć

Wyświetl plik

@ -121,9 +121,8 @@ void WMBusRTLWMBUS::processSerialData()
FrameStatus status = checkRTLWMBUSFrame(read_buffer_, &frame_length, &hex_payload_len, &hex_payload_offset);
if (status == ErrorInFrame) {
verbose("(rtl_wmbus) protocol error in message received!\n");
debug("(rtl_wmbus) error in received message.\n");
string msg = bin2hex(read_buffer_);
debug("(rtl_wmbus) protocol error \"%s\"\n", msg.c_str());
read_buffer_.clear();
} else
if (status == FullFrame) {
@ -188,7 +187,15 @@ FrameStatus WMBusRTLWMBUS::checkRTLWMBUSFrame(vector<uchar> &data,
if (data[0] != 'T' && data[0] != 'C') return ErrorInFrame;
// And the checksums should match.
if (strncmp((const char*)&data[1], "1;1;1", 5)) return ErrorInFrame;
if (strncmp((const char*)&data[1], "1;1", 3)) {
// Packages that begin with C1;1 or with T1;1 are good. The full format is:
// MODE;CRC_OK;3OUTOF6OK;TIMESTAMP;PACKET_RSSI;CURRENT_RSSI;LINK_LAYER_IDENT_NO;DATAGRAM_WITHOUT_CRC_BYTES.
// 3OUTOF6OK makes sense only with mode T1 and no sense with mode C1 (always set to 1).
if (!strncmp((const char*)&data[1], "1;0", 3)) {
verbose("(rtlwmbus) telegram received but incomplete or with errors, since CRC checks failed.");
}
return ErrorInFrame;
}
}
// Look for start of telegram 0x
size_t i = 0;

Wyświetl plik

@ -2,24 +2,22 @@
PROG="$1"
mkdir -p testoutput
TEST=testoutput
rm -rf $TEST
mkdir -p $TEST
cat tests/rtlwmbus_water.sh | grep '^#{' | tr -d '#' > $TEST/test_expected.txt
$PROG --format=json "rtlwmbus:tests/rtlwmbus_water.sh" \
ApWater apator162 88888888 00000000000000000000000000000000 \
| grep -v "(rtlwmbus) child process exited! Command was:" \
> $TEST/test_output.txt
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
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 RTLWMBUS OK
fi
echo RTLWMBUS OK
else
echo Failure.
exit 1