u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
80 stars 41 forks source link

Short name referencing #50

Open zenobik opened 3 years ago

zenobik commented 3 years ago

Hello, It would be nice to add "Short name referencing" association method. I have PAFAL 16EC3rn/1 meter and when I try to associate with it I get error:

"ValueError("vaa-name in InitateResponse is not \x00\x07")".

I comented out this line and now I have error:

"AARE requests use of Short Name referencing which is not " "supported.".

Hope you will keep developing this great project ! :smile:

Krolken commented 3 years ago

Yeah. Short Name refs are something I didn't want to do unless I got paid to do it. It is mostly used in old meters. I don't know any new ones that are not using long name refs. And you can't really reuse anything. It uses its own services for reading and writing etc. And I can't get hold of a meter for the lab either.

But are you sure it is uses DLMS? It could also be using IEC62056-21. Try our other lib out: https://github.com/pwitab/iec62056-21

zenobik commented 3 years ago

I'm pretty sure that it's not 62056-21 because I know really good this protocol and I even wrote C library to communicate with older meters using this protocol. Debug logs shows that meter answered for HDLC frame:

10:26:04,679 : DEBUG : HDLC state transitioned from NOT_CONNECTED to AWAITING_CONNECTION
10:26:04,680 : DEBUG : Sending: bytearray(b'~\xa0\x07\x03!\x93\x0f\x01~')
10:26:04,726 : DEBUG : Received HDLC data: b'~\xa0\x1e!\x03s\xc3z\x81\x80\x12\x05\x01\x80\x06\x01\x80\x07\x04\x00\x00\x00\x01\x08\x04\x00\x00\x00\x01S;~'
10:26:04,729 : DEBUG : Received frame: UnNumberedAcknowledgmentFrame(destination_address=HdlcAddress(logical_address=16, physical_address=None, address_type='client'), source_address=HdlcAddress(logical_address=1, physical_address=None, address_type='server'), payload=bytearray(b'\x81\x80\x12\x05\x01\x80\x06\x01\x80\x07\x04\x00\x00\x00\x01\x08\x04\x00\x00\x00\x01'), segmented=False, final=True)

But thanks for your fast reply! Maybe you are right that SN referencing is obsolete. I will try with other meters.

Krolken commented 3 years ago

OK. Yeah if you are getting HDLC frames back it might not support the IEC62056-21. But some support both (or it is an internal setting) I did a quick google of the meter since I have not heard of it before and found this: https://github.com/yahbluez/pafalEC3/blob/master/cron_pafal.py which seems like someone using IEC62056-21 to read the meter.

zenobik commented 3 years ago

This one supports both, but 62056-21 is on IR port and DLMS is on wired RS485 port. And of course I'm currently connected to RS485 wired port :smile: So I can read all the values with 62056-21 with IR but it's not as practical in use as the wired RS485 port.

Krolken commented 3 years ago

Ah. So annoying 😭

Ill leave this issue open and mark it with sposorship needed in case someone else is wondering about SN refs.