hello sir
I have a problem with the serial port connection. When I call the following code to close the link
if (Media != null)
{
GXReplyData reply = new GXReplyData();
readDLMSPacket(dlms.disconnectRequest(), reply);
Media.close();
}
But when I disconnect and reinitialize the link, I get an Invalid logical or physical address error. How should I solve it?
Forums
Now a new problem has arisen…
Now a new problem has arisen. He will prompt that no reply has been received after a timeout. The following is the code.
Standard: DLMS
System title: 4D 4D 4D 00 00 BC 61 4E
Authentication key: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
Block cipher key 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
Dedicated key: 52 47 45 41 53 46 53 53 41 54 43 46 4B 50 56 4A
line: TX: 19:16:08.984 2F 3F 21 0D 0A
line : RX: 19:16:09.171 2F 58 4D 53 35 5C 32 54 34 39 31 30 48 44 31 35 46 57 31 31 33 0D 0A
line: RX: 19:16:09.171 06 32 35 32 0D 0A
line: TX: 19:16:10.079 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Data sending failed. Try to resend 1/3
line: TX: 19:16:11.080 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Data sending failed. Try to resend 2/3
line: TX: 19:16:12.080 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Data sending failed. Try to resend 3/3
line: TX: 19:16:13.080 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Failed to receive reply from the device in given time.
This problem is also due to the use of
readDLMSPacket(dlms.disconnectRequest(), reply);
Caused by disconnection and reconnection, please tell me how to deal with it.
Hi, Please, don't add two…
Hi,
Please, don't add two different questions to the same topic.
#1. With some meters, you need to wait for a while before reconnecting.
#2. I believe that your server or client address is different than the meter expects when you establish the connection with the optical head.
You can connect using IEC and it seems like changing to mode E succeeded.
BR,
Mikko
Thank you, the first problem…
Thank you, the first problem has been solved. How should I deal with the second problem? When I close the connection after getting data from the instrument, the following method
public void close() throws Exception {
if (Media != null && Media.isOpen()) {
GXReplyData reply = new GXReplyData();
try {
if (dlms.getInterfaceType() == InterfaceType.WRAPPER
|| (dlms.getInterfaceType() == InterfaceType.HDLC
&& dlms.getCiphering().getSecurity() != Security.NONE)) {
readDataBlock(dlms.releaseRequest(), reply);
}
} catch (Exception e) {
}
reply.clear();
readDLMSPacket(dlms.disconnectRequest(), reply);
Media.close();
}
}
When I initialize and connect again, the instrument does not reply
reader = new GXDLMSReader(settings.client, settings.media, settings.trace, settings.invocationCounter);
void initializeConnection() throws Exception, InterruptedException {
if (Media instanceof GXSerial) {
GXSerial serial = (GXSerial) Media;
serial.setDtrEnable(true);
serial.setRtsEnable(true);
}
updateFrameCounter();
initializeOpticalHead();
GXReplyData reply = new GXReplyData();
byte[] data = dlms.snrmRequest();
if (data.length != 0) {
readDLMSPacket(data, reply);
// Has server accepted client.
dlms.parseUAResponse(reply.getData());
int size = (int) ((((Number) dlms.getHdlcSettings().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()) {
// Update public key certificate and private key.
if (dlms.getAuthentication() == Authentication.HIGH_ECDSA) {
Path path = Paths.get("Keys",
"D" + GXDLMSTranslator.toHex(dlms.getCiphering().getSystemTitle(), false)
+ ".pem");
if (!Files.exists(path)) {
throw new IllegalArgumentException("Client Private key file is missing. "
+ GXDLMSTranslator.toHex(dlms.getCiphering().getSystemTitle(), false));
}
GXPkcs8 key = GXPkcs8.load(path);
// Load public key of the server.
path = Paths.get("Certificates",
"D" + GXDLMSTranslator.toHex(dlms.getSourceSystemTitle(), false) + ".pem");
GXx509Certificate cert = GXx509Certificate.load(path);
dlms.getCiphering()
.setSigningKeyPair(new KeyPair(cert.getPublicKey(), key.getPrivateKey()));
}
for (byte[] it : dlms.getApplicationAssociationRequest()) {
readDLMSPacket(it, reply);
}
dlms.parseApplicationAssociationResponse(reply.getData());
}
}
Standard: DLMS
System Header: 4D 4D 4D 00 00 BC 61 4E
Authentication Key: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
Block Cipher Key 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
Private Key: 52 47 45 41 53 46 53 53 41 54 43 46 4B 50 56 4A
Line: TX: 19:16:08.984 2F 3F 21 0D 0A Line
: RX: 19:16:09.171 2F 58 4D 53 35 5C 32 54 34 39 31 30 48 44 31 35 46 57 31 31 33 0D 0A
Line: RX: 19:16:09.171 06 32 35 32 0D 0A
Line: TX: 19:16:10.079 7E A0 0A 02 FE 02 61 93 64 C4 7E
Data transmission failed. Try to resend 1/3
Line: TX: 19:16:11.080 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Data transmission failed. Try to resend 2/3
Line: TX: 19:16:12.080 7E A0 0A 02 FE 02 FF 61 93 64 C4 7E
Data transmission failed. Try to resend 3/3
Line: TX: 19:16:13.080 7E A0 0A 02 FE 02
Hi, In your log, you are…
Hi,
In your log, you are communicating with an optical probe. Is that purpose?
Some meters are expecting that you need to wait about one second after before sending SNRM message. Are your client and server address correct? Can you connect with GXDLMSDirector?
BR,
Mikko
Yes, it is a client address…
Yes, it is a client address problem. Thank you. The problem is solved. The client was not initialized during reinitialization, which caused the address error. I reinitialized Settings and the problem was solved. Thank you very much and I wish you good health.