Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Arduino DLMS Server

Arduino DLMS Server

By William Lopes, 6 October, 2024
Forums
General discussion

Gurux DLMS for Arduino IDE

William Lopes

8 months 1 week ago

I'm trying to use the server…

I'm trying to use the server implementation for Arduino using the Mega 2560 module.
I'm having problems in the CONFORMANCE negotiation phase, and I can't move forward.

The error message: Exception response. "Service not allowed". Service not supported.

Can you help me?

This is the server initialization.
Serial port COM4 opened

addAssociationLow
addAssociationHigh
Conformance: 12089344
Call - loadSettings
loadSettings
ser_loadObjects - Serialize objects to bytebuffer. succeeded.
Meter started.
Communication speed 9600
Test mode Is ON.
LLS password: Gurux
HLS password: Gurux
saveObjects succeeded. Index: 729
Count: 2
saveObjects succeeded. Index: 729
Count: 2
EEPROM size 4096
Server started.
svr_preAction: 40 0.0.25.9.0.255
saveObjects succeeded. Index: 729
Count: 2
saveObjects succeeded. Index: 729
Count: 2
sendPush40 0.0.25.9.0.255
svr_preRead: 1 0.0.42.0.0.255
svr_postRead: 1 0.0.42.0.0.255
svr_preRead: 40 0.0.25.9.0.255
svr_postRead: 40 0.0.25.9.0.255
svr_preAction: 40 0.0.25.9.0.255
saveObjects succeeded. Index: 729
Count: 2
saveObjects succeeded. Index: 729
Count: 2
sendPush40 0.0.25.9.0.255
svr_preRead: 1 0.0.42.0.0.255
svr_postRead: 1 0.0.42.0.0.255
svr_preRead: 40 0.0.25.9.0.255
svr_postRead: 40 0.0.25.9.0.255

This is the error when the CONNECT is done.

These are the exchanged frames

15:17:00
<HDLC len="9" >
<TargetAddress Value="1" />
<SourceAddress Value="12" />
<FrameType Value="93" />
<Snrm>
</Snrm>
</HDLC>

15:17:07
<HDLC len="1D" >
<TargetAddress Value="12" />
<SourceAddress Value="1" />
<FrameType Value="73" />
<PDU>
<Ua>
<MaxInfoTX Value="128" />
<MaxInfoRX Value="128" />
<WindowSizeTX Value="1" />
<WindowSizeRX Value="1" />
</Ua>
</PDU>
</HDLC>

15:17:07
<HDLC len="4B" >
<TargetAddress Value="1" />
<SourceAddress Value="12" />
<FrameType Value="10" />
<PDU>
<AssociationRequest>
<ApplicationContextName Value="LN" />
<SenderACSERequirements Value="1" />
<MechanismName Value="High" />
<CallingAuthentication Value="55566C275F755861721F610B3F610D37" />
<InitiateRequest>
<ProposedDlmsVersionNumber Value="06" />
<ProposedConformance>
<ConformanceBit Name="GeneralProtection" />
<ConformanceBit Name="GeneralBlockTransfer" />
<ConformanceBit Name="DeltaValueEncoding" />
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
<ConformanceBit Name="Access" />
<ConformanceBit Name="Get" />
<ConformanceBit Name="Set" />
<ConformanceBit Name="SelectiveAccess" />
<ConformanceBit Name="Action" />
</ProposedConformance>
<ProposedMaxPduSize Value="FFFF" />
</InitiateRequest>
</AssociationRequest>
</PDU>
</HDLC>

15:17:08
<HDLC len="57" >
<TargetAddress Value="12" />
<SourceAddress Value="1" />
<FrameType Value="30" />
<PDU>
<AssociationResponse>
<ApplicationContextName Value="LN" />
<AssociationResult Value="00" />
<ResultSourceDiagnostic>
<ACSEServiceUser Value="0E" />
</ResultSourceDiagnostic>
<ResponderACSERequirement Value="1" />
<MechanismName Value="High" />
<RespondingAuthentication Value="70389CCE67B359AC56AB552A158A4522" />
<InitiateResponse>
<NegotiatedDlmsVersionNumber Value="06" />
<NegotiatedConformance>
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
</NegotiatedConformance>
<NegotiatedMaxPduSize Value="0200" />
<VaaName Value="0007" />
</InitiateResponse>
</AssociationResponse>
</PDU>
</HDLC>

