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'm trying to connect with a DLMS concentrator that connects with a public static IP every 5 minutes. This concentrator use DLMS protocol, Logical Name Referencing and no using authentication during AA, then I'm using this configuration:
GXDLMSClient dlms = new GXDLMSClient(true, 16, 1, Authentication.NONE, null, InterfaceType.WRAPPER);
gurux.net.GXNet media = new gurux.net.GXNet();
media.setHostName("localhost");
media.setPort(4059);
media.setProtocol(NetworkType.TCP);
I initialize the connection using this method:
void initializeConnection() throws Exception, InterruptedException {
media.open();
GXReplyData reply = new GXReplyData();
for (byte[] it : dlms.aarqRequest()) {
System.out.println("AARQ Request:");
reply.clear();
readDLMSPacket(it, reply);
}
//Parse reply.
dlms.parseAareResponse(reply.getData());
}
And I read the packet with this method:
public void readDLMSPacket(byte[] data, GXReplyData reply) throws Exception {
if (data == null || data.length == 0) {
return;
}
reply.setError((short) 0);
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) {
writeTrace("<- " + now() + "\t" + GXCommon.bytesToHex(data));
media.send(data, null);
//If Eop is not set read one byte at time.
if (p.getEop() == null) {
p.setCount(1);
}
succeeded = media.receive(p);
if (!succeeded) {
// Try to read again...
if (pos++ != tryouts) {
System.out.println("Data send failed. Try to resend " + pos.toString() + "/"+tryouts);
continue;
} else {
JOptionPane.showMessageDialog(null, "Failed to receive reply from the device in given time.");
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.bytesToHex(p.getReply()));
if (reply.getError() != 0) {
if (reply.getError() == ErrorCode.REJECTED.getValue()) {
Thread.sleep(1000);
readDLMSPacket(data, reply);
} else {
throw new GXDLMSException(reply.getError());
}
}
}
This is the log:
<- 11:50:07.879 00 01 00 10 00 01 00 1F 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF
onTrace: 11:50:07 SENT 00 01 00 10 00 01 00 1F 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF
Data send failed. Try to resend 1/3
I did a listener attached to media that extending "IGXMediaListener" and "gurux.net.IGXNetListener", and every 5 minutes I correctly see the device connection with triggered "onClientConnected" callback:
This is the log:
Client '/X.X.X.X:35928' is connected.
Accept: true
Bytes Received: 0
Hostname: localhost
onTrace: 11:50:17 INFO Client connected.
Data send failed. Try to resend 2/3
And this is the callback:
@Override
public void onClientConnected(Object o, ConnectionEventArgs cea) {
System.out.println(String.format("Client '%1$s' is connected.", cea.getInfo()));
System.out.println("Accept: " + cea.getAccept());
GXNet server = (GXNet) o;
try (GXNet cl = server.attach(cea.getInfo())) {
System.out.println("Bytes Received: " + cl.getBytesReceived());
System.out.println("Hostname: " + cl.getHostName());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
Why bytes received are always 0 if I send AA message continuosly?
GPRS network
Hi,
You should check this:
http://www.gurux.fi/Gurux.DLMS.DynamicIP
Meter starts connection.
BR,
Mikko
Hi Kurumi,
Hi Kurumi,
thank you for your immediate answer, now I correctly pass the Application Association Request/Response but I still have an issue while reading the Application View from the concentrator. This is the log:
1 - Initialize Connection:
Send AARQ request. 00 01 00 10 00 01 00 1F 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF
Reading Data Block
Reading DLMS Packet
<- 10:10:46.508 00 01 00 10 00 01 00 1F 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF
-> 10:10:48.343 00 01 00 01 00 10 00 2B 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 02 14 FF FF 00 07
Parsing AARE reply: 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 02 14 FF FF 00 07
Parsing AARE reply succeeded.
2 - Association View:
Reading Data Block
Reading DLMS Packet
<- 10:10:48.343 00 01 00 10 00 01 00 0D C0 01 C1 00 0F 00 00 28 00 00 FF 02 00
-> 10:10:50.766 00 01 00 01 00 10 00 05 C4 01 C1 01 04
gurux.dlms.GXDLMSException: Access Error : Device reports a undefined object.
at com.gestsrl.dlms_cosem.GXDLMSReader.readDLMSPacket(GXDLMSReader.java:226)
at com.gestsrl.dlms_cosem.GXDLMSReader.readDataBlock(GXDLMSReader.java:127)
at com.gestsrl.dlms_cosem.GXDLMSReader.getAssociationView(GXDLMSReader.java:105)
at com.gestsrl.dlms_cosem.GXDLMSReader.readAll(GXDLMSReader.java:59)
at com.gestsrl.dlms_cosem.GXListener.onClientConnected(GXListener.java:91)
at gurux.net.GXNet.notifyClientConnected(GXNet.java:295)
at gurux.net.ListenerThread.run(ListenerThread.java:105)
The code I'm using for the reader is like your (java-equivalent):
https://github.com/Gurux/Gurux.DLMS.Net/blob/master/Gurux.DLMS.Meter.Li…
Why error code 4 (UNDEFINED_OBJECT) was raised after the concentrator'reply?
Thanks in advance,
Francesco
GPRS network
Hi Francesco,
You was not saying what meter (manufacturer and model) you try to read?
Can you read it with GXDLMSDirector?
UNDEFINED_OBJECT means that Association View object is not implemented to the meter
or you don't have rights to read it.
BR,
Mikko
Hi Kurumi,
Hi Kurumi,
as always thanks to your fast reply, I'm trying to read a URMET Universal concentrator (model 63776-0015) with GPRS module, and not is present in the manufacturer list of GXDLMSDirector.
I make the client like this:
GXDLMSClient dlms = new GXDLMSClient(true, 16, 1, Authentication.NONE, null, InterfaceType.WRAPPER);
I don't know yet if Association View object is implemented to the meter but, as far as I understand, client address 16 is for "Public client", It might be that I don't have permission to read the Application View?
I have LDN, System Title and keyC of this device: how can I authenticate as "Management Client" and request the full OBIS objects list?
Thanks a lot for your support.
Francesco
HI Francesco,
HI Francesco,
Association view is mandatory in DLMS. You should ask this from manufacturer.
If you want to make secured connection connection you must set Systemtitle, BlockCipherKey, AuthenticationKey and used Security level. Something like this:
GXDLMSSecureClient cl = new GXDLMSSecureClient(your connection settings);
cl.Ciphering.Security= ;
cl.Ciphering.Systemtitle = ;
cl.Ciphering.BlockCipherKey= ;
cl.Ciphering.AuthenticationKey = ;
Correct values you can get from the meter manufacturer.
BR,
Mikko