Open robertoostenveld opened 5 years ago
Can you post your sketch? I suspect you're putting the parsed message in a global variable perhaps, so its contents are not cleared between runs (I'm not actually sure if there's a way to clear a parsed message right now, haven't checked the code).
Thanks for your reply. The sketch is esp8266_p1_thingspeak.ino from my arduino repository. The "MyData data" object/structure(?) is indeed global, which I could change.
It would be nice if your dsmr library would have a method to clear it, but feel free to close this issue if you are not planning to implement it.
I had a closer look at the code now, and I think the default constructors are available. I believe this means you should be able to write:
data = MyData();
to construct a new data object and assign it. You might even do:
data = {};
to call the default constructor without having to name the type, but I'm not sure if that's valid syntax.
That would probably solve your problem for now. I do wonder if this should perhaps happen automatically whenever parse()
is called? OTOH, that might be inefficient when it is not needed (e.g. when passing a fresh data object every time)...
My ISKRA AM550 sends messages like this according to Serial.println(reader.raw())
The first telegram is parsed correctly like this
The subsequent telegrams result in "Duplicate field" parse errors pointing to the very first ISK5\2M550E-1012 line. To work around this problem I commended out line 114 and 115 in parser.h. After that the parsing works (most of the times, sometimes there is some obvious junk in the message). However, I see that the identification field is growing in subsequent telegrams like this:
The same happens for
I suspect that this is might be the underlying cause of the "Duplicate field" parse errors, since it seems that the previous values are not cleared.
My C++ template skills are not good enough to figure out why this would happen. Right now my workaround is to ignore the parse errors by keeping line 114 and 155 commented out and by not including identification and electricity_failure_log in the ParsedData template.