Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Hi,
I am using premier 300 Indian meter.
I download the file from https://github.com/Gurux/gurux.dlms.java.
Import into the eclipse mars2 taking Existing maven project individual.Then using following set up:--
GXReplyData reply = new GXReplyData();
byte[] data = dlms.snrmRequest();
System.out.println("dnrm request data ::"+data.length);
if (data.length != 0) {
readDLMSPacket(data, reply);
// Has server accepted client.
dlms.parseUAResponse(reply.getData());
// Allocate buffer to same size as transmit buffer of the meter.
// Size of replyBuff is payload and frame (Bop, EOP, crc).
int size = (int) ((((Number) dlms.getLimits().getMaxInfoTX())
.intValue() & 0xFFFFFFFFL) + 40);
replyBuff = java.nio.ByteBuffer.allocate(size);
}
reply.clear();
readDataBlock(dlms.aarqRequest(), reply);
// Parse reply.
dlms.parseAareResponse(reply.getData());
reply.clear();
// Get challenge Is HLS authentication is used.
if (dlms.getAuthentication().getValue() > Authentication.LOW
.getValue()) {
for (byte[] it : dlms.getApplicationAssociationRequest()) {
readDLMSPacket(it, reply);
}
dlms.parseApplicationAssociationResponse(reply.getData());
}
}
-----------------------------------------------------------------------------------
public IGXMedia media = null;
public TraceLevel trace = TraceLevel.INFO;
public boolean iec = false;
public GXDLMSSecureClient client = new GXDLMSSecureClient(true);
// Objects to read.
public List<Map.Entry<String, Integer>> readObjects =
new ArrayList<Map.Entry<String, Integer>>();
------------------------------------------------------------------------------------
public void readDLMSPacket(byte[] data, GXReplyData reply)
throws Exception {
if (data == null || data.length == 0) {
return;
}
Object eop = (byte) 0x7E;
// In network connection terminator is not used.
if (dlms.getInterfaceType() == InterfaceType.WRAPPER
&& Media instanceof GXNet) {
eop = null;
}
Integer pos = 0;
boolean succeeded = false;
ReceiveParameters<byte[]> p =
new ReceiveParameters<byte[]>(byte[].class);
p.setAllData(true);
p.setEop(eop);
p.setCount(5);
p.setWaitTime(WaitTime);
synchronized (Media.getSynchronous()) {
while (!succeeded) {
Media.send(data, null);
if (p.getEop() == null) {
p.setCount(1);
}
succeeded = Media.receive(p);
if (!succeeded) {
// Try to read again...
if (pos++ != 3) {
System.out.println("Data send failed. Try to resend "
+ pos.toString() + "/3");
continue;
}
throw new RuntimeException(
"Failed to receive reply from the device in given time.");
}
}
dlms.getData(p.getReply(), reply);
// Loop until whole DLMS packet is received.
while (!reply.isComplete()) {
if (p.getEop() == null) {
p.setCount(1);
}
if (!Media.receive(p)) {
throw new Exception(
"Failed to receive reply from the device in given time.");
}
}
}
// writeTrace("-> " + now() + "\t" + GXCommon.toHex(p.getReply()));
writeTrace("-> " + now() + "\t" + GXCommon.bytesToHex(p.getReply()),
TraceLevel.VERBOSE);
if (reply.getError() != 0) {
throw new GXDLMSException(reply.getError());
}
}
-------------------------------------------------------------------------------
setUseLogicalNameReferencing(useLogicalNameReferencing);//true
setClientAddress(32);
setServerAddress(1);
setAuthentication(Authentication.LOW);
setPassword(GXCommon.getBytes("***************"));
setInterfaceType(interfaceType);//HDLC
-------------------------------------------------------------------------------
gurux.dlms.client.example.java-->Run As-->Java Application.
output in my console:
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]
---------------------------------------------------------------------------
I want to connect through serial media .Where I have to initialize the media settings?. Every time it taking null media and goes into the bellow condition.
if (settings.media == null) {
showHelp();
return 1;
}
So what should I do?
I also able to get data using Gurux DLMS Director and .net code with serial media , LOW authentication.
Please help me.
Regards,
Tanmay Pramanik.
Set the meter parameter
Hi,
¨You can try to read your meter using parameters:
GuruxDlmsSample -S COM1 -a Low -P passoword
BR,
Mikko
Failed to open port
Hi,
I have started to run dlms.client.example.java. I have passed arguments at run time i.e.
-S ttyUSB0 -c 16 -s 1 -a None
it is showing message
Failed to Open port: ttyUSB0.
I am using usb to serial connector on linux system.
I want to know that why port can not be opened? or if i am using wrong parameter?
I also want to know how to find serial port on linux.
Failed to open port
Hi,
Your serial port name is wrong. It's something like /dev/ttyUSB0.
You can list from USB devices using lsusb and dmesg commands.
BR,
Mikko