Comments (3)
I did dig into the source of reader.h.
I added some debug-statements and the problem is the checksum is not valid.
For this (raw telegram from the parse example) :
/KFM5KAIFA-METER
1-3:0.2.8(40)
0-0:1.0.0(150117185916W)
0-0:96.1.1(0000000000000000000000000000000000)
1-0:1.8.1(000671.578*kWh)
1-0:1.8.2(000842.472*kWh)
1-0:2.8.1(000000.000*kWh)
1-0:2.8.2(000000.000*kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.333*kW)
1-0:2.7.0(00.000*kW)
0-0:17.0.0(999.9*kW)
0-0:96.3.10(1)
0-0:96.7.21(00008)
0-0:96.7.9(00007)
1-0:99.97.0(1)(0-0:96.7.19)(000101000001W)(2147483647*s)
1-0:32.32.0(00000)
1-0:32.36.0(00000)
0-0:96.13.1()
0-0:96.13.0()
1-0:31.7.0(001*A)
1-0:21.7.0(00.332*kW)
1-0:22.7.0(00.000*kW)
0-1:24.1.0(003)
0-1:96.1.0(0000000000000000000000000000000000)
0-1:24.2.1(150117180000W)(00473.789*m3)
0-1:24.4.0(1)
!6F4A
I get a checksum of 26A3
My code (modified loop-function of reader.h) :
bool loop() {
while(true) {
if (state == State::CHECKSUM_STATE) {
// Let the Stream buffer the CRC bytes. Convert to size_t to
// prevent unsigned vs signed comparison
Serial.println("\nchecksumming");
if ((size_t)this->stream->available() < CrcParser::CRC_LEN)
return false;
Serial.println("check no prob 1");
char buf[CrcParser::CRC_LEN];
for (uint8_t i = 0; i < CrcParser::CRC_LEN; ++i)
buf[i] = this->stream->read();
ParseResult<uint16_t> crc = CrcParser::parse(buf, buf + lengthof(buf));
// Prepare for next message
state = State::WAITING_STATE;
if (!crc.err && crc.result == this->crc) {
// Message complete, checksum correct
this->_available = true;
Serial.println("checksum OK");
if (once)
this->disable();
return true;
}
else {
Serial.print("checksum problem : ");
Serial.print(this->crc, HEX);
Serial.print(" # ");
Serial.println(crc.result, HEX);
}
} else {
// For other states, read bytes one by one
int c = this->stream->read();
if (c < 0)
return false;
switch (this->state) {
case State::DISABLED_STATE:
// Where did this byte come from? Just toss it
break;
case State::WAITING_STATE:
if (c == '/') {
this->state = State::READING_STATE;
// Include the / in the CRC
this->crc = _crc16_update(0, c);
this->clear();
}
break;
case State::READING_STATE:
// Include the ! in the CRC
this->crc = _crc16_update(this->crc, c);
if (c == '!')
this->state = State::CHECKSUM_STATE;
else
buffer.concat((char)c);
break;
case State::CHECKSUM_STATE:
// This cannot happen (given the surrounding if), but the
// compiler is not smart enough to see this, so list this
// case to prevent a warning.
abort();
break;
}
Serial.print(char(c));
}
}
return false;
}
Is that telegram from the parse-example real ?
Is there anyone who can provide me with a real telegram, or more than one, preferably ?
from arduino-dsmr.
I have a number of examles that sent to the device, everytime, the chechsum was wrong. When I manually modified that checksum with the result I got from the above patch, I got readings.
So for some reason, the checksum is calculated wrong in my tests. Any idea why ?
Those examples are from the version of rvdbreemen.
from arduino-dsmr.
I found the problem with checksums : unix/dos differences.
I'm working under linux, so when I edit files the line-endings are LF (0x0A) while the DSMR outputs CR/LF (0x0D 0x0A).
I changed the file to DOS, then the checksums are OK.
Up to the next problem : Belgian fields. I know there are some forks implementing them, so I will look into those.
from arduino-dsmr.
Related Issues (20)
- Belgium DSMR does not parse correctly HOT 26
- Bug in parsing logic HOT 2
- Allow customizing mbus id allocations HOT 9
- Doesn't compile on with Arduino 1.8.12?
- Error: a reinterpret_cast is not a constant expression HOT 6
- Problem compiling demo code HOT 3
- reader.available() remains false using Wemos d1 mini HOT 2
- ESP 3.0.0 HOT 7
- Support more OBIS codes so that the parser can be used in more countries HOT 1
- Cannot assign to String with latest Arduino after fix for Error: a reinterpret_cast is not a constant expression HOT 3
- Not able to read timestamps from TimestampedFixedValue HOT 1
- How to access items in a log ? HOT 1
- Update Library on PlatformIO Registry HOT 2
- Baud rate check in header parsing too strict HOT 5
- Timestamp no processed
- T211 DSMR5 meter does not send a unit for unlinked gas meter, causing 'missing unit' errors HOT 1
- [Question] Can the P1Parser class be used on Windows or Linux PC hardware or on a microcontroller without Arduino library? HOT 6
- arduino-dsmr niet werkt op nieuwe esp8266 lib HOT 6
- Unable to build for ESP32 Dev Module HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-dsmr.