Hi All
Firstly let me tell you that based on the activity on this site and the criticality of the technology you have open sourced - I am very impressed. Kudos to the development team and to the customer support.
I am currently working with a Taiwanese meter of unknown origins (does not seem DLMS certified from the FLAGs page).
From documentation it seems that a 'Verification Client' can connect to the meter with no authentication and no encryption.
So I've tried with the Director - but the client always times out.
I have used an oscilloscope to verify that the meter actually responds and I can also see it in the verbose mode.
However, the eop settings are possibly not right and the client times out and then sends a disconnect request.
Could you please help?
The following is a log from 1 session:
02:11:06 02:11:06.528 Info Opening
02:11:06 02:11:06.528 Info Serial Port Settings: Port Name: COM15 Baud Rate: 19200 Data Bits: 8 Parity: None Stop Bits: One Eop: None
02:11:06 02:11:06.682 Info Open
02:11:07 Send SNRM request.
TX: 7E A0 08 02 21 21 93 05 D1 7E
02:11:07 02:11:07.682 Sent 7E A0 08 02 21 21 93 05 D1 7E
02:11:07 02:11:07.683 Received 7E
02:11:07 02:11:07.691 Received 7E 00 00 00 14 34 05 60
02:11:12 Failed to receive reply from the device in given time.
02:11:12 Send Disconnect request.
TX: 7E A0 08 02 21 21 53 09 17 7E
02:11:12 02:11:12.684 Sent 7E A0 08 02 21 21 53 09 17 7E
02:11:12 02:11:12.685 Received 7E
02:11:12 02:11:12.693 Received 7E 00 00 14 34 95 2E FC
02:11:17 Data send failed. Try to resend 1/3 7E 00 00 00 14 34 05 60 DE 7E
02:11:17 02:11:17.694 Sent 7E A0 08 02 21 21 53 09 17 7E
02:11:17 02:11:17.695 Received 00
02:11:17 02:11:17.708 Received 7E 7E 00 00 14 34 95 2E
02:11:22 Failed to receive reply from the device in given time. 7E 00 00 00 14 34 05 60 DE 7E 00 00 00 14 34 95 2E FC 7E
02:11:22
RX: 7E 00 00 00 14 34 05 60 DE 7E 00 00 00 14 34 95 2E FC 7E
02:11:22 02:11:22.708 Info Closing
02:11:22 02:11:22.747 Info Closed
More Information on this attempt. I have created a small program based on your examples to test just the nrsm part and see some interesting results:
The following is the response from the meter for 2 successive runs - it seems to be responding with different values? Is this expected? Following is the code itself:
C:\Users\300227639\Desktop>java -Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n -jar gurux.jar
Listening for transport dt_socket at address: 9000
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPENING----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPENING
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:Settings: Port: COM15 Baud Rate: BAUD_RATE_19200 Data Bits: 8 Parity: NONE Stop Bits: ONE Eop:None----
???
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPEN----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPEN
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x10
>>>: 09:39:03.516 7E A0 07 21 21 93 8C B7 7E
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E A0 07 21 21 93 8C B7 7E----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:00----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:07----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:40----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:30----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:80----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:9B----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:FF----
C:\Users\300227639\Desktop>java -Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n -jar gurux.jar
Listening for transport dt_socket at address: 9000
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPENING----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPENING
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:Settings: Port: COM15 Baud Rate: BAUD_RATE_19200 Data Bits: 8 Parity: NONE Stop Bits: ONE Eop:None----
???
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPEN----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPEN
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x10
>>>: 09:39:25.540 7E A0 07 21 21 93 8C B7 7E
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E A0 07 21 21 93 8C B7 7E----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:00----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:07----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:40----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:02----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:9B----
FATAL ERROR in native method: Timeout occurred
at gurux.io.NativeCode.read(Native Method)
at gurux.serial.GXReceiveThread.run(GXReceiveThread.java:170)
GXDLMSClient client = new GXDLMSClient(true, 0x10, 0x10, Authentication.NONE, null, InterfaceType.HDLC);
serial.open();
Reader reader = new Reader(client, serial, TraceLevel.VERBOSE);
// 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.
GXReplyData reply = new GXReplyData();
byte[] data;
data = client.snrmRequest();
if (data != null) {
reader.readDLMSPacket(data, reply);
//Has server accepted client.
client.parseUAResponse(reply.getData());
} else {
throw new IllegalStateException("No data for snrm message - we have a problem");
}
//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();
reader.readDLMSPacket(it, reply);
}
//Parse reply.
client.parseAareResponse(reply.getData());
}
More Information on this
More Information on this attempt. I have created a small program based on your examples to test just the nrsm part and see some interesting results:
The following is the response from the meter for 2 successive runs - it seems to be responding with different values? Is this expected? Following is the code itself:
C:\Users\300227639\Desktop>java -Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n -jar gurux.jar
Listening for transport dt_socket at address: 9000
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPENING----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPENING
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:Settings: Port: COM15 Baud Rate: BAUD_RATE_19200 Data Bits: 8 Parity: NONE Stop Bits: ONE Eop:None----
???
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPEN----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPEN
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x10
>>>: 09:39:03.516 7E A0 07 21 21 93 8C B7 7E
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E A0 07 21 21 93 8C B7 7E----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:00----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:07----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:40----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:30----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:80----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:9B----
Apr 17, 2019 9:39:03 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:FF----
C:\Users\300227639\Desktop>java -Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n -jar gurux.jar
Listening for transport dt_socket at address: 9000
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPENING----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPENING
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:Settings: Port: COM15 Baud Rate: BAUD_RATE_19200 Data Bits: 8 Parity: NONE Stop Bits: ONE Eop:None----
???
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:OPEN----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onMediaStateChange
INFO: STATECHANGED:OPEN
Authentication: None
ClientAddress: 0x10
ServerAddress: 0x10
>>>: 09:39:25.540 7E A0 07 21 21 93 8C B7 7E
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E A0 07 21 21 93 8C B7 7E----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:7E----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:00----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:07----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:40----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:02----
Apr 17, 2019 9:39:25 AM biz.swiftsense.dlms.gurux.client.Test$1 onTrace
INFO: ontrace:9B----
FATAL ERROR in native method: Timeout occurred
at gurux.io.NativeCode.read(Native Method)
at gurux.serial.GXReceiveThread.run(GXReceiveThread.java:170)
import java.util.logging.Logger;
import javax.print.attribute.standard.Media;
import gurux.common.GXCommon;
import gurux.common.IGXMediaListener;
import gurux.common.MediaStateEventArgs;
import gurux.common.PropertyChangedEventArgs;
import gurux.common.ReceiveEventArgs;
import gurux.common.ReceiveParameters;
import gurux.common.TraceEventArgs;
import gurux.common.enums.TraceLevel;
import gurux.dlms.GXDLMSClient;
import gurux.dlms.GXDLMSException;
import gurux.dlms.GXReplyData;
import gurux.dlms.enums.Authentication;
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 Test {
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) throws Exception {
GXSerial serial = new GXSerial();
serial.setBaudRate(BaudRate.BAUD_RATE_19200);
serial.setDataBits(8);
serial.setParity(Parity.NONE);
serial.setStopBits(StopBits.ONE);
serial.setPortName("COM15");
serial.setReadTimeout(20000);
serial.setWriteTimeout(20000);
serial.setTrace(TraceLevel.VERBOSE);
serial.addListener(new IGXMediaListener() {
@Override
public void onTrace(Object sender, TraceEventArgs e) {
Logger.getLogger(Test.class.getName()).info("ontrace:" + e.dataToString(false) + "----");
}
@Override
public void onReceived(Object sender, ReceiveEventArgs e) {
Logger.getLogger(Test.class.getName()).info("RCV--------------------------");
System.out.println("...");
}
@Override
public void onPropertyChanged(Object sender, PropertyChangedEventArgs e) {
// TODO Auto-generated method stub
System.out.println("???");
}
@Override
public void onMediaStateChange(Object sender, MediaStateEventArgs e) {
Logger.getLogger(Test.class.getName()).info("STATECHANGED:" + e.getState().name());
}
@Override
public void onError(Object sender, Exception ex) {
Logger.getLogger(Test.class.getName()).severe("ERROR");
}
});
/*
GXDLMSSecureClient client = new GXDLMSSecureClient(true, 0x11, 0x10, Authentication.NONE, null, InterfaceType.HDLC);
client.getCiphering().setSecurity(Security.ENCRYPTION);
// client.getCiphering().setInvocationCounter(1);
client.getCiphering().setSystemTitle(GXCommon.hexToBytes("3137303030303633"));
//client.getCiphering().setSystemTitle(GXCommon.hexToBytes("4D4D4D0000BC614E"));
client.getCiphering().setAuthenticationKey(GXCommon.hexToBytes("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF")); // == AK
client.getCiphering().setBlockCipherKey(GXCommon.hexToBytes("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF")); // == AK
client.getCiphering().setSecuritySuite(SecuritySuite.AES_GCM_128);
//client.getCiphering().setBlockCipherKey(GXCommon.hexToBytes("000102030405060708090A0B0C0D0E0F")); // == GUK
//client.getCiphering().setAuthenticationKey(GXCommon.hexToBytes("000102030405060708090A0B0C0D0E0F")); // == GUK
client.getProposedConformance().add(Conformance.GENERAL_PROTECTION);
*/
GXDLMSClient client = new GXDLMSClient(true, 0x10, 0x10, Authentication.NONE, null, InterfaceType.HDLC);
serial.open();
Reader reader = new Reader(client, serial, TraceLevel.VERBOSE);
// 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.
GXReplyData reply = new GXReplyData();
byte[] data;
data = client.snrmRequest();
if (data != null) {
reader.readDLMSPacket(data, reply);
//Has server accepted client.
client.parseUAResponse(reply.getData());
} else {
throw new IllegalStateException("No data for snrm message - we have a problem");
}
//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();
reader.readDLMSPacket(it, reply);
}
//Parse reply.
client.parseAareResponse(reply.getData());
}
}
Hi,
Hi,
Try to change server address from 1 to 144 0x90. Give hex value 0x90 to server address in GXDLMSDirector. Let me know if you have problems.
BR,
Mikko