From 363f59a149627ba53dbfbcd8558ed72fe4931968 Mon Sep 17 00:00:00 2001 From: Jakob Skov-Pedersen Date: Mon, 11 Mar 2013 09:22:52 +0100 Subject: [PATCH 1/2] Ignore filler DIF (= 0x2F) --- mbus/mbus-protocol.c | 6 ++++++ test/test-frames/wmbus-converted.hex | 1 + test/test-frames/wmbus-converted.xml | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/test-frames/wmbus-converted.hex create mode 100644 test/test-frames/wmbus-converted.xml diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 69917ca..b0c537d 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2677,6 +2677,12 @@ mbus_data_variable_parse(mbus_frame *frame, mbus_data_variable *data) while (i < frame->data_size) { + // Skip filler dif=2F + while (((frame->data[i] & 0xFF) == 0x2F) && (i < frame->data_size)) { + i++; + } + if (i == frame->data_size) break; + if ((record = mbus_data_record_new()) == NULL) { // clean up... diff --git a/test/test-frames/wmbus-converted.hex b/test/test-frames/wmbus-converted.hex new file mode 100644 index 0000000..c6a6996 --- /dev/null +++ b/test/test-frames/wmbus-converted.hex @@ -0,0 +1 @@ +68 1f 1f 68 08 00 72 31 77 67 17 2d 2c 01 02 00 00 00 00 2f 2f 04 83 3b 88 13 00 00 2f 2f 2f 2f 2f 2f 2f 00 16 diff --git a/test/test-frames/wmbus-converted.xml b/test/test-frames/wmbus-converted.xml new file mode 100644 index 0000000..ec235a9 --- /dev/null +++ b/test/test-frames/wmbus-converted.xml @@ -0,0 +1,21 @@ + + + + 17677731 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + Energy (Wh) + 5000 + 1970-01-01T00:00:00 + + + From 6166553755dfee1bfb509d17a83050c21e9826e7 Mon Sep 17 00:00:00 2001 From: Jakob Skov-Pedersen Date: Sun, 17 Mar 2013 09:15:43 +0100 Subject: [PATCH 2/2] Make my last change more readable. As suggested by lategoodbye. Also make it more in line with the way everything else is written. --- mbus/mbus-protocol.c | 5 +++-- mbus/mbus-protocol.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index b0c537d..88cf474 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2678,10 +2678,11 @@ mbus_data_variable_parse(mbus_frame *frame, mbus_data_variable *data) while (i < frame->data_size) { // Skip filler dif=2F - while (((frame->data[i] & 0xFF) == 0x2F) && (i < frame->data_size)) { + if ((frame->data[i] & 0xFF) == MBUS_DIB_DIF_IDLE_FILLER) + { i++; + continue; } - if (i == frame->data_size) break; if ((record = mbus_data_record_new()) == NULL) { diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index ac5069b..1263417 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -129,6 +129,7 @@ typedef struct _mbus_slave_data { #define MBUS_DIB_VIF_EXTENSION_BIT 0x80 #define MBUS_DIB_DIF_MANUFACTURER_SPECIFIC 0x0F #define MBUS_DIB_DIF_MORE_RECORDS_FOLLOW 0x1F +#define MBUS_DIB_DIF_IDLE_FILLER 0x2F typedef struct _mbus_data_information_block {