Giter Club home page Giter Club logo

Comments (3)

KLelong avatar KLelong commented on June 16, 2024

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.

KLelong avatar KLelong commented on June 16, 2024

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.

KLelong avatar KLelong commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.