15:17:08
<HDLC len="2A" >
<TargetAddress Value="1" />
<SourceAddress Value="12" />
<FrameType Value="32" />
<PDU>
<ActionRequest>
<ActionRequestNormal>
<InvokeIdAndPriority Value="C1" />
<MethodDescriptor>
<ClassId Value="000F" />
<InstanceId Value="0000280000FF" />
<MethodId Value="01" />
</MethodDescriptor>
<MethodInvocationParameters>
<OctetString Value="6E407864A2F5FA45A68F8C6DEF93C703" />
</MethodInvocationParameters>
</ActionRequestNormal>
</ActionRequest>
</PDU>
</HDLC>

15:17:08
<HDLC len="E" >
<TargetAddress Value="12" />
<SourceAddress Value="1" />
<FrameType Value="52" />
<PDU>
<ExceptionResponse>
<StateError Value="ServiceNotAllowed" />
<ServiceError Value="ServiceNotSupported" />
</ExceptionResponse>
</PDU>
</HDLC>

15:17:08
<HDLC len="1D" >
<TargetAddress Value="12" />
<SourceAddress Value="1" />
<FrameType Value="73" />
<PDU>
<Ua>
<MaxInfoTX Value="128" />
<MaxInfoRX Value="128" />
<WindowSizeTX Value="1" />
<WindowSizeRX Value="1" />
</Ua>
</PDU>
</HDLC>

This is the Debug messages.
svr_isTarget.
Connecting using High authentication.
parsePDU succeeded.
svr_validateAuthentication. succeeded.
svr_validateAuthentication
High authentication is used. succeeded.
findObject15 0.0.40.0.0.255
apdu_generateAARE. succeeded.
HandleAarqRequest failed. succeeded.
svr_disconnected

Profile picture for user Kurumi

Kurumi

8 months 1 week ago

Hi, The client doesn't call…

Hi,

The client doesn't call the Application Association Request. Because of that the connection is not established.

https://github.com/Gurux/Gurux.DLMS.Net/blob/83559d81579c83083e6f074dd0…

BR,
Mikko

William Lopes

8 months 1 week ago

Hi Mikko, thank you for your…

Hi Mikko, thank you for your attention.

I'm using GuruxDirector as a client.

I noticed that the connection was requested.

15:17:07
<HDLC len="4B" >
<TargetAddress Value="1" />
<SourceAddress Value="12" />
<FrameType Value="10" />
<PDU>
<AssociationRequest>
<ApplicationContextName Value="LN" />
<SenderACSERequirements Value="1" />
<MechanismName Value="High" />
<CallingAuthentication Value="55566C275F755861721F610B3F610D37" />
<InitiateRequest>
<ProposedDlmsVersionNumber Value="06" />
<ProposedConformance>
<ConformanceBit Name="GeneralProtection" />
<ConformanceBit Name="GeneralBlockTransfer" />
<ConformanceBit Name="DeltaValueEncoding" />
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
<ConformanceBit Name="Access" />
<ConformanceBit Name="Get" />
<ConformanceBit Name="Set" />
<ConformanceBit Name="SelectiveAccess" />
<ConformanceBit Name="Action" />
</ProposedConformance>
<ProposedMaxPduSize Value="FFFF" />
</InitiateRequest>
</AssociationRequest>
</PDU>
</HDLC>

But the answer established a different CONFORMANCE.

5:17:08
<HDLC len="57" >
<TargetAddress Value="12" />
<SourceAddress Value="1" />
<FrameType Value="30" />
<PDU>
<AssociationResponse>
<ApplicationContextName Value="LN" />
<AssociationResult Value="00" />
<ResultSourceDiagnostic>
<ACSEServiceUser Value="0E" />
</ResultSourceDiagnostic>
<ResponderACSERequirement Value="1" />
<MechanismName Value="High" />
<RespondingAuthentication Value="70389CCE67B359AC56AB552A158A4522" />
<InitiateResponse>
<NegotiatedDlmsVersionNumber Value="06" />
<NegotiatedConformance>
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
</NegotiatedConformance>
<NegotiatedMaxPduSize Value="0200" />
<VaaName Value="0007" />
</InitiateResponse>
</AssociationResponse>
</PDU>
</HDLC>

