I have EK and AK password from manufacturer (see picture below)
I am trying to make time syncronization. However I am getting ArgumentOutOfRangeException.
My code:
var password = "00000000000000000000000000000000"; // 32x0
Client = new GXDLMSSecureClient(true, 1, 1, Authentication.HighGMAC, "00000000", interfaceType);
//Client.Ciphering.SystemTitle = Encoding.ASCII.GetBytes("0000000000000000"); // throws an error so commented
Client.Ciphering.Security = Security.AuthenticationEncryption;
Client.Ciphering.AuthenticationKey = Encoding.ASCII.GetBytes(password);
Client.Ciphering.BlockCipherKey = Encoding.ASCII.GetBytes(password);
Output:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Invalid Authentication Key.
at Gurux.DLMS.Secure.GXCiphering.set_AuthenticationKey(Byte[] value)
at DLMSClient.DlmsSettings..ctor(Boolean useLogicalNameReferencing, Interface
Type interfaceType, Int32 clientAddress, String connectionAddress, String serial
Number, String password, Nullable`1 serverAddress) in C:\Repos\DLMSClient\DlmsSettings.cs:line 57
at DLMSClient.Program.Main(String[] args) in C:\Repos\DLMSClient\Program.cs:l
ine 88
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at DLMSClient.Program.Main(String[] args) in C:\Repos\DLMSClient\Program.cs:l
ine 347
Meter returns 0 for RX size. That is not a valid value and it basically means that the meter can't send any data. Ask firmware update for the meter where this is fixed.
The meter is still returning an invalid value for MaxInfoRX. You need to handle in the catch. Ask if there is a firmware update available for the meter where this is fixed.
Try to change useLogicalNameReferencing from true to false. I believe it might help with another problem.
It says "ApplicationContextNameNotSupported" and "Meter expects logical name referencing" indifferently logicalName:true or :false.
I think I should force the manufacturer to fix it. (By the way I can read the meter with low Authentication when I set MaxInfo manually but I need this chipering to sync datetime.)
The reason for ApplicationContextNameNotSupported might be that your connection is not secured.
Try to set security to EncryptedAuthenticated. Then you need to set block cipher and authentication keys.
Hi,
Hi,
There must be 16 bytes. You must also give it as a hex, not ASCII.
GXDLMSTranslator.HexToBytes("00000000000000000000000000000000"):
BR,
Mikko
Hi Mikko,
Hi Mikko,
Actuallay manufacturer sended me it as 32x0. But with your suggestion I made them 16x0.
Now it throws MaxInfo Exception.
By the way, I am trying to connect with HdlcWithModeE. (Beacuse documentation says Mode E)
Client.Ciphering.SystemTitle = new byte[] { 48, 48, 48, 48, 48, 48, 48, 48 }; // this was 16x now 8x
Client.Ciphering.Security = Security.AuthenticationEncryption;
Client.Ciphering.AuthenticationKey = new byte[] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 }; // this was 32x now 16x
Client.Ciphering.BlockCipherKey = new byte[] { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 }; // this was 32x now 16x
Send SNRM request.7E A0 07 03 03 93 8C 11 7E
Info: Receive-Send Waiting Time: 10 sn.
TX: 10:26:36 7E A0 07 03 03 93 8C 11 7E
! Received byte count:34
Final! Received byte count:34
RX: 10:26:37 7E A0 20 03 03 73 F0 2E 81 80 14 05 02 02 00 06 02 00 00
07 04 00 00 00 01 08 04 00 00 00 01 BB 12 7E
Parsing UA reply.81 80 14 05 02 02 00 06 02 00 00 07 04 00 00 00 01 08 04 00 00
00 01
System.ArgumentOutOfRangeException: Specified argument was out of the range of v
alid values.
Parameter name: MaxInfoTX
at Gurux.DLMS.GXHdlcSettings.set_MaxInfoTX(UInt16 value)
at Gurux.DLMS.GXDLMS.ParseSnrmUaResponse(GXByteBuffer data, GXDLMSSettings se
ttings)
at Gurux.DLMS.GXDLMSClient.ParseUAResponse(GXByteBuffer data)
at DLMSClient.DLMSReader.InitializeConnection() in C:\Repos\DLMSClient - Upda
tedPackage\DLMSReader.cs:line 45
at DLMSClient.Program.Main(String[] args) in C:\Repos\DLMSClient - UpdatedPac
kage\Program.cs:line 332
Disconnecting from the meter.
Hi,
Hi,
Meter 32x0 is 16 bytes to fill with zero.
Meter returns 0 for RX size. That is not a valid value and it basically means that the meter can't send any data. Ask firmware update for the meter where this is fixed.
<HDLC len="1F" >
<TargetAddress Value="1" />
<SourceAddress Value="1" />
<!-- UA frame. -->
<FrameType Value="73" />
<PDU>
<Ua>
<MaxInfoTX Value="512" />
<MaxInfoRX Value="0" />
<WindowSizeTX Value="1" />
<WindowSizeRX Value="1" />
</Ua>
</PDU>
</HDLC>
BR,
Mikko
Hi Mikko,
Hi Mikko,
I will make sure the meter will return the correct data. Thanks for your support.
This is from documentation:
7E A0 20 03 03 73 F0 2E 81 80 14 05 02 01 F5 06 02 01 F5 07 04 00 00 00 01 08 04 00 00 00 01 6F 19 7E
<HDLC len="1F" >
<TargetAddress Value="1" />
<SourceAddress Value="1" />
<!-- UA frame. -->
<FrameType Value="73" />
<PDU>
<Ua>
<MaxInfoTX Value="501" />
<MaxInfoRX Value="501" />
<WindowSizeTX Value="1" />
<WindowSizeRX Value="1" />
</Ua>
</PDU>
</HDLC>
Does below code not help me?
try
{
_settings.Client.ParseUAResponse(reply.Data);
}
catch
{
_settings.Client.HdlcSettings.MaxInfoTX = 501;
_settings.Client.HdlcSettings.MaxInfoRX = 501;
}
Because it turns this ApplicationContextNameNotSupported exception:
7E A0 3A 03 03 30 60 41 E6 E7 00 61 2C A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 01 A3 05 A1 03 02 01 02 88 02 07 80 89 07 60 85 74 05 08 02 00 BE 06 04 04 0E 01 06 01 26 BF 7E
<HDLC len="39" >
<TargetAddress Value="1" />
<SourceAddress Value="1" />
<!-- AARE frame. -->
<FrameType Value="30" />
<PDU>
<AssociationResponse>
<ApplicationContextName Value="LN" />
<!-- PermanentRejected -->
<AssociationResult Value="01" />
<ResultSourceDiagnostic>
<!-- ApplicationContextNameNotSupported -->
<ACSEServiceUser Value="02" />
</ResultSourceDiagnostic>
<ResponderACSERequirement Value="1" />
<MechanismName Value="None" />
<ConfirmedServiceError>
<Service Value="01" />
<ServiceError>
<Initiate Value="DlmsVersionTooLow" />
</ServiceError>
</ConfirmedServiceError>
</AssociationResponse>
</PDU>
</HDLC>
Hi,
Hi,
Set this before you call SNRMRequest.
_settings.Client.HdlcSettings.MaxInfoTX = 501;
_settings.Client.HdlcSettings.MaxInfoRX = 501;
Check that you have set UseLogicalNameReferencing.
BR,
Mikko
Hi,
Hi,
I put that two lines before SNRMRequest but still no chance.
//
GXReplyData reply = new GXReplyData();
byte[] data;
_settings.Client.HdlcSettings.MaxInfoTX = 501;
_settings.Client.HdlcSettings.MaxInfoRX = 501;
data = _settings.Client.SNRMRequest();
//
Send SNRM request.7E A0 20 03 03 93 FE C9 81 80 14 05 02 01 F5 06 02 01 F5 07 04
00 00 00 01 08 04 00 00 00 01 6F 19 7E
Info: Receive-Send Waiting Time: 10 sn.
TX: 14:18:22 7E A0 20 03 03 93 FE C9 81 80 14 05 02 01 F5 06 02 01 F5
07 04 00 00 00 01 08 04 00 00 00 01 6F 19 7E
! Received byte count:34
Final! Received byte count:34
RX: 14:18:23 7E A0 20 03 03 73 F0 2E 81 80 14 05 02 02 00 06 02 00 00
07 04 00 00 00 01 08 04 00 00 00 01 BB 12 7E
Parsing UA reply.81 80 14 05 02 02 00 06 02 00 00 07 04 00 00 00 01 08 04 00 00
00 01
System.ArgumentOutOfRangeException: Specified argument was out of the range of v
alid values.
Parameter name: MaxInfoTX
at Gurux.DLMS.GXHdlcSettings.set_MaxInfoTX(UInt16 value)
at Gurux.DLMS.GXDLMS.ParseSnrmUaResponse(GXByteBuffer data, GXDLMSSettings se
ttings)
at Gurux.DLMS.GXDLMSClient.ParseUAResponse(GXByteBuffer data)
at DLMSClient.DLMSReader.InitializeConnection() in C:\Repos\DLMSClient - Upda
tedPackage\DLMSReader.cs:line 49
Hi,
Hi,
The meter is still returning an invalid value for MaxInfoRX. You need to handle in the catch. Ask if there is a firmware update available for the meter where this is fixed.
Try to change useLogicalNameReferencing from true to false. I believe it might help with another problem.
BR,
Mikko
Hi Mikko,
Hi Mikko,
It says "ApplicationContextNameNotSupported" and "Meter expects logical name referencing" indifferently logicalName:true or :false.
I think I should force the manufacturer to fix it. (By the way I can read the meter with low Authentication when I set MaxInfo manually but I need this chipering to sync datetime.)
Thanks for your support.
Hi,
Hi,
The reason for ApplicationContextNameNotSupported might be that your connection is not secured.
Try to set security to EncryptedAuthenticated. Then you need to set block cipher and authentication keys.
BR,
Mikko
Hi,
Hi,
Already set.
Client.Ciphering.SystemTitle = GXDLMSTranslator.HexToBytes("0000000000000000");
Client.Ciphering.Security = Security.AuthenticationEncryption;
Client.Ciphering.AuthenticationKey = GXDLMSTranslator.HexToBytes("00000000000000000000000000000000");
Client.Ciphering.BlockCipherKey = GXDLMSTranslator.HexToBytes("00000000000000000000000000000000");