Skip to content
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

Unsigned current Power Value #101

Closed
SirkoVZ opened this issue Mar 29, 2021 · 9 comments
Closed

Unsigned current Power Value #101

SirkoVZ opened this issue Mar 29, 2021 · 9 comments
Labels

Comments

@SirkoVZ
Copy link

SirkoVZ commented Mar 29, 2021

According to the SML protocol
https://www.vde.com/resource/blob/951000/252eb3cdf1c7f6cdea10847be399da0d/fnn-lastenheft-edl-1-0-2010-01-13-data.pdf
page 31 the direction (consumption or delivery) is marked using flag.
It seems the SMLlib is not honoring the flag, as it always shows positive values, even when delivering power.
At least in the EMZ ED300L no negative values are shown when delivering power
The (un)sign seems to be addressed already in Tasmota:
arendst/Tasmota#8001 (comment)
and finally in
arendst/Tasmota@61b9735
Maybe we can also add this in the SML lib...

@r00t-
Copy link
Collaborator

r00t- commented Mar 29, 2021

can you attach or link binary dumps of sml transmissions with both variants?
(to enable developing/testing an implementation without owning an affected meter.)

@SirkoVZ
Copy link
Author

SirkoVZ commented Mar 29, 2021

How do I do that?
dd if=/dev/ttyAMA0 of=/tmp/dumpfile.bin bs=1 count=4096 iflag=fullblock
creates an empty file, while vzlogger works properly using /dev/ttyAMA0

@r00t-
Copy link
Collaborator

r00t- commented Mar 29, 2021

@SirkoVZ:
in theory that should work,
bute note that using dd is never necessary, and kind of silly on a character device.
just cat /dev/ttyAMA0 >logfile
if in doubt also try xxd </dev/ttyAMA0 (a hexdump also works, as it can be converted back. and actually it can simply be posted here as text.)

@r00t-
Copy link
Collaborator

r00t- commented Mar 29, 2021

oh, look, it's all here:
https://github.com/devZer0/libsml-testing
you could just submit your dumps right there

SirkoVZ added a commit to SirkoVZ/libsml-testing that referenced this issue Mar 30, 2021
Delivery is not marked by by negative sign in EMH ED300L, but there is an flag in the SML protocol, please see
volkszaehler/libsml#101
@r00t-
Copy link
Collaborator

r00t- commented Mar 31, 2021

yay, data!

first results look good:
i added this:

[~/libsml]$ git diff examples/
diff --git a/examples/sml_server.c b/examples/sml_server.c
index 1de47bc..83a775b 100644
--- a/examples/sml_server.c
+++ b/examples/sml_server.c
@@ -131,6 +131,12 @@ void transport_receiver(unsigned char *buffer, size_t buffer_len) {
                                        if (prec < 0)
                                                prec = 0;
                                        value = value * pow(10, scaler);
+                                       if (entry->status)
+                                               printf(
+                                                       "status: %x (type %x)\n",
+                                                       *(entry->status->data.status16),
+                                                       entry->status->type & SML_TYPE_FIELD
+                                               );
                                        printf("%d-%d:%d.%d.%d*%d#%.*f#",
                                                entry->obj_name->str[0], entry->obj_name->str[1],
                                                entry->obj_name->str[2], entry->obj_name->str[3],

and get:

[~/libsml]$ ./examples/sml_server -v - <../libsml-testing/EMH-ED300L_consumption.bin | grep -A1 status
status: 182 (type 60)
1-0:1.8.0*255#17243368.3#Wh
[~/libsml]$ ./examples/sml_server -v - <../libsml-testing/EMH-ED300L_delivery.bin  | grep -A1 status
status: 1b0 (type 60)
1-0:1.8.0*255#17243675.6#Wh
--
status: 1b0 (type 60)
1-0:1.8.0*255#17243675.6#Wh

consumption = 0x182 = 0b110000010
delivery: 0x1B0 = 0b110110000

(the values differ from those in arendst/Tasmota#8001 (comment) because it's a bit-field, each bit has a separate meaning.)

according to the docs
https://www.vde.com/resource/blob/951000/252eb3cdf1c7f6cdea10847be399da0d/fnn-lastenheft-edl-1-0-2010-01-13-data.pdf

bit 5 Energierichtung 0 <=> +A; 1 <=> -A.

so indeed in the delivery case, bit 5 is 1!

the code in tasmota is using & 0x20 = 0b100000, also bit 5:
arendst/Tasmota@61b9735#diff-97c9ae02f894436fc4188ce195998aa3d258fed1e78d21239c11c0c8539d01e5R1053

(it's a bit annoying that the status field is attached to the energy (Wh) reading, and not to the power (W) reading,
so one can not trivially apply that bit as a sign bit to the value of the (power) reading.)

@r00t-
Copy link
Collaborator

r00t- commented Mar 31, 2021

@SirkoVZ:
are you using vzlogger or some other utility using libsml?

i'm not sure if this should be implemented in libsml or in it's user.
it seems to me that at the sml level, libsml extracts the data just fine,
the meaning of the bits in the status field is not defined by sml itself,
but in that vde document ("Ausführungsvariante SML").
(just like the meaning of the obis numbers i guess)
so it doesn't seem that there's any need to change anything in libsml itself.

@r00t-
Copy link
Collaborator

r00t- commented Mar 31, 2021

@SirkoVZ:
volkszaehler/vzlogger#476 has an experimental implementation for vzlogger that works with the data in your dumps

@SirkoVZ
Copy link
Author

SirkoVZ commented Mar 31, 2021

I can confirm that it is working... more details later,

thanks so far :-)

@r00t-
Copy link
Collaborator

r00t- commented Apr 2, 2021

closing this, as it's out of the scope of libsml, see volkszaehler/vzlogger#431

@r00t- r00t- closed this as completed Apr 2, 2021
@r00t- r00t- added the wontfix label Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants