Skip to content

Add raw CRC #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/dsmr/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ class P1Reader {

char buf[CrcParser::CRC_LEN];
for (uint8_t i = 0; i < CrcParser::CRC_LEN; ++i)
buf[i] = this->stream->read();
{
int c = this->stream->read();
buf[i] = (char)c;
crcBuffer.concat((char)c);
}

ParseResult<uint16_t> crc = CrcParser::parse(buf, buf + lengthof(buf));

Expand Down Expand Up @@ -188,6 +192,13 @@ class P1Reader {
return buffer;
}

/**
* Returns the crc read so far.
*/
const String &rawCrc() {
return crcBuffer;
}

/**
* If a complete message has been received, parse it and store the
* result into the ParsedData object passed.
Expand Down Expand Up @@ -217,6 +228,7 @@ class P1Reader {
void clear() {
if (_available) {
buffer = "";
crcBuffer = "";
_available = false;
}
}
Expand All @@ -234,6 +246,7 @@ class P1Reader {
bool once;
State state;
String buffer;
String crcBuffer;
uint16_t crc;
};

Expand Down