Recevieing pushed data i several blocks

10 posts / 0 new
Last post
AndreasAtPowel
Recevieing pushed data i several blocks

Hi
We are receiving pushed messages from Star meters, this works fine as long as everything comes in one message. However we no have encountered that the message is splitted in two as shown below. Taking the data from these two messages and combine we can see it is a valid PDU of values. (https://www.gurux.fi/GuruxDLMSTranslator)

However we can not figure out how to combine these messages using Gurux.

Message 1:
00 01 00 02 00 66 02 3B E0 00 00 01 00 00 82 02 32 0F 00 00 03 17 00 02 08 01 08 02 04 12 00 28 09 06 00 01 19 09 00 FF 0F 02 12 00 00 02 04 12 00 01 09 06 00 00 60 01 00 FF 0F 02 12 00 00 02 04 12 00 07 09 06 01 00 63 01 00 FF 0F 02 12 10 04 02 04 12 00 07 09 06 00 01 18 03 00 FF 0F 02 12 10 01 02 04 12 00 07 09 06 01 00 63 01 00 FF 0F 02 12 10 04 02 04 12 00 07 09 06 01 00 63 01 00 FF 0F 02 12 10 04 02 04 12 00 07 09 06 01 00 63 01 00 FF 0F 02 12 10 04 02 04 12 00 07 09 06 01 00 63 01 00 FF 0F 02 12 10 04 09 12 37 33 35 39 39 39 32 35 34 33 30 30 30 31 30 30 31 36 01 04 02 06 09 0C 07 E6 01 14 04 03 0F 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 1E 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 2D 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 04 00 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 01 01 02 07 09 0C 07 E6 01 14 04 04 00 00 00 80 00 00 11 00 05 00 00 00 00 05 00 00 00 00 05 00 00 00 16 05 00 00 00 16 05 00 00 00 07 01 04 02 06 09 0C 07 E6 01 14 04 03 0F 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 1E 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 2D 00 00 80 00

Message2:
00 01 00 02 00 66 02 1A E0 80 00 02 00 00 82 02 11 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 04 00 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 01 04 02 06 09 0C 07 E6 01 14 04 03 0F 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 1E 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 2D 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 04 00 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 01 04 02 06 09 0C 07 E6 01 14 04 03 0F 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 1E 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 03 2D 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16 02 06 09 0C 07 E6 01 14 04 04 00 00 00 80 00 00 11 00 15 00 00 00 00 00 00 65 73 15 00 00 00 00 00 00 00 1D 15 00 00 00 00 00 00 00 07 15 00 00 00 00 00 00 1B 16

Kurumi
Kurumi's picture

Hi,

I tested this with Gurux.DLMS.Push.Listener.Example.Net and it was able to show received data.

Because push message is coming in two parts you must use notify and it must define outside of the function. Like this in the example:

private GXReplyData notify = new GXReplyData();

Check the example and let me know if you have any problems.

https://github.com/Gurux/Gurux.DLMS.Net/blob/3950553d22bb501c9b835c66a9a...

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

AndreasAtPowel

Hi
I can't manage to get this to work. After first message IsComplete and IsMoreData are both set to true on notify as expected. However after second message both IsComplete and IsMoreData are set to false.

I see a difference that we create the GXDLMSClient like GXDLMSClient(true, -1, -1, Authentication.None, null, InterfaceType.WRAPPER); but I tried to create it with InterfaceType.HDLC as well but then it doesn't seem to work at all.

Code snipper below:

private readonly GXReplyData _notify = new GXReplyData();

_dlmsClient = new GXDLMSClient(true, -1, -1, Authentication.None, null, InterfaceType.WRAPPER);

public bool HandleMessage(IEnumerable<byte> data)
{
try
{
var dataArray = data.ToArray();
if (Log.IsDebugEnabled)
{
Log.Debug($"Received message: {Gurux.Common.GXCommon.ToHex(dataArray)} from {_source.MapToIPv4()}");
}

var buffer = new GXByteBuffer(dataArray);
var replyData = new GXReplyData();
var getDataResult = _dlmsClient.GetData(buffer, replyData, _notify);
if (_notify.IsComplete) //true after first message, false after second
{
if (!_notify.IsMoreData)//true after first message, false after second
{
try
{
var pushSetup = new GXDLMSPushSetup();
pushSetup.GetPushValues(_dlmsClient, (List<object>)_notify.Value);
}
finally
{
_notify.Clear();
}
}
}
}
catch (Exception e)
{
Log.Error($"Error parsing message {e.ToUserFriendlyErrorMessage()}");
throw;
}
return true;
}

Kurumi
Kurumi's picture

Hi,

The meter is sending data using WRAPPER frames, so you must change the interface from HDLC to WRAPPER or you don't see any data.

If you are using GetPushValues you must add capture objects for the pushSetup object.

If you add this you can see values as a hex string.

string xml;
GXDLMSTranslator t = new GXDLMSTranslator(TranslatorOutputType.SimpleXml);
t.DataToXml(notify.Data, out xml);
Console.WriteLine(xml);

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

AndreasAtPowel

Yes WRAPPER is what we normally use but as I mention
after _dlmsClient.GetData(buffer, replyData, _notify);

_notify.IsComplete is true and _notify.IsMoreData is true as expected.

When second message is received and after _dlmsClient.GetData(buffer, replyData, _notify);

_notify.IsComplete is false and _notify.IsMoreData is true which means I don't even get to the point where I try to use GXDLMSPushSetup

I added GXDLMSTranslator as you show to print out notify after first and second message:

After first message xml=<Int8 Value="00" />

After second message xml=<None />

Kurumi
Kurumi's picture

Hi,

Are you sure that you have received all the bytes from message #2? I did try to test this with Gurux.DLMS.Push.Listener.Example.Net. I change only HDLC to WRAPPER.

I send message #1 and listener received it. Then I send #2 without the last byte (0x16). Is complete is false. Then I send last byte and IsComplete is true and IsMoreData is more data and push message is shown.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

AndreasAtPowel

You're correct! I accidently had remove the last byte from testdata.

Thanks! Now I just have to figure out how to parse the result... how to setup push object
What you do in example does not seem to work:
push.PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(new GXDLMSClock(), new GXDLMSCaptureObject(2, 0)));
Gets an error "Size of the push object list is different than values."

Kurumi
Kurumi's picture

Hi,

This meter is sending the push object list as a first parameter. You can use ParsePushObjects to get the data out without knowing the structure of the push message. Check the example.

I notest that all the data is not there. The last item is Data object 1.0.99.1.0.255, but it's value not added to the values list. You need to ask the meter manufacturer to check this. This will cause an exception, but you can handle this if you check that there is enough data on the buffer. This last item is not updated.

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi

AndreasAtPowel

Thanks for help!

AndreasAtPowel

It actually seem as ParsePushObjects not throwing an exception, just seem to ignore the extra data object.