Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Hi,
I am using the example of the gurux push listener on the github repo for C# but I am having some trouble with the decryption of the payload to be able to portray the payload in XML format. I am trying to receive and decrypt periodic push payloads from the meter but regardless of the encryption type (encrypted or not encrypted), I get the same error.
Code example:
private GXDLMSSecureClient guruxClient;
private GXByteBuffer reply = new GXByteBuffer();
private GXReplyData notify = new GXReplyData();
private GXDLMSPushSetup push = new GXDLMSPushSetup();
public Task DecodePayloadAsync(byte[] payload)
{
//GxDlms
guruxClient = new GXDLMSSecureClient
{
Authentication = (Authentication)Options.Authentication, //AuthenticationEncryption
Password = string.IsNullOrEmpty(Options.Password)
? null
: Encoding.UTF8.GetBytes(Options.Password), //null
ClientAddress = Options.ClientAddress, //16
ServerAddress = Options.ServerAddress, //17
InterfaceType = (InterfaceType)Options.ConnectionInterfaceType, //WRAPPER
Priority = (Priority)Options.Priority, //High
Standard = (Standard)Options.StartProtocol, //DLMS
UseLogicalNameReferencing = Options.UseLogicalNameReferencing, //true
};
if (Options.SecureClient)
{
guruxClient.Ciphering.BlockCipherKey = GXCommon.HexToBytes(Options.BlockCipherKey);
guruxClient.Ciphering.Security = (Security)Options.SecureClientSecurity;
guruxClient.Ciphering.SystemTitle = GXCommon.HexToBytes(Options.SystemTitle);
guruxClient.Ciphering.AuthenticationKey = GXCommon.HexToBytes(Options.AuthenticationKey);
guruxClient.Ciphering.SecuritySuite = (SecuritySuite)Options.SecuritySuite;
}
GXDLMSPushSetup setup = new GXDLMSPushSetup();
push.PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(new GXDLMSClock(), new GXDLMSCaptureObject(2, 0)));
Console.WriteLine("<- " + Gurux.Common.GXCommon.ToHex((byte[])payload, true));
reply.Set(payload);
GXReplyData data = new GXReplyData();
guruxClient.GetData(reply, data, notify);
if (notify.IsComplete)
{
reply.Clear();
if (!notify.IsMoreData)
{
try
{
// Make clone so we don't replace current values.
GXDLMSPushSetup clone = (GXDLMSPushSetup)push.Clone();
clone.GetPushValues(guruxClient, (List<object>)notify.Value);
//Comment this if the meter describes the content of the push message for the client in the received data.
foreach (KeyValuePair<GXDLMSObject, GXDLMSCaptureObject> it in clone.PushObjectList)
{
int index = it.Value.AttributeIndex - 1;
Console.WriteLine(((IGXDLMSBase)it.Key).GetNames()[index] + ": " + it.Key.GetValues()[index]);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
//Show data as XML.
string xml;
GXDLMSTranslator t = new GXDLMSTranslator(TranslatorOutputType.SimpleXml);
t.DataToXml(notify.Data, out xml);
Console.WriteLine(xml);
// Print received data.
PrintData(notify.Value, 0);
Console.WriteLine("Server address:" + notify.ServerAddress + " Client Address:" + notify.ClientAddress);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
notify.Clear();
}
}
}
return Task.CompletedTask;
Within the if where it is defined "if(!notify.IsMoreData)" on the following line:
clone.GetPushValues(guruxClient, (List<object>)notify.Value);
The application throws an exception here stating that the "Size of the push object list is different than values."
I included the values for each of the guruxClient properties after the //
The device is setup to use AuthenticationEncryption.
The response I receive is:
Size of the push object list is different than values.
<Structure Qty="02" >
<OctetString Value="3132333435363738" />
<Structure Qty="03" >
<OctetString Value="0100010800FF" />
<UInt32 Value="00000000" />
<Structure Qty="02" >
<Int8 Value="00" />
<Enum Value="1E" />
</Structure>
</Structure>
</Structure>
Which is completely different from the expected Gurux translator response:
1: 00 01 00 01 00 66 00 4A E0 80 00 01 00 00 43 DB 08 45 44 4D 67 10 BC 61 4E 38 30 00 00 00 02 09 74 80 FA 5A E6 9D 87 87 A4 48 02 D9 A3 48 9A 75 3F AF 75 68 11 F4 88 ED 99 7C 57 F7 93 BD D3 F6 83 69 C1 62 05 6F D9 7E E8 6A 65 C7 46 06 E9 15 1D 1F
<WRAPPER len="27" >
<TargetAddress Value="1" />
<SourceAddress Value="66" />
<PDU>
<GeneralBlockTransfer>
<!-- Last block: True -->
<!-- Streaming: False -->
<!-- Window size: 0 -->
<BlockControl Value="80" />
<BlockNumber Value="0001" />
<BlockNumberAck Value="0000" />
<!--
<DataNotification>
# High priority.
# Invoke ID: 0
<LongInvokeIdAndPriority Value="80000000" />
# 0001/01/01 00:00:00
<DateTime Value="" />
<NotificationBody>
<DataValue>
<Structure Qty="02" >
# 12345678
<OctetString Value="3132333435363738" />
<Structure Qty="03" >
# 1.0.1.8.0.255
<OctetString Value="0100010800FF" />
<UInt32 Value="00000000" />
<Structure Qty="02" >
<Int8 Value="00" />
<Enum Value="1E" />
</Structure>
</Structure>
</Structure>
</DataValue>
</NotificationBody>
</DataNotification>
-->
<BlockData Value="02 09 08 31 32 33 34 35 36 37 38 02 03 09 06 01 00 01 08 00 FF 06 00 00 00 00 02 02 0F 00 16 1E" />
</GeneralBlockTransfer>
</PDU>
</WRAPPER>
I included a picture of the error along with the line it occurs on.
Hi,
Hi,
I believe that there is one error that reflects here. That is fixed for the next release.
Try to replace this line:
GXDLMSPushSetup clone = (GXDLMSPushSetup)push.Clone();
to this:
GXDLMSPushSetup clone = (GXDLMSPushSetup)push;
BR,
Mikko
Hi Mikko,
Hi Mikko,
I changed the above mentioned clone to GXDLMSPushSetup clone = (GXDLMSPushSetup)push but unfortunately the error is persisting, 'Size of the push object list is different than values.'
Hi,
Hi,
I believe that I was searching the issue from the wrong place.
You have described that there is one clock object and that is not true and this is causing the issue.
push.PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(new GXDLMSClock(), new GXDLMSCaptureObject(2, 0)));
Meter sends a push message where are three objects and none of them is the date and time of the clock object. Received data is here:
<Structure Qty="02" >
<OctetString Value="3132333435363738" />
<Structure Qty="03" >
<OctetString Value="0100010800FF" />
<UInt32 Value="00000000" />
<Structure Qty="02" >
<Int8 Value="00" />
<Enum Value="1E" />
</Structure>
</Structure>
</Structure>
Read push object list from the push setup object. Then add the same objects t to the push object list in your code.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSPushSetup
BR,
Mikko
Hi Mikko,
Hi Mikko,
Thanks for the guidance. The issue I had has been resolved