Hi,
I am reading 0.0.96.1.0.255, ObjectType.Data but result is not parsing data it is showing as HEX:
96.1.0(36 30 33 38 33 30 33 30)
1.0.0(23-04-07,12:43)(-180)(Ok)(23-03-01,02:00)(23-10-01,03:00)(0)(False)(Crystal)
Code:
GXDLMSObject obj = GXDLMSClient.CreateObject(ObjectType.Data);
obj.Version = 0;
obj.LogicalName = "0.0.96.1.0.255";
Client.Objects.Add(obj);
Reader.GetScalersAndUnits();
Reader.GetReadOut();
/////
public void GetReadOut()
{
var result = new List<KeyValuePair<GXDLMSObject, object>>();
foreach (GXDLMSObject it in _settings.Client.Objects)
{
// Profile generics are read later because they are special cases.
// (There might be so lots of data and we so not want waste time to read all the data.)
if (it is GXDLMSProfileGeneric)
{
continue;
}
if (!(it is IGXDLMSBase))
{
//If interface is not implemented.
//Example manufacturer spesific interface.
if (_settings.Trace > TraceLevel.Error)
{
Console.WriteLine("Unknown Interface: " + it.ObjectType.ToString());
}
continue;
}
if (_settings.Trace > TraceLevel.Warning)
{
Console.WriteLine("-------- Reading " + it.GetType().Name + " " + it.Name + " " + it.Description);
}
foreach (int pos in (it as IGXDLMSBase).GetAttributeIndexToRead(false))
{
if (pos == 1)
{
continue;
}
try
{
object val = Read(it, pos);
result.Add(new KeyValuePair<GXDLMSObject, object>(it, ShowValue(val, pos)));
}
catch (Exception ex)
{
Console.WriteLine("Error! " + it.GetType().Name + " " + it.Name + "Index: " + pos + " " + ex.Message);
Console.WriteLine(ex.ToString());
}
}
}
Console.WriteLine($"result readout: {result.Count}");
}
Hi, It looks like you are…
Hi,
It looks like you are reading your meter using IEC 62056-21 and not DLMS.
https://www.gurux.fi/DLMSCOSEMFAQ
BR,
Mikko
Hi Mikko, I am using Gx dlms…
Hi Mikko,
I am using Gx dlms.net read methods. I can read other meter brand properly. Should I do some any other settings? By the way GXDlmsDirector can read also properly.
Read scalers and units from the device.
-------- Reading GXDLMSData 0.0.96.1.0.255
TX: 16:58:16 00 01 00 01 00 01 00 0D C0 01 C1 00 01 00 00 60 01 00 FF 02 00
RX: 16:58:16 00 01 00 01 00 01 00 0E C4 01 C1 00 09 08 36 30 33 38 33 30 33 30
Index: 2 Value: 36 30 33 38 33 30 33 30
Hi, I'm not quite sure what…
Hi,
I'm not quite sure what you mean by this:
96.1.0(36 30 33 38 33 30 33 30)
1.0.0(23-04-07,12:43)(-180)(Ok)(23-03-01,02:00)(23-10-01,03:00)(0)(False)(Crystal)
You are reading the Ch. 0 Device ID 1, manufacturing number and meter returns it as a hex. You can convert it to the string by setting UIType to string like this:
GXDLMSData obj = new GXDLMSData("0.0.96.1.0.255");
obj.SetUIDataType(DataType.String);
BR,
Mikko
Hi Mikko, This is the way I…
Hi Mikko,
This is the way I made them written. The main issue is when I read Device Id it returns me the hex value instead of ASCII from ShowValue(it,pos) method.
On a meter of another brand, I can properly get the ASCII value with the same code.
Hi again, In the below code,…
Hi again,
In the below code, on the last if block, reply.DataType comes OctetString. Is it because od the meter itself?
public object Read(GXDLMSObject it, int attributeIndex)
{
GXReplyData reply = new GXReplyData();
if (!ReadDataBlock(_settings.Client.Read(it, attributeIndex), reply))
{
if (reply.Error != (short)ErrorCode.Rejected)
{
throw new GXDLMSException(reply.Error);
}
reply.Clear();
Thread.Sleep(1000);
if (!ReadDataBlock(_settings.Client.Read(it, attributeIndex), reply))
{
throw new GXDLMSException(reply.Error);
}
}
//Update data type.
if (it.GetDataType(attributeIndex) == DataType.None)
{
it.SetDataType(attributeIndex, reply.DataType);
}
return _settings.Client.UpdateValue(it, attributeIndex, reply.Value);
}
Hi, The Device ID is usually…
Hi,
The Device ID is usually an octect-string, but it can also be string. You need to tell the library that this is shown in string and not in hex string. For this reason you need to add this like after you have created the object.
obj.SetUIDataType(DataType.String);
BR,
Mikko
Okay it seems I should write…
Okay it seems I should write an if block for this register.
But I am wondering how Gurux Dlms Director shows this as string? Does it have the similar if block?
Thanks.
Hi, Parse objects will…
Hi,
Parse objects will handle this. It will update the description and common data types.
You can do it like this:
GXDLMSConverter c = new GXDLMSConverter(Standard);
c.UpdateOBISCodeInformation(Client.Objects);
BR,
Mikko
Hi, Okay that's good. I put…
Hi,
Okay that's good. I put that line of code after GetScalersAndUnits part.
But which registers will be updated? Does it cause any wrong data value?
Hi, It'll updates all the…
Hi,
It'll updates all the COSEM objects that are given to it. It will only update the description and UI types for some objects. It doen't cause wrong data value.
BR,
Mikko
Hi Mikko, Thank you for your…
Hi Mikko,
Thank you for your support. It is perfect to know, fixed my issue.