Created
April 4, 2019 16:14
-
-
Save mrvdb/ba197ea41f8c3ebfc61cb0979cadfdd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/dsmr.h b/src/dsmr.h | |
index ced73ec..73b368c 100644 | |
--- a/src/dsmr.h | |
+++ b/src/dsmr.h | |
@@ -32,6 +32,10 @@ | |
#ifndef DSMR_INCLUDE_DSMR_H | |
#define DSMR_INCLUDE_DSMR_H | |
+// Workaround for isolatiing support DSMR2.2 (kinda) | |
+// - no checksum after the '!' | |
+// - slave gas comes in without OBIS id | |
+#define DSMR22 | |
#include "dsmr/parser.h" | |
#include "dsmr/reader.h" | |
#include "dsmr/fields.h" | |
diff --git a/src/dsmr/parser.h b/src/dsmr/parser.h | |
index 68805a6..2778199 100644 | |
--- a/src/dsmr/parser.h | |
+++ b/src/dsmr/parser.h | |
@@ -402,7 +402,12 @@ struct P1Parser { | |
ParseResult<ObisId> idres = ObisIdParser::parse(line, end); | |
if (idres.err) | |
+#ifdef DSMR22 | |
+ // No OBIS id, just ignore the line (it's probably gas) | |
+ return res; | |
+#else | |
return idres; | |
+#endif | |
ParseResult<void> datares = data->parse_line(idres.result, idres.next, end); | |
if (datares.err) | |
diff --git a/src/dsmr/reader.h b/src/dsmr/reader.h | |
index 61b8742..3ded0a1 100644 | |
--- a/src/dsmr/reader.h | |
+++ b/src/dsmr/reader.h | |
@@ -119,6 +119,7 @@ class P1Reader { | |
bool loop() { | |
while(true) { | |
if (state == State::CHECKSUM_STATE) { | |
+#ifndef DSMR22 | |
// Let the Stream buffer the CRC bytes. Convert to size_t to | |
// prevent unsigned vs signed comparison | |
if ((size_t)this->stream->available() < CrcParser::CRC_LEN) | |
@@ -129,11 +130,13 @@ class P1Reader { | |
buf[i] = this->stream->read(); | |
ParseResult<uint16_t> crc = CrcParser::parse(buf, buf + lengthof(buf)); | |
- | |
+#endif | |
// Prepare for next message | |
state = State::WAITING_STATE; | |
+#ifndef DSMR22 | |
if (!crc.err && crc.result == this->crc) { | |
+#endif | |
// Message complete, checksum correct | |
this->_available = true; | |
@@ -141,7 +144,9 @@ class P1Reader { | |
this->disable(); | |
return true; | |
+#ifndef DSMR22 | |
} | |
+#endif | |
} else { | |
// For other states, read bytes one by one | |
int c = this->stream->read(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment