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

Add a HexStringField parser. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

middelink
Copy link

Add a HexStringField parser which understands some DSMRs encode the equipement ids as hex strings.

For example my Dutch DSMR sends out 0-0:96.1.1(4530303639303030373138323035333231) but in reality this should be E0069000718205321 (which matches the id on the front of the unit).

@middelink
Copy link
Author

ping?

@middelink
Copy link
Author

more ping

@middelink middelink force-pushed the master branch 2 times, most recently from bbd9de3 to 411d081 Compare August 9, 2023 13:46
@xabolcs
Copy link

xabolcs commented Nov 4, 2023

Hi @middelink , thanks for adding this parser!

Would you mind changing electricity_tariff (0-0:96.14.0.255) parser to HexStringField?
From the documentation it's format is "S4, tag 9"

6.5 Representation of COSEM Data Type octet-string (tag 9)
COSEM Data Type octet-string is represented with Sn format where octets are formatted
with hexadecimal characters. Octet-string length is implicit.

  1. XX Hexadecimal characters for first octet
  2. XX Hexadecimal characters for second octet
  3. XX Hexadecimal characters for m-th octet (m is octet-string length).
    Note: An octet string or bit string with a length of m, will result in a Alphanumeric string Sn
    with a length of n, where n is 2 times m

@xabolcs
Copy link

xabolcs commented Nov 4, 2023

@glmnet , would you mind reviewing and merging this PR?
Looks like the electricity_tariff isn't just a text but a hex-encoded text.

@middelink
Copy link
Author

@xabolcs I'm not 100% sure that would be advisable. Om my meter the value reads "0001" or "0002", which if interpreted as a hex string would become "\x00\x01" or "\x00\02", which is not a string normal humans handle well.

If anything it would require a HexIntField function, converting hex numbers to a int.

What are the values you are seeing? "3031" and "3032" ?

@xabolcs
Copy link

xabolcs commented Nov 4, 2023

🤔

Meh, my values (from Hungary) don't follow the standard too, as my meter shows 0001 and 0002 too.

[15:54:07][D][uart_debug:158]: <<< "0-0:96.14.0(0002)\r\n"

It just doesn't make much sense to differ only in encoding from the standard and send an integer as a four bytes string (S4).

Sorry for the noise. 😕

@middelink
Copy link
Author

@xabolcs no worries. Out of curiosity, what does your equipment_id string look like? 0-0:96.1.1

@xabolcs
Copy link

xabolcs commented Nov 4, 2023

@middelink, its a Sanxing SX601/S12U16 (2022) from EON Hungary ... and it doesn't provide such element, just it's serial number (as the first line and in 0-0:96.1.0). 🙃

[16:28:47][D][uart_debug:158]: <<< "/AUX59903049099\r\n"
[16:28:47][D][uart_debug:158]: <<< "\r\n"
[16:28:47][D][uart_debug:158]: <<< "0-0:1.0.0(231104162850W)\r\n"
[16:28:47][D][uart_debug:158]: <<< "0-0:42.0.0(AUX1020303049099)\r\n"
[16:28:47][D][uart_debug:158]: <<< "0-0:96.1.0(9903049099)\r\n"
[16:28:47][D][uart_debug:158]: <<< "0-0:96.14.0(0002)\r\n"
[16:28:47][D][uart_debug:158]: <<< "0-0:96.50.68(ON)\r\n"

@geduxas
Copy link

geduxas commented Nov 4, 2023

According IEC standart, 0.96 are used for manufacture specific needs... So in different devices values maybe different..

Screenshot_2023-11-04-20-21-02-70_e2d5b3f32b79de1d45acd1fad96fbb0f

@middelink
Copy link
Author

yeah, thats why the hexstrings falls back to a normal string if the content is not "hexy" enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants