DLMS is not easy protocol. Add and initialize register objects in same way that clock1 is added.
Then read values in loop.
Somethig like;
gxRegister r1;
- I am using low authentication
- com_initializeConnection return OK.
I tried reading current, voltage registers using the code sample you gave above.
- current: cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , "1.0.31.7.0.255")
- voltage: cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , "1.0.32.7.0.255")
Reading current, voltage returns DLMS_ERROR_CODE_UNAVAILABLE_OBJECT.
I tried reading profile generic( gxProfileGeneric ), but it also returns unavailable object.
- gxProfileGeneric p1;
- cosem_init(BASE(p1), DLMS_OBJECT_TYPE_PROFILE_GENERIC , "1.0.94.91.0.255")
- com_read(BASE(p1), 2)
If you want to use Low aithentication you need to change initial settings for the client.
Change this:
cl_init(&meterSettings, 1, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
to;
cl_init(&meterSettings, 1, 16, 1, DLMS_AUTHENTICATION_LOW, "YOUR PASSWORD", DLMS_INTERFACE_TYPE_HDLC);
You also need to change the client address from 16 (0x10) to example 32 (0x20). I don't know what meter you try to read, so I don't know the right value. Try to read the meter with GXDLMSDirector and copy the value from there.
BR,
Mikko
DLMS is a standard and it's very well documented.
There are several documents that you need to read.
• IEC 62056-21 Direct local data exchange
• IEC 62056-42 Physical Layer Services and Procedures for Connection-Oriented Asynchronous Data Exchange
• IEC 62056-46 Data link layer using HDLC protocol
• IEC 62056-47 COSEM transport layers for IPv4 networks
• IEC 62056-53 COSEM application layer
• IEC 62056-61 OBIS Object identification system
• IEC 62056-62 Interface objects
• India Standard 15959 (Part-1) 2011: Data exchange for electricity meter reading, tariff and load control: companion specification
• India Standard 15959 (Part-2) 2016: Data exchange for electricity meter reading, tariff and load control: companion specification part2 for smart meter
• Italy Standard UNI/TS 11291-11-2
I am calling cl_init:
cl_init(&meterSettings, 1, 32, 1, DLMS_AUTHENTICATION_LOW, "ABCD0001", DLMS_INTERFACE_TYPE_HDLC);
in setup
and in loop I read 3-4 registers:
ret = com_initializeConnection(); // open conn
cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , OBIS_VOLTAGE_R); // read V(R)
ret = com_read(BASE(r1), 2);
cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , OBIS_VOLTAGE_Y); // read V(Y)
ret = com_read(BASE(r1), 2);
ret = com_close();
The problem arises from the second iteration of the loop.
The com_initializeConnection returns DLMS_ERROR_CODE_AUTHENTICATION_FAILURE
If I called cl_init again on every loop iteration, it works fine.
I wanted to ask if cl_init is required everytime before openning connection ?
Hello,
Hello,
DLMS is not easy protocol. Add and initialize register objects in same way that clock1 is added.
Then read values in loop.
Somethig like;
gxRegister r1;
void setup() {
bb_init(&frameData);
//Set frame size.
bb_capacity(&frameData, 128);
cl_init(&meterSettings, 1, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER, "OBIS CODE");
// start serial port at 9600 bps:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
int ret;
//Initialize connection.
ret = com_initializeConnection();
if (ret != DLMS_ERROR_CODE_OK)
{
return;
}
//Read register.
ret = com_read(BASE(r1), 2);
if (ret != DLMS_ERROR_CODE_OK)
{
return;
}
com_close();
}
BR,
Mikko
Hello,
Hello,
Thank you for your prompt response.
- I am using low authentication
- com_initializeConnection return OK.
I tried reading current, voltage registers using the code sample you gave above.
- current: cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , "1.0.31.7.0.255")
- voltage: cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , "1.0.32.7.0.255")
Reading current, voltage returns DLMS_ERROR_CODE_UNAVAILABLE_OBJECT.
I tried reading profile generic( gxProfileGeneric ), but it also returns unavailable object.
- gxProfileGeneric p1;
- cosem_init(BASE(p1), DLMS_OBJECT_TYPE_PROFILE_GENERIC , "1.0.94.91.0.255")
- com_read(BASE(p1), 2)
Can you tell me what does this error code means ?
Thank you Again. :)
Hi,
Hi,
If you want to use Low aithentication you need to change initial settings for the client.
Change this:
cl_init(&meterSettings, 1, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
to;
cl_init(&meterSettings, 1, 16, 1, DLMS_AUTHENTICATION_LOW, "YOUR PASSWORD", DLMS_INTERFACE_TYPE_HDLC);
You also need to change the client address from 16 (0x10) to example 32 (0x20). I don't know what meter you try to read, so I don't know the right value. Try to read the meter with GXDLMSDirector and copy the value from there.
BR,
Mikko
Hello,
Hello,
I talked with the manufacturer, they gave me AARQ REQUEST bytes that should be sent:
7E A0 48 03 41 10 87 76 E6 E6 00 60 3A 80 02 02 84 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 30 30 30 31 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 18 19 FF FF EB AB 7E
Can you tell me how on cl_init should be configured by this ?
Hi,
Hi,
Change the password and all the settings are correct.
cl_init(&meterSettings, 1, 32, 1, DLMS_AUTHENTICATION_LOW, "ABCD0001", DLMS_INTERFACE_TYPE_HDLC);
BR,
Mikko
Hello,
Hello,
This worked like a charm.
Thank you very much.
Thank you for decoding the binary stream for me.
Can you point be to the documentation so that I can understand the protocol or at least help me decoding this kind of DLMS binary stream ?
Thank you :)
Hi,
Hi,
DLMS is a standard and it's very well documented.
There are several documents that you need to read.
• IEC 62056-21 Direct local data exchange
• IEC 62056-42 Physical Layer Services and Procedures for Connection-Oriented Asynchronous Data Exchange
• IEC 62056-46 Data link layer using HDLC protocol
• IEC 62056-47 COSEM transport layers for IPv4 networks
• IEC 62056-53 COSEM application layer
• IEC 62056-61 OBIS Object identification system
• IEC 62056-62 Interface objects
• India Standard 15959 (Part-1) 2011: Data exchange for electricity meter reading, tariff and load control: companion specification
• India Standard 15959 (Part-2) 2016: Data exchange for electricity meter reading, tariff and load control: companion specification part2 for smart meter
• Italy Standard UNI/TS 11291-11-2
BR,
Mikko
Hello,
Hello,
Will read these spcifications.
Thank you very much.
Hello,
Hello,
I am calling cl_init:
cl_init(&meterSettings, 1, 32, 1, DLMS_AUTHENTICATION_LOW, "ABCD0001", DLMS_INTERFACE_TYPE_HDLC);
in setup
and in loop I read 3-4 registers:
ret = com_initializeConnection(); // open conn
cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , OBIS_VOLTAGE_R); // read V(R)
ret = com_read(BASE(r1), 2);
cosem_init(BASE(r1), DLMS_OBJECT_TYPE_REGISTER , OBIS_VOLTAGE_Y); // read V(Y)
ret = com_read(BASE(r1), 2);
ret = com_close();
The problem arises from the second iteration of the loop.
The com_initializeConnection returns DLMS_ERROR_CODE_AUTHENTICATION_FAILURE
If I called cl_init again on every loop iteration, it works fine.
I wanted to ask if cl_init is required everytime before openning connection ?
Thank you.
Hi,
Hi,
Example reset all client settings after the read. This is done to release all buffers.
Find com_close and comment cl_clear(&connection->settings);
Now you can connect as many times as you want to.
BR,
Mikko