Script Starting
Send SNRM data: 7E A0 07 03 03 93 8C 11 7E
Received response data: 7E A0 20 03 03 73 F0 2E 81 80 14 05 02 00 80 06 02 00 80 07 04 00 00 00 01 08 04 00 00 00 01 CE 6A 7E
Send AARQ data: 7E A0 6B 03 03 10 CF A9 E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 00 00 00 00 00 00 00 01 8A 02 07 80 8B 07 60 85 74 05 08 02 05 AC 12 80 10 23 56 03 6F 57 6D 3B 08 2A 31 3E 6A 12 40 5E 59 BE 23 04 21 21 1F 30 00 00 00 00 A8 32 5C DD CA 99 47 FD 7A C3 99 3C 2C 30 65 59 FC FE 11 D8 54 35 2D 2F 9B 1A F0 72 7E
Received AARQ response data: 7E A0 77 03 03 30 58 DC E6 E7 00 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E 89 07 60 85 74 05 08 02 05 A4 0A 04 08 44 53 54 29 BA F7 54 44 88 02 07 80 AA 12 80 10 B7 63 00 67 B7 63 00 67 80 97 CC B9 31 AF A6 05 BE 23 04 21 28 1F 30 00 00 00 00 29 5A E5 EB 12 AB 9B 67 00 42 61 D0 AA 5B 16 5E 3F B4 ED F0 21 AE EC 3F 96 90 F1 EE 7E
Send Auth data: 7E A0 3F 03 03 32 25 0C E6 E6 00 CB 31 30 00 00 00 01 2C C2 54 84 D9 E1 5B 5F 7B 9A 30 BD C2 B5 9B 9E 51 24 6B D0 C7 46 8E 06 66 81 83 24 46 42 19 AB BA 90 D0 5C C8 1F 93 EB F8 BA 51 EF F6 F4 7E
Received Auth response data: 7E A0 24 03 03 52 97 6C E6 E7 00 CF 16 30 00 00 00 01 ED CA C9 44 12 5B 38 B1 40 2D F4 79 7E 80 93 F0 5F C7 C9 7E
Hi everyone, I need your help why Received Auth response data is received less than expected frame length should be ?
Below is my asp.net code. Do i miss something ?
using Gurux.DLMS.Enums;
using Gurux.DLMS;
using System.IO.Ports;
using System;
using System.Diagnostics;
using Gurux.Common;
using Gurux.DLMS.Secure;
using System.Text;
using System.Threading;
using Gurux.DLMS.Client.Example;
namespace DLMSConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Script Starting");
// Create a SerialPort instance.
SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
port.Open();
GXDLMSSecureClient dlms = new GXDLMSSecureClient();
dlms.UseLogicalNameReferencing = true;
dlms.InterfaceType = InterfaceType.HDLC;
dlms.ClientAddress = 1;
dlms.ServerAddress = 1;
dlms.ServerAddressSize = 1;
dlms.Authentication = Authentication.HighGMAC;
dlms.Password = ASCIIEncoding.ASCII.GetBytes("0x1111111111111111");
dlms.Ciphering.Security = Security.AuthenticationEncryption;
dlms.Ciphering.SystemTitle = GXCommon.HexToBytes("0000000000000001");
dlms.Ciphering.AuthenticationKey = GXCommon.HexToBytes("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
dlms.Ciphering.BlockCipherKey = GXCommon.HexToBytes("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
// Send SNRM request
byte[] snrmData = dlms.SNRMRequest();
Console.WriteLine("Send SNRM data: " + BitConverter.ToString(snrmData).Replace("-", " "));
// Write the SNRM request data to the serial port.
port.Write(snrmData, 0, snrmData.Length);
Thread.Sleep(1000);
if (port.BytesToRead > 0)
{
byte[] responseBuffer = new byte[1024]; // Adjust buffer size as needed
int bytesRead = port.Read(responseBuffer, 0, responseBuffer.Length);
// Display the received response in hexadecimal format with spaces.
Console.WriteLine("Received response data: " + BitConverter.ToString(responseBuffer, 0, bytesRead).Replace("-", " "));
// Send AARQ request
byte[][] aarqData = dlms.AARQRequest();
Console.WriteLine("Send AARQ data: " + BitConverter.ToString(aarqData[0]).Replace("-", " "));
// Write the AARQ request data to the serial port.
port.Write(aarqData[0], 0, aarqData[0].Length);
Thread.Sleep(1000);
// Read the AARQ response from the serial port.
byte[] aarqResponseBuffer = new byte[1024]; // Adjust buffer size as needed
int aarqBytesRead = port.Read(aarqResponseBuffer, 0, aarqResponseBuffer.Length);
// Display the received AARQ response in hexadecimal format with spaces.
Console.WriteLine("Received AARQ response data: " + BitConverter.ToString(aarqResponseBuffer, 0, aarqBytesRead).Replace("-", " "));
// Send Auth request
byte[][] authData = dlms.GetApplicationAssociationRequest();
Console.WriteLine("Send Auth data: " + BitConverter.ToString(authData[0]).Replace("-", " "));
// Write the Auth request data to the serial port.
port.Write(authData[0], 0, authData[0].Length);
Thread.Sleep(1000);
// Read the AARQ response from the serial port.
byte[] authResponseBuffer = new byte[1024]; // Adjust buffer size as needed
int authBytesRead = port.Read(authResponseBuffer, 0, authResponseBuffer.Length);
// Display the received AARQ response in hexadecimal format with spaces.
Console.WriteLine("Received Auth response data: " + BitConverter.ToString(authResponseBuffer, 0, authBytesRead).Replace("-", " "));
}
else
{
Console.WriteLine("No data available in the serial port.");
}
// Close the SerialPort.
port.Close();
}
}
}
Thank you
Thank you
Hi, Your meter is returning…
Hi,
Your meter is returning an error. The reason might be that your Authentication level is different than the meter expects. You need to verify the correct settings from the meter vendor.
BR,
Mikko