Is this correct?

Profile picture for user Kurumi

Kurumi

8 months 1 week ago

Hi, Yes, this is correct…

Hi,

Yes, this is correct. The client proposes the conformance and the server sends a negotiated conformance.

https://www.gurux.fi/Gurux.DLMS.Conformance

BR,
Mikko

William Lopes

8 months 1 week ago

Hi Mikko. I understand this…

Hi Mikko.

I understand this.
But the negotiated CONFORMACE seems incomplete to me.
In the server code it is defined:

int addAssociationHigh()
{
int ret;
static unsigned char SECRET[20];
//Dedicated key.
static unsigned char CYPHERING_INFO[16] = { 0 };
const unsigned char ln[6] = { 0, 0, 40, 0, 3, 255 };

GXTRACE(GET_STR_FROM_EEPROM("addAssociationHigh"), NULL);

if ((ret = INIT_OBJECT(associationHigh, DLMS_OBJECT_TYPE_ASSOCIATION_LOGICAL_NAME, ln)) == 0)
{
associationHigh.authenticationMechanismName.mechanismId = DLMS_AUTHENTICATION_HIGH;
OA_ATTACH(associationHigh.objectList, ALL_OBJECTS);
BB_ATTACH(associationHigh.xDLMSContextInfo.cypheringInfo, CYPHERING_INFO, 0);
associationHigh.clientSAP = 0x12;
associationHigh.xDLMSContextInfo.maxSendPduSize = associationHigh.xDLMSContextInfo.maxReceivePduSize = PDU_BUFFER_SIZE;
associationHigh.xDLMSContextInfo.conformance = (DLMS_CONFORMANCE)(DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_ACTION |
DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_SET_OR_WRITE |
DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_GET_OR_READ |
DLMS_CONFORMANCE_SET |
DLMS_CONFORMANCE_SELECTIVE_ACCESS |
DLMS_CONFORMANCE_ACTION |
DLMS_CONFORMANCE_MULTIPLE_REFERENCES |
DLMS_CONFORMANCE_GET);

GXTRACE_LONG(GET_STR_FROM_EEPROM("Conformance:"), associationHigh.xDLMSContextInfo.conformance); //teste
BB_ATTACH(associationHigh.secret, SECRET, 0);
memcpy((char*) SECRET, "Gurux", 5);
associationHigh.secret.size = 5;
#ifndef DLMS_IGNORE_OBJECT_POINTERS
associationHigh.securitySetup = &securitySetupHigh;
#else
memcpy(associationHigh.securitySetupReference, securitySetupHigh.base.logicalName, 6);
#endif //DLMS_IGNORE_OBJECT_POINTERS
}
return ret;
}

The same requested by the server.

<ProposedConformance>
<ConformanceBit Name="GeneralProtection" />
<ConformanceBit Name="GeneralBlockTransfer" />
<ConformanceBit Name="DeltaValueEncoding" />
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
<ConformanceBit Name="Access" />
<ConformanceBit Name="Get" />
<ConformanceBit Name="Set" />
<ConformanceBit Name="SelectiveAccess" />
<ConformanceBit Name="Action" />

But the server response was incomplete.

<NegotiatedConformance>
<ConformanceBit Name="BlockTransferWithGetOrRead" />
<ConformanceBit Name="BlockTransferWithSetOrWrite" />
<ConformanceBit Name="BlockTransferWithAction" />
<ConformanceBit Name="MultipleReferences" />
</NegotiatedConformance>

Shouldn't it be the same?

Profile picture for user Kurumi

Kurumi

8 months ago

Hi, The DLMS_CONFORMANCE_GET…

Hi,

The DLMS_CONFORMANCE_GET conformance is missing from the meter reply and that is the reason for this. Check why this is happening.

BR,
Mikko

William Lopes

8 months ago

Hi Mikko! I've found the…

Hi Mikko!

I've found the problem. _Uint32 variables are not being processed properly. Only the first 16 bits are being considered.
I'm using Arduino IDE as the build environment.
Do you have any ideas about this?

William Lopes

