Good afternoon,
I'm having trouble importing the project https://github.com/gurux/gurux.dlms.java in Eclipse. I tried to import straight from Github for my machine and then
I tried to run the main (GuruxSerialExampleJava.java) and appeared several errors:
Exception in thread "main" java.lang.NoClassDefFoundError: MediaStateEventArgs
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Unknown Source)
at java.lang.Class.getMethod0 (Unknown Source)
at java.lang.Class.getMethod (Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod (Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain (Unknown Source)
Caused by: java.lang.ClassNotFoundException: MediaStateEventArgs
java.net.URLClassLoader at $ 1.run (Unknown Source)
java.net.URLClassLoader at $ 1.run (Unknown Source)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass (Unknown Source)
at java.lang.ClassLoader.loadClass (Unknown Source)
sun.misc.Launcher at $ AppClassLoader.loadClass (Unknown Source)
at java.lang.ClassLoader.loadClass (Unknown Source)
6 ... more
So I tried to create a new main class with the steps in the example (http://www.gurux.fi//Gurux.DLMS) and in the first step I checked the
client.setClientID methods ((byte) 0x21); client.setServerID ((byte) 0x3); do not exist in GXDLMSClient.java class. What am I doing wrong? How should I care
the library?
Grateful!
Rodrigo Lacerda Taschetto
Electrical engineer
Thank you for speed in responding , I downloaded the latest version https://github.com/Gurux/gurux.dlms.java and cared for Eclipse. I tried to run in sampleclient.java and had the following problem:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
IGXMedia cannot be resolved to a type
gurux.net cannot be resolved to a type
gurux.serial cannot be resolved to a type
GXTerminal cannot be resolved to a type
gurux.net cannot be resolved to a type
GXSerial cannot be resolved to a type
GXSerial cannot be resolved to a type
GXSerial cannot be resolved to a type
Parity cannot be resolved to a variable
StopBits cannot be resolved to a variable
Parity cannot be resolved to a variable
StopBits cannot be resolved to a variable
GXNet cannot be resolved to a type
GXNet cannot be resolved to a type
GXNet cannot be resolved to a type
NetworkType cannot be resolved to a variable
GXTerminal cannot be resolved to a type
GXTerminal cannot be resolved to a type
GXTerminal cannot be resolved to a type
gurux.io cannot be resolved to a variable
gurux.io cannot be resolved to a variable
at gurux.dlms.client.sampleclient.main(sampleclient.java:109)
Then I created a main (Principal.java) with the example of README.md with the following code:
package principal;
public class Principal {
public static void main(String[] args) {
//SIMPLE EXAMPLE
//Before use you must set following device parameters. Parameters are manufacturer specific.
GXDLMSClient client = new GXDLMSClient();
// Is used Logical Name or Short Name referencing.
client.setUseLogicalNameReferencing(true);
// Is used HDLC or COSEM transport layers for IPv4 networks (WRAPPER).
client.setInterfaceType(InterfaceType.HDLC);
// Read http://www.gurux.org/dlmsAddress
// to find out how Client and Server addresses are counted.
// Some manufacturers might use own Server and Client addresses.
client.setClientAddress(16);
client.setServerAddress(1);
//After you have set parameters you can try to connect to the meter. First you should send SNRM request and handle UA response. After that you will send AARQ request and handle AARE response.
GXReplyData reply = new GXReplyData();
byte[] data;
data = client.SNRMRequest();
if (data != null)
{
readDLMSPacket(data, reply);
//Has server accepted client.
client.parseUAResponse(reply.getData());
}
//Generate AARQ request.
//Split requests to multiple packets if needed.
//If password is used all data might not fit to one packet.
for (byte[] it : client.AARQRequest())
{
reply.clear();
readDLMSPacket(it, reply);
}
//Parse reply.
client.parseAAREResponse(reply.getData());
}
}
and I got the following message on the console:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method SNRMRequest() is undefined for the type GXDLMSClient
The method readDLMSPacket(byte[], GXReplyData) is undefined for the type Principal
The method AARQRequest() is undefined for the type GXDLMSClient
The method readDLMSPacket(byte[], GXReplyData) is undefined for the type Principal
The method parseAAREResponse(GXByteBuffer) is undefined for the type GXDLMSClient
The steps performed to import the Eclipse Mars were:
1- I downloaded the "download zip " from github : https://github.com/gurux/gurux.dlms.java
I unzipped the gurux.dlms.java-master.zip .
Eclipse clicked File- > Import- > Existing Maven Projects
Next>
Root Directory : C: \ Gurux \ gurux.dlms.java -master
Finish
Eclipse starts Importing Maven Projects and Building Workspace
Right click on the project, Maven- > Update Project-> Ok
Appeared messages :
Updating Maven Project
Building Workspace
Right click on the project, as- Run > Java Application
Only the following options appear :
JUnitCore - org.junit.runner
TestRunner - junit.textui
Version - junit.runner
When I try to click the right button in the project, Run as- > Java Aplication in sampleclient.java the file, I get the following information: Launch Error : " Editor does not contain the main type"
2- After that blacked out the entire project and the folder with the unpacked files. I unzipped again
I gave the command " mvn eclipse : eclipse" in the project by prompt, got the result " Build Success" .
Went on File- > Import- > Existing Projects into Workspace after direct button on the Project-> Run as- > Java application and got the same result as before .
3- I deleted the folder again and unzipped again and tried:
Eclipse clicked File- > Import- > Existing Maven Projects
Next>
Root Directory : C: \ Gurux \ gurux.dlms.java -master
Finish
at the command prompt : cd Gurux \ gurux.dlms.java -master
mvn clean compile
Message Build Success
Eclipse right in the project, Maven- > Update Project-> Ok
Appeared messages :
Updating Maven Project
Building Workspace
I got the same answer from previous items .
what I'm doing wrong? There is another way to import it?
Thanks for attention,
Rodrigo Lacerda Taschetto
I downloaded zip into temp directory and checked that it work.
I have Mars.1
When you import Maven project select "Existing Maven Projects" and then try to select example,
not main project. Like this:
C:\Temp\gurux.dlms.java-master\gurux.dlms.server.example.java
I'm sorry for this, now its work.More one: I have a meter that is described as : Itron SL7000 . When I used the GXDLMSDirector I configured as Actaris SL7000 without authentication and returned to me the following obis :
0.0.42.0.0.255
0.0.40.0.0.255
0.0.40.0.16.255
0.0.25.1.0.255
0.0.41.0.0.255
For more code I should connect with low authentication? And how is the abbreviation of the name of the manufacturer ? In the readme gurux.dlms.java the Landis Gyr is lgz and Actaris SL7000 ?
Grateful!
Rodrigo Lacerda Taschetto
Hi Mikko,
I found the Actaris code is ACE. After changing I recompiled and gave the following error in the console:
Authentication : LOW
ClientAddress : 0x1
ServerAddress : 0x111
<- 14: 19: 08,892 7E A0 08 04 23 03 93 A4 3F 7E
gurux.dlms.GXDLMSException : Source do not match addresses. It is 32785. It shouldnt be 273 .
DisconnectRequest
java.lang.NullPointerException
Done!
Picked up JAVA_TOOL_OPTIONS : -Djava.vendor = " Sun Microsystems Inc."
Hi Mikko,
I tried to change the value = GXDLMSClient.countServerAddress ( serv.getPhysicalAddress () , serv.getLogicalAddress ()); to value = GXDLMSClient.countServerAddress ( serv.getPhysicalAddress () , serv.getLogicalAddress () , 4); but there is no method for this. I tried to create a method in the .class GXDLMSClient.class but is not editable , exactly how should I do this?
Tanks,
Rodrigo Lacerda Taschetto
Hi,
I downloaded the latest file from https://github.com/Gurux/gurux.dlms.java and unzip the file.
From eclipse mars 2 , import the 5 project files with Existing Maven Project individually.
Eclipse right in the project, Maven- > Update Project-> Ok.
Right click on the gurux.dlms.client.example.java Run As- >Java Application.
I got this message in consol:-
GuruxDlmsSample reads data from the DLMS/COSEM device.
GuruxDlmsSample -h [Meter IP Address] -p [Meter Port No] -c 16 -s 1 -r SN
-h host name or IP address.
-p port number or name (Example: 1000).
-S serial port.
-i IEC is a start protocol.
-a Authentication (None, Low, High).
-P Password for authentication.
-c Client address. (Default: 16)
-s Server address. (Default: 1)
-n Server address as serial number.
-r [sn, sn] Short name or Logican Name (default) referencing is used.
-w WRAPPER profile is used. HDLC is default.
-t [Error, Warning, Info, Verbose] Trace messages.
-g "0.0.1.0.0.255:1; 0.0.1.0.0.255:2" Get selected object(s) with given attribute index.
Example:
Read LG device using TCP/IP connection.
GuruxDlmsSample -r SN -c 16 -s 1 -h [Meter IP Address] -p [Meter Port No]
Read LG device using serial port connection.
GuruxDlmsSample -r SN -c 16 -s 1 -sp COM1 -i
Read Indian device using serial port connection.
GuruxDlmsSample -S COM1 -c 16 -s 1 -a Low -P [password]
what I'm doing wrong? There is another way to import it?
For the Media - Serial, what should do ?
Using .net code , I also able to get the meter data using low authentication and serial media.
Thanks for attention,
Regards,
Tanmay Pramanik
Those are command line parameters. If you are debugging you can give those for debug settings. In Eclipse select "Debug as" and "Debug Configuration". Then select "Arguments" and "Program arguments".
Hi Mikko,
I have added the program arguments like this "-r SN -c 16 -s 1 -h [118.112.22.1] -p [1044]" ...its showing invalid reference option...can u help me to get out of this....Actually i am provided with smart meters ipv4 address and port number with key details
Key Details:
LLS Secret : genesis
Encryption & Authentication Key : ************
and they have also provided some meter information,TCP negotiation parameters and HDLC negotiation parameters ...
Is it possible to connect to smart meter in this case?
if no,pls mention alternative method
if yes,then how can i connect to smart meter and pull the data using your code...
I have mentioned the ip and port number above in the eg argument
pls tell me whether the argument which i specified is corrrect ...if not pls specify the correct argument
The ip and port number mentioned above is just an example
Hi Mikko,
Its showing "java.lang.IllegalArgumentException: Invalid reference option." for the above case
i have given the arguments as -r SN -c 16 -s 1 -h meter_ip -p meter_port -a Low -P auth_passwd . I have entered the appropriate meter ip and meter port and authentication password..so help me how to enter the arguments for tcp/ip connection to meter.It is an ITI ltd smart meter...is ur program only access LG smart meter?
i think my is logical reference ...so i added /r=ln in the parameter ...afer that i am getting this exception...what should i do next..
java.lang.ArrayIndexOutOfBoundsException: 11
The exception occured in this line
int ret = getParameters(args, settings);
/**
* Handle meter reply.
*
* @param item
* Command to sent.
* @param reply
* Received reply.
*/
private static void handleReply(final GXDLMSXmlPdu item,
final GXReplyData reply) {
if (reply.getValue() instanceof byte[]) {
System.out.println(GXCommon.bytesToHex((byte[]) reply.getValue()));
System.out.println(reply.toString());
} else {
System.out.println(String.valueOf(reply));
}
}
static File[] listFiles(final File folder) {
List<File> list = new ArrayList<File>();
if (folder.isDirectory()) {
for (final File it : folder.listFiles()) {
if (it.isDirectory()) {
listFiles(it);
} else {
list.add(it);
}
}
} else {
list.add(folder);
}
return list.toArray(new File[list.size()]);
}
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) {
Settings settings = new Settings();
GXDLMSReader reader = null;
try {
////////////////////////////////////////
// Handle command line parameters.
//System.out.println("I am here");
int ret = getParameters(args, settings);
System.out.println("I am still here");
if (ret != 0) {
System.out.println("1");
System.exit(1);
return;
}
////////////////////////////////////////
// Initialize connection settings.
if (settings.media instanceof GXSerial) {
GXSerial serial = (GXSerial) settings.media;
if (settings.iec) {
serial.setBaudRate(BaudRate.BAUD_RATE_300);
serial.setDataBits(7);
System.out.println("2");
serial.setParity(Parity.EVEN);
serial.setStopBits(StopBits.ONE);
} else {
serial.setBaudRate(BaudRate.BAUD_RATE_9600);
serial.setDataBits(8);
System.out.println("3");
serial.setParity(Parity.NONE);
serial.setStopBits(StopBits.ONE);
}
} else if (settings.media instanceof GXNet) {
} else {
System.out.println("4");
throw new Exception("Unknown media type.");
}
if (settings.path == null || settings.path == "") {
System.out.println("5");
throw new Exception("Unknown xml path.");
}
// Execute messages.
for (File file : listFiles(new File(settings.path))) {
String name = file.getName();
System.out.println("6");
if (settings.trace.ordinal() > TraceLevel.WARNING.ordinal()) {
System.out.println(
"------------------------------------------------------------1");
System.out.println(name);
}
List<GXDLMSXmlPdu> actions = settings.client.load(file);
if (actions.size() == 0) {
continue;
}
try {
settings.media.open();
reader = new GXDLMSReader(settings.client, settings.media,
settings.trace);
GXReplyData reply = new GXReplyData();
// Send SNRM if not in xml.
if (settings.client
.getInterfaceType() == InterfaceType.HDLC) {
if (!containsCommand(actions, Command.SNRM)) {
reader.snrmRequest();
}
}
// Send AARQ if not in xml.
if (!containsCommand(actions, Command.AARQ)) {
if (!containsCommand(actions, Command.SNRM)) {
reader.aarqRequest();
}
}
for (GXDLMSXmlPdu it : actions) {
if (it.getCommand() == Command.SNRM && settings.client
.getInterfaceType() == InterfaceType.WRAPPER) {
continue;
}
if (it.getCommand() == Command.DISCONNECT_REQUEST
&& settings.client
.getInterfaceType() == InterfaceType.WRAPPER) {
break;
}
// Send
reply.clear();
if (settings.trace.ordinal() > TraceLevel.WARNING
.ordinal()) {
System.out.println(
"------------------------------------------------------------2");
System.out.println(it.toString());
}
if (it.isRequest()) {
reader.readDataBlock(
settings.client.pduToMessages(it), reply);
handleReply(it, reply);
}
}
} catch (Exception ex) {
System.out.println(
"------------------------------------------------------------3");
System.out.println(ex.getMessage());
} finally {
// Send Disconnect if not in xml.
if (!containsCommand(actions, Command.DISCONNECT_REQUEST)) {
reader.disconnect();
} else {
settings.media.close();
}
}
}
} catch (Exception ex) {
System.out.println(
"------------------------------------------------------------");
System.out.println(ex);
System.out.println(ex.getMessage());
}
}
/**
* Is command in XML file.
*
* @param actions
* @param command
* @return
*/
private static boolean containsCommand(final List<GXDLMSXmlPdu> actions,
final int command) {
for (GXDLMSXmlPdu it : actions) {
if (it.getCommand() == command) {
return true;
}
}
return false;
}
/**
* Show help.
*/
static void showHelp() {
System.out.println(
"GuruxDlmsSample reads data from the DLMS/COSEM device.");
System.out.println(
"GuruxDlmsSample -h [Meter IP Address] -p [Meter Port No] -c 16 -s 1 -r SN");
System.out.println(" -h \t host name or IP address.");
System.out.println(" -p \t port number or name (Example: 1000).");
System.out.println(" -S \t serial port.");
System.out.println(" -i IEC is a start protocol.");
System.out.println(" -a \t Authentication (None, Low, High).");
System.out.println(" -P \t Password for authentication.");
System.out.println(" -c \t Client address. (Default: 16)");
System.out.println(" -s \t Server address. (Default: 1)");
System.out.println(" -n \t Server address as serial number.");
System.out.println(
" -r [sn, sn]\t Short name or Logican Name (default) referencing is used.");
System.out.println(" -w WRAPPER profile is used. HDLC is default.");
System.out
.println(" -t [Error, Warning, Info, Verbose] Trace messages.");
System.out.println(" -x input XML file.");
System.out.println("Example:");
System.out.println("Read LG device using TCP/IP connection.");
System.out.println(
"GuruxDlmsSample -r SN -c 16 -s 1 -h [Meter IP Address] -p [Meter Port No]");
System.out.println("Read LG device using serial port connection.");
System.out.println("GuruxDlmsSample -r SN -c 16 -s 1 -sp COM1 -i");
System.out.println("Read Indian device using serial port connection.");
System.out.println(
"GuruxDlmsSample -S COM1 -c 16 -s 1 -a Low -P [password]");
}
static int getParameters(String[] args, Settings settings) {
ArrayList<GXCmdParameter> parameters =
GXCommon.getParameters(args, "h:p:c:s:r:it:a:p:wP:x:");
GXNet net = null;
for (GXCmdParameter it : parameters) {
switch (it.getTag()) {
case 'w':
settings.client.setInterfaceType(InterfaceType.WRAPPER);
break;
case 'r':
if ("sn".compareTo(it.getValue()) == 0) {
settings.client.setUseLogicalNameReferencing(false);
} else if ("ln".compareTo(it.getValue()) == 0) {
settings.client.setUseLogicalNameReferencing(true);
} else {
throw new IllegalArgumentException(
"Invalid reference option.");
}
break;
case 'h':
// Host address.
if (settings.media == null) {
settings.media = new GXNet();
}
net = (GXNet) settings.media;
net.setHostName(it.getValue());
break;
case 't':
// Trace.
if ("Error".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.ERROR;
else if ("Warning".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.WARNING;
else if ("Info".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.INFO;
else if ("Verbose".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.VERBOSE;
else if ("Off".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.OFF;
else
throw new IllegalArgumentException(
"Invalid Authentication option. (Error, Warning, Info, Verbose, Off).");
break;
case 'p':
// Port.
if (settings.media == null) {
settings.media = new GXNet();
}
net = (GXNet) settings.media;
net.setPort(Integer.parseInt(it.getValue()));
break;
case 'P':// Password
settings.client.setPassword(it.getValue().getBytes());
break;
case 'i':
// IEC.
settings.iec = true;
break;
case 'S':// Serial Port
settings.media = new GXSerial();
GXSerial serial = (GXSerial) settings.media;
serial.setPortName(it.getValue());
break;
case 'a':
try {
settings.client.setAuthentication(
Authentication.valueOfString(it.getValue()));
} catch (Exception e) {
throw new IllegalArgumentException(
"Invalid Authentication option: '" + it.getValue()
+ "'. (None, Low, High, HighMd5, HighSha1, HighGmac, HighSha256)");
}
break;
case 'o':
break;
case 'c':
settings.client
.setClientAddress(Integer.parseInt(it.getValue()));
break;
case 's':
settings.client
.setServerAddress(Integer.parseInt(it.getValue()));
break;
case 'x':
settings.path = it.getValue();
break;
case '?':
switch (it.getTag()) {
case 'c':
throw new IllegalArgumentException(
"Missing mandatory client option.");
case 's':
throw new IllegalArgumentException(
"Missing mandatory server option.");
case 'h':
throw new IllegalArgumentException(
"Missing mandatory host name option.");
case 'p':
throw new IllegalArgumentException(
"Missing mandatory port option.");
case 'r':
throw new IllegalArgumentException(
"Missing mandatory reference option.");
case 'a':
throw new IllegalArgumentException(
"Missing mandatory authentication option.");
case 'S':
throw new IllegalArgumentException(
"Missing mandatory Serial port option.\n");
case 't':
throw new IllegalArgumentException(
"Missing mandatory trace option.\n");
default:
showHelp();
return 1;
}
default:
showHelp();
return 1;
}
}
if (settings.media == null) {
showHelp();
return 1;
}
return 0;
}
}
The output is :
I am still here
5
------------------------------------------------------------
java.lang.Exception: Unknown xml path.
Unknown xml path.
I ran the program gurux.dlms.client.example.java.sample client with arguments -r ln -c 16 -s 1 -h ipaddress -p portno and i got the following output...
the output is :
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x1
Data send failed. Try to resend 1/3
Data send failed. Try to resend 2/3
Data send failed. Try to resend 3/3
Invalid connection.
I need read the smart meter data remotely provided ipv4 address and port number and other meter information...
Can u provide me any source (share the link) to learn DLMS...?
Your settings are not correct. Meter doesn't reply for this reason. What meter you try to read?
DLMS is a standard. You need to buy standard documents.
Check that your port number and IP address are correct. Then make sure that "Start Protocol" is DLMS.
Make sure that your Manufacturer is "Indian Standard".
DLMS parameters vary among manufacturers. If one of the parameters is wrong, meter doesn't reply.
I have successfully established connection and i can able to read meter data ....how to add objects in java client example( as we can able to add in GXDLMS director )...I have some OBIS and attributes...
Thanks a lot ...By the way how to read billing data ...the corresponding OBIS is in Register,Extended Register and ProfileGeneric class....if i read with Register and ExtendedRegister it returns null ...if i use ProfileGeneric using the method readRowsByEntry with three arguments object name , index and count then the program reads other objects and it displays in console "capture read objects first"...So help me to read billing data ...And what is IC (a number)..is IC refers to GXDLMS Objects?
Import into Eclipse
Hi Rodrigo,
We have released new API. There are lots of improvements for DLMS parser.
It's faster and uses less memory.
We updated documentation and there was still DeviceID and ClientID.
They are not ClientAddress and ServerAddress.
I'm sorry about this.
Try to get latest version from GitHub.
We are using Maven Project as a default, but I did try to create new project and
added Gurux.DLMS as Eclipse Project and it worked for me.
Let me know if you still have problems.
BR,
Mikko
Import into Eclipse
Thank you for speed in responding , I downloaded the latest version https://github.com/Gurux/gurux.dlms.java and cared for Eclipse. I tried to run in sampleclient.java and had the following problem:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
IGXMedia cannot be resolved to a type
gurux.net cannot be resolved to a type
gurux.serial cannot be resolved to a type
GXTerminal cannot be resolved to a type
gurux.net cannot be resolved to a type
GXSerial cannot be resolved to a type
GXSerial cannot be resolved to a type
GXSerial cannot be resolved to a type
Parity cannot be resolved to a variable
StopBits cannot be resolved to a variable
Parity cannot be resolved to a variable
StopBits cannot be resolved to a variable
GXNet cannot be resolved to a type
GXNet cannot be resolved to a type
GXNet cannot be resolved to a type
NetworkType cannot be resolved to a variable
GXTerminal cannot be resolved to a type
GXTerminal cannot be resolved to a type
GXTerminal cannot be resolved to a type
gurux.io cannot be resolved to a variable
gurux.io cannot be resolved to a variable
at gurux.dlms.client.sampleclient.main(sampleclient.java:109)
Then I created a main (Principal.java) with the example of README.md with the following code:
package principal;
import gurux.dlms.GXDLMSClient;
import gurux.dlms.GXReplyData;
import gurux.dlms.enums.InterfaceType;
public class Principal {
public static void main(String[] args) {
//SIMPLE EXAMPLE
//Before use you must set following device parameters. Parameters are manufacturer specific.
GXDLMSClient client = new GXDLMSClient();
// Is used Logical Name or Short Name referencing.
client.setUseLogicalNameReferencing(true);
// Is used HDLC or COSEM transport layers for IPv4 networks (WRAPPER).
client.setInterfaceType(InterfaceType.HDLC);
// Read http://www.gurux.org/dlmsAddress
// to find out how Client and Server addresses are counted.
// Some manufacturers might use own Server and Client addresses.
client.setClientAddress(16);
client.setServerAddress(1);
//After you have set parameters you can try to connect to the meter. First you should send SNRM request and handle UA response. After that you will send AARQ request and handle AARE response.
GXReplyData reply = new GXReplyData();
byte[] data;
data = client.SNRMRequest();
if (data != null)
{
readDLMSPacket(data, reply);
//Has server accepted client.
client.parseUAResponse(reply.getData());
}
//Generate AARQ request.
//Split requests to multiple packets if needed.
//If password is used all data might not fit to one packet.
for (byte[] it : client.AARQRequest())
{
reply.clear();
readDLMSPacket(it, reply);
}
//Parse reply.
client.parseAAREResponse(reply.getData());
}
}
and I got the following message on the console:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method SNRMRequest() is undefined for the type GXDLMSClient
The method readDLMSPacket(byte[], GXReplyData) is undefined for the type Principal
The method AARQRequest() is undefined for the type GXDLMSClient
The method readDLMSPacket(byte[], GXReplyData) is undefined for the type Principal
The method parseAAREResponse(GXByteBuffer) is undefined for the type GXDLMSClient
at principal.Principal.main(Principal.java:28)
I'm forgetting something ?
Grateful!
Rodrigo Lacerda Taschetto
Import into Eclipse
Hi,
This is Maven Project. You should open it selecting "Existing Mavan Project" from Import.
Maven projct will load all resources automatically.
BR,
Mikko
Import into Eclipse
The steps performed to import the Eclipse Mars were:
1- I downloaded the "download zip " from github : https://github.com/gurux/gurux.dlms.java
I unzipped the gurux.dlms.java-master.zip .
Eclipse clicked File- > Import- > Existing Maven Projects
Next>
Root Directory : C: \ Gurux \ gurux.dlms.java -master
Finish
Eclipse starts Importing Maven Projects and Building Workspace
Right click on the project, Maven- > Update Project-> Ok
Appeared messages :
Updating Maven Project
Building Workspace
Right click on the project, as- Run > Java Application
Only the following options appear :
JUnitCore - org.junit.runner
TestRunner - junit.textui
Version - junit.runner
When I try to click the right button in the project, Run as- > Java Aplication in sampleclient.java the file, I get the following information: Launch Error : " Editor does not contain the main type"
2- After that blacked out the entire project and the folder with the unpacked files. I unzipped again
I gave the command " mvn eclipse : eclipse" in the project by prompt, got the result " Build Success" .
Went on File- > Import- > Existing Projects into Workspace after direct button on the Project-> Run as- > Java application and got the same result as before .
3- I deleted the folder again and unzipped again and tried:
Eclipse clicked File- > Import- > Existing Maven Projects
Next>
Root Directory : C: \ Gurux \ gurux.dlms.java -master
Finish
at the command prompt : cd Gurux \ gurux.dlms.java -master
mvn clean compile
Message Build Success
Eclipse right in the project, Maven- > Update Project-> Ok
Appeared messages :
Updating Maven Project
Building Workspace
I got the same answer from previous items .
what I'm doing wrong? There is another way to import it?
Thanks for attention,
Rodrigo Lacerda Taschetto
Import into Eclipse
Hi,
I downloaded zip into temp directory and checked that it work.
I have Mars.1
When you import Maven project select "Existing Maven Projects" and then try to select example,
not main project. Like this:
C:\Temp\gurux.dlms.java-master\gurux.dlms.server.example.java
This works for me. I hope this helps.
BR,
Mikko
Import into Eclipse
I'm sorry for this, now its work.More one: I have a meter that is described as : Itron SL7000 . When I used the GXDLMSDirector I configured as Actaris SL7000 without authentication and returned to me the following obis :
0.0.42.0.0.255
0.0.40.0.0.255
0.0.40.0.16.255
0.0.25.1.0.255
0.0.41.0.0.255
For more code I should connect with low authentication? And how is the abbreviation of the name of the manufacturer ? In the readme gurux.dlms.java the Landis Gyr is lgz and Actaris SL7000 ?
Grateful!
Rodrigo Lacerda Taschetto
Error in sampleclient.java
Hi Mikko,
I found the Actaris code is ACE. After changing I recompiled and gave the following error in the console:
Authentication : LOW
ClientAddress : 0x1
ServerAddress : 0x111
<- 14: 19: 08,892 7E A0 08 04 23 03 93 A4 3F 7E
gurux.dlms.GXDLMSException : Source do not match addresses. It is 32785. It shouldnt be 273 .
DisconnectRequest
java.lang.NullPointerException
Done!
Picked up JAVA_TOOL_OPTIONS : -Djava.vendor = " Sun Microsystems Inc."
How do I fix this?
Thank you,
Rodrigo Lacerda Taschetto
Actaris
Hi,
We must do special implementation for Actaris. :-(
We will do this ASAP, but you can continue if you modify example.
Change
GXDLMSClient.countServerAddress(serv.getPhysicalAddress(), serv.getLogicalAddress());
To
GXDLMSClient.countServerAddress(serv.getPhysicalAddress(), serv.getLogicalAddress(), 4);
This will force server address size for four bytes.
BR,
Mikko
Actaris
Hi Mikko,
I tried to change the value = GXDLMSClient.countServerAddress ( serv.getPhysicalAddress () , serv.getLogicalAddress ()); to value = GXDLMSClient.countServerAddress ( serv.getPhysicalAddress () , serv.getLogicalAddress () , 4); but there is no method for this. I tried to create a method in the .class GXDLMSClient.class but is not editable , exactly how should I do this?
Tanks,
Rodrigo Lacerda Taschetto
Actaris
Hi,
Sorry. We renamed countServerAddress to getServerAddress.
Accidentally we left old countServerAddress to Java version.
Use getServerAddress for now on.
BR,
Mikko
Not getting response
Hi,
I downloaded the latest file from https://github.com/Gurux/gurux.dlms.java and unzip the file.
From eclipse mars 2 , import the 5 project files with Existing Maven Project individually.
Eclipse right in the project, Maven- > Update Project-> Ok.
Right click on the gurux.dlms.client.example.java Run As- >Java Application.
I got this message in consol:-
GuruxDlmsSample reads data from the DLMS/COSEM device.
GuruxDlmsSample -h [Meter IP Address] -p [Meter Port No] -c 16 -s 1 -r SN
-h host name or IP address.
-p port number or name (Example: 1000).
-S serial port.
-i IEC is a start protocol.
-a Authentication (None, Low, High).
-P Password for authentication.
-c Client address. (Default: 16)
-s Server address. (Default: 1)
-n Server address as serial number.
-r [sn, sn] Short name or Logican Name (default) referencing is used.
-w WRAPPER profile is used. HDLC is default.
-t [Error, Warning, Info, Verbose] Trace messages.
-g "0.0.1.0.0.255:1; 0.0.1.0.0.255:2" Get selected object(s) with given attribute index.
Example:
Read LG device using TCP/IP connection.
GuruxDlmsSample -r SN -c 16 -s 1 -h [Meter IP Address] -p [Meter Port No]
Read LG device using serial port connection.
GuruxDlmsSample -r SN -c 16 -s 1 -sp COM1 -i
Read Indian device using serial port connection.
GuruxDlmsSample -S COM1 -c 16 -s 1 -a Low -P [password]
what I'm doing wrong? There is another way to import it?
For the Media - Serial, what should do ?
Using .net code , I also able to get the meter data using low authentication and serial media.
Thanks for attention,
Regards,
Tanmay Pramanik
Eclipse
Hi Tanmay Pramanik.
Please, if you have a question, create new topic for it.
You have not given meter parameters for your app. You must give those parameters to read your meter.
BR,
Mikko
How to give parameters to the
Me too got the same ...How to give parameters to the app ....where to give those parameters ? ...help please
Hi,
Hi,
Those are command line parameters. If you are debugging you can give those for debug settings. In Eclipse select "Debug as" and "Debug Configuration". Then select "Arguments" and "Program arguments".
BR,
Mikko
i have added the program
Hi Mikko,
I have added the program arguments like this "-r SN -c 16 -s 1 -h [118.112.22.1] -p [1044]" ...its showing invalid reference option...can u help me to get out of this....Actually i am provided with smart meters ipv4 address and port number with key details
Key Details:
LLS Secret : genesis
Encryption & Authentication Key : ************
and they have also provided some meter information,TCP negotiation parameters and HDLC negotiation parameters ...
Is it possible to connect to smart meter in this case?
if no,pls mention alternative method
if yes,then how can i connect to smart meter and pull the data using your code...
I have mentioned the ip and port number above in the eg argument
pls tell me whether the argument which i specified is corrrect ...if not pls specify the correct argument
The ip and port number mentioned above is just an example
Hi Mikko,
Hi Mikko,
Its showing "java.lang.IllegalArgumentException: Invalid reference option." for the above case
i have given the arguments as -r SN -c 16 -s 1 -h meter_ip -p meter_port -a Low -P auth_passwd . I have entered the appropriate meter ip and meter port and authentication password..so help me how to enter the arguments for tcp/ip connection to meter.It is an ITI ltd smart meter...is ur program only access LG smart meter?
Hi,
Hi,
"Invalid reference option" is because your parameter is wrong. Try to give "-s sn" with lower case.
BR,
Mikko
i think my is logical
i think my is logical reference ...so i added /r=ln in the parameter ...afer that i am getting this exception...what should i do next..
java.lang.ArrayIndexOutOfBoundsException: 11
The exception occured in this line
int ret = getParameters(args, settings);
Hi,
Hi,
Add parameter as "-r ln"
BR,
Mikko
If I add -r ln then it's
If I add -r ln then it's showing unknown XML path
Hi,
Hi,
I just re-test this. My command line parameters are
java -jar gurux.dlms.client.example.java-0.0.1-SNAPSHOT.jar -r ln -h localhost -p 4061
It works like expected.
BR,
Mikko
package main.java.gurux.dlms
package main.java.gurux.dlms.xmlClient;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import gurux.common.GXCmdParameter;
import gurux.common.GXCommon;
import gurux.common.enums.TraceLevel;
import gurux.dlms.GXDLMSXmlPdu;
import gurux.dlms.GXReplyData;
import gurux.dlms.enums.Authentication;
import gurux.dlms.enums.Command;
import gurux.dlms.enums.InterfaceType;
import gurux.io.BaudRate;
import gurux.io.Parity;
import gurux.io.StopBits;
import gurux.net.GXNet;
import gurux.serial.GXSerial;
public class Program {
/**
* Handle meter reply.
*
* @param item
* Command to sent.
* @param reply
* Received reply.
*/
private static void handleReply(final GXDLMSXmlPdu item,
final GXReplyData reply) {
if (reply.getValue() instanceof byte[]) {
System.out.println(GXCommon.bytesToHex((byte[]) reply.getValue()));
System.out.println(reply.toString());
} else {
System.out.println(String.valueOf(reply));
}
}
static File[] listFiles(final File folder) {
List<File> list = new ArrayList<File>();
if (folder.isDirectory()) {
for (final File it : folder.listFiles()) {
if (it.isDirectory()) {
listFiles(it);
} else {
list.add(it);
}
}
} else {
list.add(folder);
}
return list.toArray(new File[list.size()]);
}
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) {
Settings settings = new Settings();
GXDLMSReader reader = null;
try {
////////////////////////////////////////
// Handle command line parameters.
//System.out.println("I am here");
int ret = getParameters(args, settings);
System.out.println("I am still here");
if (ret != 0) {
System.out.println("1");
System.exit(1);
return;
}
////////////////////////////////////////
// Initialize connection settings.
if (settings.media instanceof GXSerial) {
GXSerial serial = (GXSerial) settings.media;
if (settings.iec) {
serial.setBaudRate(BaudRate.BAUD_RATE_300);
serial.setDataBits(7);
System.out.println("2");
serial.setParity(Parity.EVEN);
serial.setStopBits(StopBits.ONE);
} else {
serial.setBaudRate(BaudRate.BAUD_RATE_9600);
serial.setDataBits(8);
System.out.println("3");
serial.setParity(Parity.NONE);
serial.setStopBits(StopBits.ONE);
}
} else if (settings.media instanceof GXNet) {
} else {
System.out.println("4");
throw new Exception("Unknown media type.");
}
if (settings.path == null || settings.path == "") {
System.out.println("5");
throw new Exception("Unknown xml path.");
}
// Execute messages.
for (File file : listFiles(new File(settings.path))) {
String name = file.getName();
System.out.println("6");
if (settings.trace.ordinal() > TraceLevel.WARNING.ordinal()) {
System.out.println(
"------------------------------------------------------------1");
System.out.println(name);
}
List<GXDLMSXmlPdu> actions = settings.client.load(file);
if (actions.size() == 0) {
continue;
}
try {
settings.media.open();
reader = new GXDLMSReader(settings.client, settings.media,
settings.trace);
GXReplyData reply = new GXReplyData();
// Send SNRM if not in xml.
if (settings.client
.getInterfaceType() == InterfaceType.HDLC) {
if (!containsCommand(actions, Command.SNRM)) {
reader.snrmRequest();
}
}
// Send AARQ if not in xml.
if (!containsCommand(actions, Command.AARQ)) {
if (!containsCommand(actions, Command.SNRM)) {
reader.aarqRequest();
}
}
for (GXDLMSXmlPdu it : actions) {
if (it.getCommand() == Command.SNRM && settings.client
.getInterfaceType() == InterfaceType.WRAPPER) {
continue;
}
if (it.getCommand() == Command.DISCONNECT_REQUEST
&& settings.client
.getInterfaceType() == InterfaceType.WRAPPER) {
break;
}
// Send
reply.clear();
if (settings.trace.ordinal() > TraceLevel.WARNING
.ordinal()) {
System.out.println(
"------------------------------------------------------------2");
System.out.println(it.toString());
}
if (it.isRequest()) {
reader.readDataBlock(
settings.client.pduToMessages(it), reply);
handleReply(it, reply);
}
}
} catch (Exception ex) {
System.out.println(
"------------------------------------------------------------3");
System.out.println(ex.getMessage());
} finally {
// Send Disconnect if not in xml.
if (!containsCommand(actions, Command.DISCONNECT_REQUEST)) {
reader.disconnect();
} else {
settings.media.close();
}
}
}
} catch (Exception ex) {
System.out.println(
"------------------------------------------------------------");
System.out.println(ex);
System.out.println(ex.getMessage());
}
}
/**
* Is command in XML file.
*
* @param actions
* @param command
* @return
*/
private static boolean containsCommand(final List<GXDLMSXmlPdu> actions,
final int command) {
for (GXDLMSXmlPdu it : actions) {
if (it.getCommand() == command) {
return true;
}
}
return false;
}
/**
* Show help.
*/
static void showHelp() {
System.out.println(
"GuruxDlmsSample reads data from the DLMS/COSEM device.");
System.out.println(
"GuruxDlmsSample -h [Meter IP Address] -p [Meter Port No] -c 16 -s 1 -r SN");
System.out.println(" -h \t host name or IP address.");
System.out.println(" -p \t port number or name (Example: 1000).");
System.out.println(" -S \t serial port.");
System.out.println(" -i IEC is a start protocol.");
System.out.println(" -a \t Authentication (None, Low, High).");
System.out.println(" -P \t Password for authentication.");
System.out.println(" -c \t Client address. (Default: 16)");
System.out.println(" -s \t Server address. (Default: 1)");
System.out.println(" -n \t Server address as serial number.");
System.out.println(
" -r [sn, sn]\t Short name or Logican Name (default) referencing is used.");
System.out.println(" -w WRAPPER profile is used. HDLC is default.");
System.out
.println(" -t [Error, Warning, Info, Verbose] Trace messages.");
System.out.println(" -x input XML file.");
System.out.println("Example:");
System.out.println("Read LG device using TCP/IP connection.");
System.out.println(
"GuruxDlmsSample -r SN -c 16 -s 1 -h [Meter IP Address] -p [Meter Port No]");
System.out.println("Read LG device using serial port connection.");
System.out.println("GuruxDlmsSample -r SN -c 16 -s 1 -sp COM1 -i");
System.out.println("Read Indian device using serial port connection.");
System.out.println(
"GuruxDlmsSample -S COM1 -c 16 -s 1 -a Low -P [password]");
}
static int getParameters(String[] args, Settings settings) {
ArrayList<GXCmdParameter> parameters =
GXCommon.getParameters(args, "h:p:c:s:r:it:a:p:wP:x:");
GXNet net = null;
for (GXCmdParameter it : parameters) {
switch (it.getTag()) {
case 'w':
settings.client.setInterfaceType(InterfaceType.WRAPPER);
break;
case 'r':
if ("sn".compareTo(it.getValue()) == 0) {
settings.client.setUseLogicalNameReferencing(false);
} else if ("ln".compareTo(it.getValue()) == 0) {
settings.client.setUseLogicalNameReferencing(true);
} else {
throw new IllegalArgumentException(
"Invalid reference option.");
}
break;
case 'h':
// Host address.
if (settings.media == null) {
settings.media = new GXNet();
}
net = (GXNet) settings.media;
net.setHostName(it.getValue());
break;
case 't':
// Trace.
if ("Error".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.ERROR;
else if ("Warning".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.WARNING;
else if ("Info".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.INFO;
else if ("Verbose".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.VERBOSE;
else if ("Off".compareTo(it.getValue()) == 0)
settings.trace = TraceLevel.OFF;
else
throw new IllegalArgumentException(
"Invalid Authentication option. (Error, Warning, Info, Verbose, Off).");
break;
case 'p':
// Port.
if (settings.media == null) {
settings.media = new GXNet();
}
net = (GXNet) settings.media;
net.setPort(Integer.parseInt(it.getValue()));
break;
case 'P':// Password
settings.client.setPassword(it.getValue().getBytes());
break;
case 'i':
// IEC.
settings.iec = true;
break;
case 'S':// Serial Port
settings.media = new GXSerial();
GXSerial serial = (GXSerial) settings.media;
serial.setPortName(it.getValue());
break;
case 'a':
try {
settings.client.setAuthentication(
Authentication.valueOfString(it.getValue()));
} catch (Exception e) {
throw new IllegalArgumentException(
"Invalid Authentication option: '" + it.getValue()
+ "'. (None, Low, High, HighMd5, HighSha1, HighGmac, HighSha256)");
}
break;
case 'o':
break;
case 'c':
settings.client
.setClientAddress(Integer.parseInt(it.getValue()));
break;
case 's':
settings.client
.setServerAddress(Integer.parseInt(it.getValue()));
break;
case 'x':
settings.path = it.getValue();
break;
case '?':
switch (it.getTag()) {
case 'c':
throw new IllegalArgumentException(
"Missing mandatory client option.");
case 's':
throw new IllegalArgumentException(
"Missing mandatory server option.");
case 'h':
throw new IllegalArgumentException(
"Missing mandatory host name option.");
case 'p':
throw new IllegalArgumentException(
"Missing mandatory port option.");
case 'r':
throw new IllegalArgumentException(
"Missing mandatory reference option.");
case 'a':
throw new IllegalArgumentException(
"Missing mandatory authentication option.");
case 'S':
throw new IllegalArgumentException(
"Missing mandatory Serial port option.\n");
case 't':
throw new IllegalArgumentException(
"Missing mandatory trace option.\n");
default:
showHelp();
return 1;
}
default:
showHelp();
return 1;
}
}
if (settings.media == null) {
showHelp();
return 1;
}
return 0;
}
}
The output is :
I am still here
5
------------------------------------------------------------
java.lang.Exception: Unknown xml path.
Unknown xml path.
The argument is :
-r ln -h ipaddress -p portno
Hi,
Hi,
You are using gurux.dlms.xmlClient, not gurux.dlms.client.example.java. XML client is supporting only logical name referencing at the moment.
BR,
Mikko
I ran the program gurux.dlms
I ran the program gurux.dlms.client.example.java.sample client with arguments -r ln -c 16 -s 1 -h ipaddress -p portno and i got the following output...
the output is :
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x1
Data send failed. Try to resend 1/3
Data send failed. Try to resend 2/3
Data send failed. Try to resend 3/3
Invalid connection.
I need read the smart meter data remotely provided ipv4 address and port number and other meter information...
Can u provide me any source (share the link) to learn DLMS...?
Hi,
Hi,
Your settings are not correct. Meter doesn't reply for this reason. What meter you try to read?
DLMS is a standard. You need to buy standard documents.
BR,
Mikko
I am trying to ITI ltd smart
I am trying to ITI ltd smart meter ...meter type is 6.
Hi,
Hi,
Try to connect first using GXDLMSDirector. Select "Indian Standard" to the manufacturer.
BR,
Mikko
Does GURUX DLMS director
Does GURUX DLMS director support for ubuntu 16.04 or Windows 10
Because i have windows 10 and ubuntu 16.04
if possible , how to install it ..
Hi,
Hi,
You can install it here to Windows:
http://www.gurux.fi/Downloads/gxdlmsdirector46/GXDLMSDirector.applicatiā¦
BR,
Mikko
I tried using GXDLMS Director
I tried using GXDLMS Director...it shows "Failed to receive reply within the given time"
are the parameters right ? i
are the parameters right ? i have mentioned the meter manufacturer details in the above comments..
Hi,
Hi,
Check that your port number and IP address are correct. Then make sure that "Start Protocol" is DLMS.
Make sure that your Manufacturer is "Indian Standard".
DLMS parameters vary among manufacturers. If one of the parameters is wrong, meter doesn't reply.
BR,
Mikko
BR,
Mikko
I have successfully
I have successfully established connection and i can able to read meter data ....how to add objects in java client example( as we can able to add in GXDLMS director )...I have some OBIS and attributes...
Hi,
Hi,
Don't read association view.
Then read objects like this:
GXDLMSClock clock = new GXDLMSClock("OBIS CODE");
read(clock, 2);
BR,
Mikko
which part of the code is for
which part of the code is for reading association view ....and where to add our own objects
Hi,
Hi,
Check client example an find associationview.
BR,
Mikko
Which part of the code should
Which part of the code should i comment(for association view) and where to add the above code ...could u pls clearly explain...cos i am new to DLMS
Hi,
Hi,
Find readAll(). Comment getAssociationView. Now association view is not read when you make connections. Read objects what you want to read here.
BR,
Mikko
Thanks a lot ...By the way
Thanks a lot ...By the way how to read billing data ...the corresponding OBIS is in Register,Extended Register and ProfileGeneric class....if i read with Register and ExtendedRegister it returns null ...if i use ProfileGeneric using the method readRowsByEntry with three arguments object name , index and count then the program reads other objects and it displays in console "capture read objects first"...So help me to read billing data ...And what is IC (a number)..is IC refers to GXDLMS Objects?
Hi,
Hi,
If you want to read profile generic, you need to read capture objects before reading buffer. That causes the issue.
IC = COSEM interface number.
BR,
Mikko
Could u pls email me ur
Could u pls email me ur contact
Hi,
Hi,
I'm sorry, but we can help only our clients by email and telco.
BR,
Mikko
Okay Mail id pls?
How to import python dlms project from github to pycham ?...i tried importing and ran the code ...its showing errors in imports
I created a new project in
Can u help me with connection establishing in python
Hi,
Hi,
What kind of errors you are getting? Do you try to import client example or DLMS library?
BR,
Mikko
I fixed those errors and I
I fixed those errors and I established connection successfully too...Now I am trying to read objects with read() function...I have problem in those
The syntax is :
data = GXDLMSRegister("1.0.12.7.0.255")
print(data)
The error is:
value = float(buff.getFloat())
TypeError: float() argument must be a string or a number, not 'tuple'
File : gurux_dlms/internal/_GXCommon.py", line 611, in getFloat
Hi,
Hi,
Your data is already in a float value. Remove cast.
value = buff.getFloat()
You don't need to call buff.getFloat. Data is already updated to data object.
you can get it like this:
print(data.value)
BR,
Mikko
If i remove cast it prints
If i remove cast it prints value like this "(3.471985001476767e-14,)"
The voltage value should not be like this...That OBIS is for votage
Hi,
Hi,
You need to check the scaler. Try to read scaler first and then check the value.
BR,
Mikko
Can u explain how to do it
Can u explain how to do it pls ...in python ...pls reply as soon as possible