Hi everyone,
I'm encountering an issue while trying to write an IPv6 address as a structure using C# and the GXDLMS library. The error message I'm receiving is:
Get Data Type failed, Invalid attribute
I'm confident that the attribute is correct Here’s the code I'm using:csharp
string ipv6Address = "2401:8800:0e11::2"; // Example: Replace with your dynamic IPv6 address
if (!System.Net.IPAddress.TryParse(ipv6Address, out System.Net.IPAddress parsedAddress))
{
throw new ArgumentException("Invalid IPv6 address format.");
}
byte[] addressBytes = parsedAddress.GetAddressBytes();
List<object> structureItems = new List<object>();
foreach (byte b in addressBytes)
{
structureItems.Add(b); // Add each byte as an item in the structure
}
GXDLMSData ipAddressObject = new GXDLMSData(obj.LogicalName)
{
Value = structureItems // Assign the structure to the Value property
};
conn.ReadDataBlock(Client.Write(ipAddressObject, 3), reply); // Attempting to write the IPv6 address
The attribute is correct, and the data type is indeed a structure. Despite this, I keep getting the error that the attribute is invalid when trying to write the data.
Has anyone experienced this issue before, or can anyone suggest where the problem might lie? Any advice would be greatly appreciated!
Thanks in advance
Hi, Your structureItems …
Hi,
Your structureItems data type is an object list and it won't work.
Try to read the value with GXDLMSDirector and then write it back.
I believe that your data is more like:
GXDLMSData ipAddressObject = new GXDLMSData(obj.LogicalName)
{
Value = addressBytes
};
The data object value attribute index is #2, not #3. You need to change this line:
conn.ReadDataBlock(Client.Write(ipAddressObject, 2), reply);
BR,
Mikko
reply.Clear(); string…
reply.Clear();
string ipv6Address = "xxx.xxx.xxx";
// Convert the IPv6 address to a byte array.
if (!System.Net.IPAddress.TryParse(ipv6Address, out var address) || address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
{
throw new ArgumentException("Invalid IPv6 address format.");
}
byte[] ipv6Bytes = address.GetAddressBytes();
//conn.ReadDataBlock(Client.Write(objData, 3),reply);
GXDLMSData ipAddressObject = new GXDLMSData(obj.LogicalName)
{
Value = address.GetAddressBytes()
};
conn.ReadDataBlock(Client.Write(ipAddressObject, 2), reply);
still throwing exception-Insufficient memory to continue the execution of the program.
Hi, It's not possible to say…
Hi,
It's not possible to say what might cause this because I don't know what you try to write and where you get the error. I also don't know in what format your meter wants the IP adddress.
Check that your IPv6 address is correct and try to read the value from the meter first. Try to write the value with GXDLMSDirector. I believe it will help you to understand DLMS data structures.
BR,
Mikko
Hi, A meter should send data…
Hi,
A meter should send data to the Head-End System (HES) server every 15 minutes. To achieve this, I am configuring the Destination IP address in the HES using the DLMS .NET Library in C#.
Could you help modify my C# code to properly configure the Destination IP address for communication via DLMS?
Thanks in advance
Hi, I believe that you need…
Hi,
I believe that you need to set the destination address to the push object.
Read the association view with GDDLMSDirector. Then select the push object that you want to modify and set the new IP address.
Check Send destination and method:
https://gurux.fi/Gurux.DLMS.Objects.GXDLMSPushSetup
BR,
Mikko