Hi,
Am new to DLMS programming. i need to get Voltage (V1) from the meter using Gurux.DLMS.cpp.
In GitHub i can see GuruxDLMSClientExample, GuruxDLMSPushExample, GuruxDLMSServerExample so which project i should use and where to start. i know its a very basic question. plz guide me to start it.
Am from India
Meter Information
Sprint 350
Type : E3D109
S.No : Y0517221
i tried following settings. but still i cant able to get any response. i can only see ShowHelp() function. GXDLMSDirector sample is working fine with this settings
Reader.GXDLMSReader reader = null;
try
{
//////////////////////////////////////
//Handle command line parameters.
int ret = GetParameters(args, settings);
if (ret != 0)
{
return ret;
}
////////////////////////////////////////
//Initialize connection settings.
if (settings.media is GXSerial)
{
GXSerial serial = settings.media as GXSerial;
Reader.GXDLMSReader reader = null;
try
{
//////////////////////////////////////
//Handle command line parameters.
int ret = GetParameters(args, settings);
if (ret != 0)
{
return ret;
}
////////////////////////////////////////
//Initialize connection settings.
if (settings.media is GXSerial)
{
GXSerial serial = settings.media as GXSerial;
Gurux.DLMS.cpp where to start
Hi,
If you want to read your meter you should use GuruxDLMSClientExample. You need to set right parameters of the meter is not answering anything.
BR,
Mikko
Reading Meter
i tried following settings. but still i cant able to get any response. i can only see ShowHelp() function. GXDLMSDirector sample is working fine with this settings
<WaitTime>7</WaitTime>
<Authentication>Low</Authentication>
<Password>HgjgLgmwzrHfQnEjli2QqQ==</Password>
<PhysicalAddress xsi:type="xsd:int">256</PhysicalAddress>
<LogicalAddress>1</LogicalAddress>
<ClientAddress>32</ClientAddress>
<StartProtocol>DLMS</StartProtocol>
<WindowSizeTX>1</WindowSizeTX>
<WindowSizeRX>1</WindowSizeRX>
<InactivityTimeout>120</InactivityTimeout>
<Name>secure1</Name>
<Verbose>false</Verbose>
<Conformance>7709</Conformance>
<Manufacturer>EHL</Manufacturer>
<HDLCAddressing>0</HDLCAddressing>
<MediaType>Gurux.Serial.GXSerial</MediaType>
<MediaSettings><Port>COM5</Port><StopBits>1</StopBits></MediaSettings>
C# code :
Settings settings = new Settings();
settings.client.Authentication = Authentication.Low;
settings.client.ClientAddress = 32;
settings.client.ServerAddress = 1;
settings.client.InterfaceType = InterfaceType.HDLC;
settings.client.UseLogicalNameReferencing = true;
settings.client.Password = ASCIIEncoding.ASCII.GetBytes("HgjgLgmwzrHfQnEjli2QqQ==");
Reader.GXDLMSReader reader = null;
try
{
//////////////////////////////////////
//Handle command line parameters.
int ret = GetParameters(args, settings);
if (ret != 0)
{
return ret;
}
////////////////////////////////////////
//Initialize connection settings.
if (settings.media is GXSerial)
{
GXSerial serial = settings.media as GXSerial;
serial.PortName = "COM5";
serial.BaudRate = 9600;
serial.DataBits = 8;
serial.Parity = System.IO.Ports.Parity.None;
serial.StopBits = System.IO.Ports.StopBits.One;
}
else
{
throw new Exception("Unknown media type.");
}
////////////////////////////////////////
reader = new Reader.GXDLMSReader(settings.client, settings.media, settings.trace);
settings.media.Open();
if (settings.readObjects.Count != 0)
{
reader.InitializeConnection();
reader.GetAssociationView(false);
foreach (KeyValuePair<string, int> it in settings.readObjects)
{
object val = reader.Read(settings.client.Objects.FindByLN(ObjectType.None, it.Key), it.Value);
reader.ShowValue(val, it.Value);
}
}
else
{
reader.ReadAll(false);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString());
if (System.Diagnostics.Debugger.IsAttached)
{
Console.ReadKey();
}
return 1;
}
finally
{
if (reader != null)
{
reader.Close();
}
if (System.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Ended. Press any key to continue.");
Console.ReadKey();
}
}
return 0;
}
plz guide me
Reading Meter
Hi,
Your password is not correct.
BR,
Mikko
Reading Meter
hi, thank you for the reply. i updated the password. still it shows showHelp();
int ret return 1 and List Parameters count is zero | settings.media is null
int ret = GetParameters(args, settings);
if (ret != 0)
{
return ret;
}
My C# code :
Settings settings = new Settings();
settings.client.Authentication = Authentication.Low;
settings.client.ClientAddress = 32;
settings.client.ServerAddress = 1;
settings.client.InterfaceType = InterfaceType.HDLC;
settings.client.UseLogicalNameReferencing = true;
settings.client.Password = ASCIIEncoding.ASCII.GetBytes("ABCD0001");
Reader.GXDLMSReader reader = null;
try
{
//////////////////////////////////////
//Handle command line parameters.
int ret = GetParameters(args, settings);
if (ret != 0)
{
return ret;
}
////////////////////////////////////////
//Initialize connection settings.
if (settings.media is GXSerial)
{
GXSerial serial = settings.media as GXSerial;
serial.PortName = "COM5";
serial.BaudRate = 9600;
serial.DataBits = 8;
serial.Parity = System.IO.Ports.Parity.None;
serial.StopBits = System.IO.Ports.StopBits.One;
}else {
throw new Exception("Unknown media type.");
}
////////////////////////////////////////
reader = new Reader.GXDLMSReader(settings.client, settings.media, settings.trace);
settings.media.Open();
if (settings.readObjects.Count != 0)
{
reader.InitializeConnection();
reader.GetAssociationView(false);
foreach (KeyValuePair<string, int> it in settings.readObjects)
{
object val = reader.Read(settings.client.Objects.FindByLN(ObjectType.None, it.Key), it.Value);
reader.ShowValue(val, it.Value);
}
}
else
{
reader.ReadAll(false);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString());
if (System.Diagnostics.Debugger.IsAttached)
{
Console.ReadKey();
}
return 1;
}
finally
{
if (reader != null)
{
reader.Close();
}
if (System.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Ended. Press any key to continue.");
Console.ReadKey();
}
}
return 0;
}
static int GetParameters(string[] args, Settings settings)
{
string[] tmp;
List<GXCmdParameter> parameters = GXCommon.GetParameters(args, "p:s:c:s:r:it:a:wP:g:S:C:");
GXNet net = null;
foreach (GXCmdParameter it in parameters)
{
switch (it.Tag)
{
case 'w':
settings.client.InterfaceType = InterfaceType.WRAPPER;
break;
case 'r':
if (string.Compare(it.Value, "sn", true) == 0)
{
settings.client.UseLogicalNameReferencing = false;
}
else if (string.Compare(it.Value, "ln", true) == 0)
{
settings.client.UseLogicalNameReferencing = true;
}
else
{
throw new ArgumentException("Invalid reference option.");
}
break;
case 'h':
//Host address.
if (settings.media == null)
{
settings.media = new GXNet();
}
net = settings.media as GXNet;
net.HostName = it.Value;
break;
case 't':
//Trace.
try
{
settings.trace = (TraceLevel)Enum.Parse(typeof(TraceLevel), it.Value);
}
catch (Exception)
{
throw new ArgumentException("Invalid trace level option. (Error, Warning, Info, Verbose, Off)");
}
break;
case 'p':
//Port.
if (settings.media == null)
{
settings.media = new GXNet();
}
net = settings.media as GXNet;
net.Port = int.Parse(it.Value);
break;
case 'P'://Password
settings.client.Password = ASCIIEncoding.ASCII.GetBytes(it.Value);
break;
case 'i':
//IEC.
settings.iec = true;
break;
case 'g':
//Get (read) selected objects.
foreach (string o in it.Value.Split(new char[] { ';', ',' }))
{
tmp = o.Split(new char[] { ':' });
if (tmp.Length != 2)
{
throw new ArgumentOutOfRangeException("Invalid Logical name or attribute index.");
}
settings.readObjects.Add(new KeyValuePair<string, int>(tmp[0].Trim(), int.Parse(tmp[1].Trim())));
}
break;
case 'S'://Serial Port
settings.media = new GXSerial();
GXSerial serial = settings.media as GXSerial;
tmp = it.Value.Split(':');
serial.PortName = tmp[0];
if (tmp.Length > 1)
{
serial.BaudRate = int.Parse(tmp[1]);
serial.DataBits = int.Parse(tmp[2].Substring(0, 1));
serial.Parity = (Parity)Enum.Parse(typeof(Parity), tmp[2].Substring(1, tmp[2].Length - 2));
serial.StopBits = (StopBits)int.Parse(tmp[2].Substring(tmp[2].Length - 1, 1));
}
else
{
serial.BaudRate = 9600;
serial.DataBits = 8;
serial.Parity = Parity.None;
serial.StopBits = StopBits.One;
}
break;
case 'a':
try
{
if (string.Compare("None", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.None;
}
else if (string.Compare("Low", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.Low;
}
else if (string.Compare("High", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.High;
}
else if (string.Compare("HighMd5", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.HighMD5;
}
else if (string.Compare("HighSha1", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.HighSHA1;
}
else if (string.Compare("HighSha256", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.HighSHA256;
}
else if (string.Compare("HighGMac", it.Value, true) == 0)
{
settings.client.Authentication = Authentication.HighGMAC;
}
else
{
throw new ArgumentException("Invalid Authentication option: '" + it.Value + "'. (None, Low, High, HighMd5, HighSha1, HighGMac, HighSha256)");
}
}
catch (Exception)
{
throw new ArgumentException("Invalid Authentication option: '" + it.Value + "'. (None, Low, High, HighMd5, HighSha1, HighGMac, HighSha256)");
}
break;
case 'C':
try
{
settings.client.Ciphering.Security = (Security)Enum.Parse(typeof(Security), it.Value);
}
catch (Exception)
{
throw new ArgumentException("Invalid Ciphering option. (None, Authentication, Encrypted, AuthenticationEncryption)");
}
break;
case 'o':
break;
case 'c':
settings.client.ClientAddress = int.Parse(it.Value);
break;
case 's':
settings.client.ServerAddress = int.Parse(it.Value);
break;
case '?':
switch (it.Tag)
{
case 'c':
throw new ArgumentException("Missing mandatory client option.");
case 's':
throw new ArgumentException("Missing mandatory server option.");
case 'h':
throw new ArgumentException("Missing mandatory host name option.");
case 'p':
throw new ArgumentException("Missing mandatory port option.");
case 'r':
throw new ArgumentException("Missing mandatory reference option.");
case 'a':
throw new ArgumentException("Missing mandatory authentication option.");
case 'S':
throw new ArgumentException("Missing mandatory Serial port option.");
case 't':
throw new ArgumentException("Missing mandatory trace option.");
case 'g':
throw new ArgumentException("Missing mandatory OBIS code option.");
case 'C':
throw new ArgumentException("Missing mandatory Ciphering option.");
default:
ShowHelp();
return 1;
}
default:
ShowHelp();
return 1;
}
}
if (settings.media == null)
{
ShowHelp();
return 1;
}
return 0;
}