7 months 3 weeks ago

Hi Nikko! I solved the…

Hi Nikko!

I solved the problem!

The problem was in the definition of uint_32 and int_32 in gxint.h.

Replacing "int" with "long" in the definitions solved the problem.

#if !(defined uint32_t) && !(defined _UINT32_T_DECLARED)
#define uint32_t unsigned int
#endif //!(defined uint32_t) && !(defined _UINT32_T_DECLARED)

to

#if !(defined uint32_t) && !(defined _UINT32_T_DECLARED)
#define uint32_t unsigned long
#endif //!(defined uint32_t) && !(defined _UINT32_T_DECLARED)

#if !(defined int32_t) && !(defined _INT32_T_DECLARED)
#define int32_t int
#endif //!(defined int32_t) && !(defined _INT32_T_DECLARED)

to

#if !(defined int32_t) && !(defined _INT32_T_DECLARED)
#define int32_t long
#endif //!(defined int32_t) && !(defined _INT32_T_DECLARED)

Thank you for your attention!

Profile picture for user Kurumi

Kurumi

7 months 2 weeks ago

Hi, I'm glad that you were…

Hi,

I'm glad that you were able to solve this. The only thing that worries me is that why this works with Mega 2560 that we have.

What version are you using from Arduino IDE? I tested this with 1.8.19 and it worked.

BR,
Mikko

William Lopes

7 months 1 week ago

Hi Mikko! I'm using this…

Hi Mikko!
I'm using this version.

Version: 2.3.3
Date: 2024-09-25T09:41:18.242Z
CLI Version: 1.0.4

Copyright © 2024 Arduino SA

William Lopes

7 months 1 week ago

Hi Mikko! I updated the …

Hi Mikko!

I updated the "Development" files due to changes in the "serializer" function.

After this, I had problems with the EEPROM operation when loading objects.

See.

ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject succeeded.
ser_loadObject failed Error: 6
Failed to load settings from EEPROM. 170
Failed to load settings from EEPROM. 258
Meter started.
Communication speed 9600
Test mode Is ON.
LLS password: Gurux
HLS password: Gurux
saveObjects failed: 258
saveObjects failed: 258
EEPROM size 4096
Server started.
svr_preAction: 40 0.0.25.9.0.255
saveObjects failed: 258
saveObjects failed: 258
sendPush40 0.0.25.9.0.255
svr_preRead: 1 0.0.42.0.0.255
generatePushSetupMessages Failed.

I imagine it is due to the "serializer structure" changing. How should I proceed?

How do I proceed with the "serializer version"?

Profile picture for user Kurumi

Kurumi

7 months 1 week ago

Hi, Thank you for this…

Hi,

Thank you for this information. This is tested with version 1.0.4 during this week. Serialization is also checked. In the meantime, uncomment loadSettings for one time.
Everything should work after the Serialization values are saved to EEPROM one time.

BR,
Mikko

William Lopes

7 months ago

Hi Mikko. Now, I need to…

Hi Mikko.

Now, I need to switch from HDLC to wrapper/UDP, do you have a reference for this?

Profile picture for user Kurumi

Kurumi

7 months ago

Hi, Change interface type…

Hi,

Change interface type from HDLC to WRAPPER. You can do it like this in client side:

Client.init(true, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_WRAPPER);

and like this on server side:

Server.init(true, DLMS_INTERFACE_TYPE_WRAPPER, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, frameBuff, sizeof(frameBuff), pduBuff, sizeof(pduBuff));

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 06/04/2025 - 13:35
    gurux.dlms.c 9.0.2506.0401
  • Fri, 05/30/2025 - 08:30
    gurux.dlms.c 9.0.2505.3001
  • Tue, 05/27/2025 - 08:10
    Gurux.Serial.Android 2.0.12
  • Mon, 05/26/2025 - 08:39
    gurux.dlms.c 9.0.2505.2601
  • Tue, 05/20/2025 - 08:40
    gurux.dlms.c 9.0.2505.2001

New forum topics

  • Create gateway protocol in c
  • Error while reading event log object
  • GXDLMS Simulator – AssociationLogicalName Not Listed
  • Failed to read meter through raspberry pi 5 and probe
  • Protocol Version in AARQ Packet
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin