Hello,
I am new with DLMS.Any help would be great !!
I am trying to read data from Kimbal smart meter(Manufactured by:Sinhal Udyog pvt ltd)) using optical cable.
I have successfully Established Connection.Please find all Connection Logs Below.
Sending SNMR Request for -->
TX: 7E A0 07 03 61 93 69 47 7E
RX: 7E A0 20 61 03 73 05 9E 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
SNMR Success -->
Sending AARQ Request for -->
TX: 7E A0 6B 03 61 10 2A FF E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 31 32 33 34 35 36 37 38 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 1D 21 35 06 39 3D 59 45 54 4B 77 5C 6E 11 21 68 BE 23 04 21 21 1F 30 0A 99 E4 05 88 CC A1 D2 62 12 B5 52 5C A4 20 1E 3A DC C0 BE 27 C2 60 93 E2 EA EB 76 12 26 DD FB 7E
RX: 7E A0 77 61 03 30 AD 6C E6 E7 00 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 4B 42 4C 00 00 89 6D 7C 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 41 49 5C 53 46 7C 48 1B 68 59 51 45 3A 20 24 59 BE 23 04 21 28 1F 30 00 00 10 A9 1C 8A F7 8A D1 BE B9 2B 28 AF 8E 18 B7 0C 8E 19 A0 6B 1D 9F 54 EB D5 5B 4C 36 58 F1 7E
Parsing AARE Response For--->08 00 06 5F 1F 04 00 20 18 9D 02 EE 00 07
Parsing AARE reply succeeded. -->
Parsing HLS authentication For: --->
TX: 7E A0 3E 03 61 32 7B 46 E6 E6 00 CB 30 30 0A 99 E4 05 4A CD 60 D2 6B 4D AA 7E 5C A4 C1 02 C4 2A E6 D5 7A 48 84 9B 6E 50 32 EB 73 93 32 B8 65 FE 36 F7 25 50 D5 93 45 D1 1D 95 92 0D A4 38 A6 7E
RX: 7E A0 37 61 03 52 0E 3A E6 E7 00 CF 29 30 00 00 10 AA 24 BA 80 7B A5 44 AF F1 FB 9C 08 64 A9 BE 9D 49 3E 36 D5 8A 3F 02 4C F3 70 CF A1 5F 76 AF 45 2C CB 35 62 A3 9E F0 7E
Parsing HLS authentication For Rx: --->09 10 6C 38 1B 89 B5 C2 48 C6 85 45 18 76 68 ED 52 41
Connection Established
Request send for RTC:
Reading Data Tx: 7EA0190361543998E6E600C001C200080000010000FF0200D3E47E
TX: 7E A0 19 03 61 54 39 98 E6 E6 00 C0 01 C2 00 08 00 00 01 00 00 FF 02 00 D3 E4 7E
RX: 7E A0 07 61 03 97 5D E7 7E
Response for RTC: 20-Aug-2025 12:52:21
Request send for Serial NO:
Reading Data Tx: 7EA019036176299AE6E600C001C300010000600100FF0200AB0B7E
TX: 7E A0 19 03 61 76 29 9A E6 E6 00 C0 01 C3 00 01 00 00 60 01 00 FF 02 00 AB 0B 7E
RX: 7E A0 07 61 03 97 5D E7 7E
com.inventive.mrilib.readData.GXDLMSException: Access Error : Unknown error.
We have Already Read Allied , LNT,HPL,JPM Meter from our Code
Sorry I forgot adding how we…
Sorry I forgot adding how we set invocation counter, I tried 3 type to set invocation counter. When we trying to read invocation counter from 2nd type then its giving access error unkown error.
1) long value = System.currentTimeMillis();
long onejanmili = 1577817000000L;
value = value - onejanmili;
value = value / 1000;
// value= value + 1;
dlms.getCiphering().setInvocationCounter(value);
2) GXDLMSData counterObj = new GXDLMSData("0.0.43.1.3.255"); // KIMBAL specific
GXReplyData reply = new GXReplyData();
for (byte[] it : dlms.read(counterObj, 2)) {
readDLMSPacket(it, reply);
}
while (reply.isMoreData()) {
readDLMSPacket(dlms.receiverReady(reply.getMoreData()), reply);
}
long invocationCounter = Long.parseLong(reply.getValue().toString());
reply.clear();
Log.d("TAG", "Invocation Counter read from meter --> " + invocationCounter);
// Disconnect public session
reply.clear();
readDLMSPacket(dlms.disconnectRequest(), reply);
reply.clear();
// Dynamically set for secure client
dlms.getCiphering().setInvocationCounter(invocationCounter + 1);
3) dlms.getCiphering().setInvocationCounter(0xFFFFFFFF);
Hi, You need to read the…
Hi,
You need to read the invocation counter from the meter like it is done in updateFrameCounter method:
https://github.com/Gurux/gurux.dlms.java/blob/fcf1d205a69a12f12dcc82bfc…
BR,
Mikko
Hi, We are using serial…
Hi,
We are using serial communication using optical probe through GXCommunicate Class for this. So, Please suggest me how to set invocation counter in my initializeConnection Function.
Hi, Check the link that I…
Hi,
Check the link that I shared with you. It will do all the needful.
There might be multiple invocation counter objects, so make sure that you read the right one.
BR,
Mikko
Hello,Now we are using…
Hello,
Now we are using updateframecounter method as you suggest but same problem occured when we trying to read invocation counter then value return null
private void updateFrameCounter() throws Exception {
try {
if (dlms.getCiphering() != null
&& dlms.getCiphering().getSecurity() != Security.NONE) {
// Media settings are saved and they are restored when HDLC with
// mode E is used.
String mediaSettings = media.getSettings();
byte[] data;
GXReplyData reply = new GXReplyData();
reply.clear();
int add = dlms.getClientAddress();
int serverAdd = dlms.getServerAddress();
byte[] serverSt = dlms.getServerSystemTitle();
Authentication auth = dlms.getAuthentication();
Security security = dlms.getCiphering().getSecurity();
Signing signing = dlms.getCiphering().getSigning();
byte[] challenge = dlms.getCtoSChallenge();
try {
dlms.setServerSystemTitle(null);
dlms.setClientAddress(16);
dlms.setAuthentication(Authentication.NONE);
dlms.getCiphering().setSecurity(Security.NONE);
dlms.getCiphering().setSigning(Signing.NONE);
data = dlms.snrmRequest();
if (data.length != 0) {
readDLMSPacket(data, reply);
// Has server accepted client.
dlms.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.
try {
if (!dlms.isPreEstablishedConnection()) {
reply.clear();
readDataBlock(dlms.aarqRequest(), reply);
// Parse reply.
dlms.parseAareResponse(reply.getData());
}
reply.clear();
GXDLMSData d = new GXDLMSData("0.0.43.1.3.255");
dlms.read(d, 2);
long iv = ((Number) d.getValue()).longValue();
iv += 1;
dlms.getCiphering().setInvocationCounter(iv);
// writeTrace("Invocation counter: " + String.valueOf(iv), TraceLevel.INFO);
reply.clear();
disconnect();
// Reset media settings back to default.
if (dlms.getInterfaceType() == InterfaceType.HDLC_WITH_MODE_E) {
media.close();
media.setSettings(mediaSettings);
}
} catch (Exception Ex) {
disconnect();
throw Ex;
}
} finally {
dlms.setServerSystemTitle(serverSt);
dlms.setClientAddress(add);
dlms.setServerAddress(serverAdd);
dlms.setAuthentication(auth);
dlms.getCiphering().setSecurity(security);
dlms.setCtoSChallenge(challenge);
dlms.getCiphering().setSigning(signing);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
GXDLMSData d = new GXDLMSData("0.0.43.1.3.255");
dlms.read(d, 2);
long iv = ((Number) d.getValue()).longValue();
d.getValue return null
}
TX: 7E A0 07 03 21 93 0F 01…
Hello,
Now I am able to get invocation counter but after that when i read RTC & Serial Number its giving access error unknown error
All Logs are attached
TX: 7E A0 07 03 21 93 0F 01 7E RX: 7E A0 20 21 03 73 73 98 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
Reading Data
Tx: 7EA02B032110FBAFE6E600601DA109060760857405080101BE10040E01000000065F1F0400001E1DFFFFC5E47E
TX: 7E A0 2B 03 21 10 FB AF E6 E6 00 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 00 1E 1D FF FF C5 E4 7E
RX: 7E A0 37 21 03 30 6C 7C E6 E7 00 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 00 10 02 EE 00 07 A6 F3 7E
Reading Data Tx: 7EA0190321326FD8E6E600C001C1000100002B0102FF02000BB67E
TX: 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E RX: 7E A0 15 21 03 52 5D 8A E6 E7 00 C4 01 C1 00 06 00 00 00 05 D0 4F 7E
Found Invocation Counter at 0.0.43.1.2.255 = 5
DisconnectRequest TX: 7E A0 07 03 21 53 03 C7 7E RX: 7E A0 20 21 03 73 73 98 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
Sending SNMR Request for -->
TX: 7E A0 20 03 61 93 1B 9F 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E RX: 7E A0 20 61 03 73 05 9E 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
SNMR Success -->
Sending AARQ Request for -->
TX: 7E A0 6B 03 61 10 2A FF E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 4B 49 4D 31 32 33 34 35 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 6E 37 68 74 28 5A 77 3E 5A 39 08 59 12 66 4F 2F BE 23 04 21 21 1F 30 00 0F 42 45 28 AC 8B D5 D0 97 2D ED C3 DE B3 B2 31 5A D6 F2 2B 8E 7F 6E 96 52 21 AE 93 F8 08 10 7E
RX: 7E A0 77 61 03 30 AD 6C E6 E7 00 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 4B 42 4C 00 00 89 6D 7C 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 6A 5A 63 71 6E 61 43 2E 68 2A 46 21 16 3D 34 1E BE 23 04 21 28 1F 30 00 00 12 76 C0 CE 7A 04 BA FF 0C 16 BF B8 27 66 F3 9A 97 76 64 8D 70 1E 70 E1 E9 12 97 40 9F 5B 7E
Parsing AARE Response For--->08 00 06 5F 1F 04 00 20 18 9D 02 EE 00 07
Parsing AARE reply succeeded. -->
Parsing HLS authentication For: --->
TX: 7E A0 3E 03 61 32 7B 46 E6 E6 00 CB 30 30 00 0F 42 45 EA AD 4A D5 D9 C8 32 C1 C3 DE 52 AE CF AC 6C 51 BC 6F DB 7E 4A BA 5E 05 DD F2 BD C5 08 FB 50 27 D6 2D A6 B3 F5 92 0C 9F 3C 0E 6B B8 01 7E RX: 7E A0 37 61 03 52 0E 3A E6 E7 00 CF 29 30 00 00 12 77 00 A3 4F 40 F5 AC 04 30 C8 5E 21 44 00 C1 CC 8D 81 E7 F9 C0 0D D1 44 70 B9 C2 76 62 FB 6B BD 21 C5 CE 3E FE E8 73 7E
Parsing HLS authentication For Rx: --->
09 10 9C 63 9F F0 EF 9E 66 93 70 FB 91 7B C2 02 08 5E
Connection Established
Request send for RTC: Reading Data Tx:
7EA0190361543998E6E600C001C200080000010000FF0200D3E47E TX: 7E A0 19 03 61 54 39 98 E6 E6 00 C0 01 C2 00 08 00 00 01 00 00 FF 02 00 D3 E4 7E RX: 7E A0 07 61 03 97 5D E7 7E
com.inventive.mrilib.readData.GXDLMSException: Access Error : Unknown error. at com.inventive.mrilib.readData.GXCommunicate.readDLMSPacket(GXCommunicate.java:343) at com.inventive.mrilib.readData.GXCommunicate.readDataBlock(GXCommunicate.java:376) at com.inventive.mrilib.readData.GXCommunicate.readObject(GXCommunicate.java:964) at com.inventive.mrilib.mri.MRIAsync.readMeter(MRIAsync.java:947) at com.inventive.mrilib.mri.MRIAsync.readData(MRIAsync.java:899) at com.inventive.mrilib.mri.MRIAsync.doInBackground(MRIAsync.java:216) at com.inventive.mrilib.mri.MRIAsync.doInBackground(MRIAsync.java:63) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:317) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651) at java.lang.Thread.run(Thread.java:1119) com.inventive.mrilib.readData.GXDLMSException: Access Error : Unknown error. at com.inventive.mrilib.readData.GXCommunicate.readDLMSPacket(GXCommunicate.java:348) at com.inventive.mrilib.readData.GXCommunicate.readDataBlock(GXCommunicate.java:376) at com.inventive.mrilib.readData.GXCommunicate.readObject(GXCommunicate.java:964) at com.inventive.mrilib.mri.MRIAsync.readMeter(MRIAsync.java:947) at com.inventive.mrilib.mri.MRIAsync.readData(MRIAsync.java:899) at com.inventive.mrilib.mri.MRIAsync.doInBackground(MRIAsync.java:216) at com.inventive.mrilib.mri.MRIAsync.doInBackground(MRIAsync.java:63) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:317) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651) at java.lang.Thread.run(Thread.java:1119)
Response for RTC: 26-Aug-2025 16:23:25
Request send for Serial NO: Reading Data Tx: 7EA019036176299AE6E600C001C300010000600100FF0200AB0B7E TX: 7E A0 19 03 61 76 29 9A E6 E6 00 C0 01 C3 00 01 00 00 60 01 00 FF 02 00 AB 0B 7E RX: 7E A0 07 61 03 97 5D E7 7E com.inventive.mrilib.readData.GXDLMSException: Access Error : Unknown error.
Please help its very urgent
Hi, I need your block cipher…
Hi,
I need your block cipher and authentication keys to decrypt this.
BR,
Mikko
Hello, Please provide me…
Hello,
Please provide me your Mail ID for sharing keys securely
Hello As advised, I have…
Hello
As advised, I have shared all the vendor details and keys with the email ID provided by you. I request you to kindly review the same and provide the necessary solution at the earliest.
Looking forward to your response.
Hi, Please, don't share…
Hi,
Please, don't share information by email. I believe that was phishing, and the person has now been removed.
Your problem is that you establish a secure connection, but you try to read the clock with a normal read. You need to check that.
BR,
Mikko
Hii, But also need to read…
Hii,
But also need to read Serial NO number & all billing details. So, Please suggest what can i do
Hi, Verify that you haven't…
Hi,
Verify that you haven't changed the security setting from AuthenticationEncryption to None after establishing the connection.
Check how this is done in the client example.
BR,
Mikko
Hii, I have checked after…
Hii,
I have checked after reading invocation counter we already set security setting AuthenticationEncryption. Please find the attached code for your reference.
public boolean initializeConnection(String initialisationMode, Devices devices) throws ConnectionBrokenException,
Exception, InterruptedException {
boolean resFlag = false;
try {
if (initialisationMode.equals(Constants.InitializationMode.NONE)) {
dlms.setAuthentication(Authentication.NONE);
dlms.getCiphering().setSecurity(Security.NONE);
} else if (initialisationMode.equals(Constants.InitializationMode.HIGH)) {
long value = System.currentTimeMillis();
long onejanmili = 1577817000000L;
value = value - onejanmili;
value = value / 1000;
dlms.setAuthentication(Authentication.HIGH);
if (ObisCodeConstants.MasterObisCodes.IMAGE_TRANSFER.equals(devices.getObisCode())) {
dlms.setClientAddress(80);
dlms.setPassword(devices.getFirwarePwd().getBytes("ASCII"));
} else {
dlms.setClientAddress(48);
dlms.setPassword(devices.getHighPwd().getBytes("ASCII"));
}
dlms.getCiphering().setAuthenticationKey(devices.getAuthKey().getBytes("ASCII"));
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
if (devices.getCipheringMode().equalsIgnoreCase("YES")) {
dlms.getCiphering().setSecurity(Security.AUTHENTICATION_ENCRYPTION);
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
dlms.getCiphering().setBlockCipherKey(devices.getCipheringKey().getBytes("ASCII"));
dlms.setInterfaceType(InterfaceType.HDLC);
dlms.setServerAddress(1);
dlms.setUseLogicalNameReferencing(true);
dlms.setAutoIncreaseInvokeID(true);
dlms.setStandard(Standard.DLMS);
dlms.setUseUtc2NormalTime(true);
} else {
dlms.getCiphering().setSecurity(Security.NONE);
}
if (devices.getManufacturer().equals("Allied")) {
dlms.getCiphering().setInvocationCounter(value);
} else if (devices.getManufacturer().equals("Kimbal")) {
/* GXDLMSData gxdlmsData = new GXDLMSData("0.0.43.1.2.255");
// Create a reply data container
GXReplyData reply = new GXReplyData();
Log.d("TAG", "Start Getting Invocation Counter --> ");
// Read invocation counter using public client
for (byte[] it : dlms.read(gxdlmsData, 2)) {
readDLMSPacket(it, reply);
}
// Handle remaining data packets if any
while (reply.isMoreData()) {
readDLMSPacket(dlms.receiverReady(reply.getMoreData()), reply);
}
Log.d("TAG", "Getting Invocation Counter --> ");
// Extract the invocation counter
long invocationCounter = Long.parseLong(reply.getValue().toString());
reply.clear();
Log.d("TAG", "Invocation Counter --> " + invocationCounter);
readDLMSPacket(dlms.disconnectRequest(), reply);
reply.clear();
// Assign counter to secure client
dlms.getCiphering().setInvocationCounter(invocationCounter + 1);*/
updateFrameCounter();
dlms.setAuthentication(Authentication.HIGH);
if (ObisCodeConstants.MasterObisCodes.IMAGE_TRANSFER.equals(devices.getObisCode())) {
dlms.setClientAddress(80);
dlms.setPassword(devices.getFirwarePwd().getBytes("ASCII"));
} else {
dlms.setClientAddress(48);
dlms.setPassword(devices.getHighPwd().getBytes("ASCII"));
}
dlms.getCiphering().setAuthenticationKey(devices.getAuthKey().getBytes("ASCII"));
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
if (devices.getCipheringMode().equalsIgnoreCase("YES")) {
dlms.getCiphering().setSecurity(Security.AUTHENTICATION_ENCRYPTION);
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
dlms.getCiphering().setBlockCipherKey(devices.getCipheringKey().getBytes("ASCII"));
dlms.setInterfaceType(InterfaceType.HDLC);
dlms.setServerAddress(1);
dlms.setUseLogicalNameReferencing(true);
dlms.setAutoIncreaseInvokeID(true);
dlms.setStandard(Standard.DLMS);
dlms.setUseUtc2NormalTime(true);
} else {
dlms.getCiphering().setSecurity(Security.NONE);
}
} else {
dlms.getCiphering().setInvocationCounter(0xFFFFFFFF);
}
} else if (initialisationMode.equals(Constants.InitializationMode.LOW)) {
long currentTimeInMillsec = System.currentTimeMillis();
long randomMillisec = 1577817000000L;
currentTimeInMillsec = currentTimeInMillsec - randomMillisec;
currentTimeInMillsec = currentTimeInMillsec / 1000;
dlms.getCiphering().setInvocationCounter(currentTimeInMillsec);
dlms.setAuthentication(Authentication.LOW);
dlms.setPassword(devices.getLowPwd().getBytes("ASCII"));
dlms.getCiphering().setAuthenticationKey(devices.getAuthKey().getBytes("ASCII"));
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
if (devices.getCipheringMode().equalsIgnoreCase("YES")) {
if (devices.getManufacturer().equalsIgnoreCase(Constants.ManufacturerCodes.HEXING_MANUFACTURER)
|| devices.getManufacturer().equalsIgnoreCase(Constants.ManufacturerCodes.ZEN))//Change Nitin for ZEN/Hexing Meter
{
dlms.getCiphering().setSecurity(Security.AUTHENTICATION_ENCRYPTION);
} else {
dlms.getCiphering().setSecurity(Security.ENCRYPTION);
}
dlms.getCiphering().setSystemTitle(devices.getSystemTitle().getBytes("ASCII"));
dlms.getCiphering().setBlockCipherKey(devices.getCipheringKey().getBytes("ASCII"));
} else {
dlms.getCiphering().setSecurity(Security.NONE);
}
}
resFlag = true;
} catch (Exception e) {
e.printStackTrace();
resFlag = false;
}
System.out.println(devices.getSystemTitle());
GXReplyData reply = new GXReplyData();
try {
byte[] data = dlms.snrmRequest();
Log.d("TAG", "Sending SNMR Request for --> ");
if (data.length != 0) {
readDLMSPacket(data, reply);
Log.d("TAG", "SNMR Success --> ");
//TextFileHandler.loggedData("Parsing SNMR Response for ---> "+ dlmsMeterGenricInfoBean.getSystemTitle()+" :"+ GXCommon.bytesToHex(reply.getData().array()));
//TextFileHandler.loggedData("SNMR Reply Error of" + dlmsMeterGenricInfoBean.getSystemTitle()+": "+reply.getError());
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);
}
} catch (ConnectionBrokenException e) {
Log.d("TAG", "SNMR Exception Data --> " + e.getMessage());
e.printStackTrace();
} catch (Exception e) {
Log.d("TAG", "SNMR Exception Data --> " + e.getMessage());
e.printStackTrace();
throw e;
}
reply.clear();
try {
// 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 : dlms.aarqRequest()) {
Log.d("TAG", "Sending AARQ Request for --> ");
//TextFileHandler.loggedData("Sending AARQ Request for......" + dlmsMeterGenricInfoBean.getSystemTitle() );
try {
//TextFileHandler.loggedData(GXCommon.bytesToHex(reply.getData().array()));
readDLMSPacket(it, reply);
} catch (Exception exception) {
exception.printStackTrace();
throw exception;
}
}
try {
// Parse reply.
dlms.parseAareResponse(reply.getData());
Log.d("TAG", "Parsing AARE Response For--->" + GXCommon.bytesToHex(reply.getData().array()));
//TextFileHandler.loggedData("AARE Reply Error of" + dlmsMeterGenricInfoBean.getSystemTitle()+": "+reply.getError());
Log.d("TAG", " Parsing AARE reply succeeded. --> ");
reply.clear();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
// Get challenge Is HLS authentication is used.
if (dlms.getIsAuthenticationRequired()) {
//byte a[] = dlms.getApplicationAssociationRequest()[0];
Log.d("TAG", "Parsing HLS authentication For: --->");
for (byte[] it : dlms.getApplicationAssociationRequest()) {
// Log.d("TAG" , "readDLMSPacket ki It value : - " + it);
readDLMSPacket(it, reply);
}
dlms.parseApplicationAssociationResponse(reply.getData());
Log.d("TAG", "Parsing HLS authentication For Rx: --->" + GXCommon.bytesToHex(reply.getData().array()));
} else {
Log.d("TAG", "Parsing HLS authenticationv Fail For Rx: --->" + GXCommon.bytesToHex(reply.getData().array()));
}
resFlag = true;
//flag = true;
} catch (ConnectionBrokenException e) {
resFlag = false;
Log.d("TAG", "Parsing HLS --->" + e.getMessage());
throw e;
}
return resFlag;
}
after initialize connection when we read serial no then given access error unkown error
String serialNo = Read_Data_Type(reader, "0.0.96.1.0.255") != null ? Read_Data_Type(reader, "0.0.96.1.0.255").trim() : "";
Hi, One of your settings is…
Hi,
One of your settings is different that the meter expects.
You don't usually count the invocation counter from the onejanmili. You read it from the meter.
You need to ask the correct settings from the meter manufacturer, or you can try to use different settings with GXDLMSDirector.
BR,
Mikko
Hii Mikko,…
Hii Mikko,
updateFrameCounter Method is used to set invocation counter where we read invocation counter from meter then set after +1
private long updateFrameCounter() throws Exception {
long invocationCounter = 0;
try {
// if (dlms.getCiphering() != null
// && dlms.getCiphering().getSecurity() != Security.NONE) {
String mediaSettings = media.getSettings();
GXReplyData reply = new GXReplyData();
reply.clear();
int add = dlms.getClientAddress();
int serverAdd = dlms.getServerAddress();
byte[] serverSt = dlms.getServerSystemTitle();
Authentication auth = dlms.getAuthentication();
Security security = dlms.getCiphering().getSecurity();
Signing signing = dlms.getCiphering().getSigning();
byte[] challenge = dlms.getCtoSChallenge();
try {
dlms.setServerSystemTitle(null);
dlms.setClientAddress(16);
dlms.setAuthentication(Authentication.NONE);
dlms.getCiphering().setSecurity(Security.NONE);
dlms.getCiphering().setSigning(Signing.NONE);
// SNRM
byte[] data = dlms.snrmRequest();
if (data.length != 0) {
readDLMSPacket(data, reply);
dlms.parseUAResponse(reply.getData());
}
// AARQ
if (!dlms.isPreEstablishedConnection()) {
reply.clear();
readDataBlock(dlms.aarqRequest(), reply);
dlms.parseAareResponse(reply.getData());
}
// === Find the correct OBIS for Invocation Counter ===
String[] possibleObis = {
"0.0.43.1.3.255"
};
Long iv = null;
for (String obis : possibleObis) {
try {
GXDLMSData d = new GXDLMSData(obis);
GXReplyData reply2 = new GXReplyData();
readDataBlock(dlms.read(d, 2), reply2);
// Update object value
dlms.updateValue(d, 2, reply2.getValue());
Object val = d.getValue();
if (val != null) {
iv = ((Number) val).longValue();
System.out.println("Found Invocation Counter at " + obis + " = " + iv);
break;
}
} catch (Exception ex) {
// Ignore and try next OBIS
}
}
if (iv == null) {
throw new Exception("Invocation counter could not be read from any OBIS.");
}
// Increment and set
// dlms.getCiphering().setInvocationCounter(iv + 1);
reply.clear();
disconnect();
invocationCounter = iv +1;
// Reset media if needed
if (dlms.getInterfaceType() == InterfaceType.HDLC_WITH_MODE_E) {
media.close();
media.setSettings(mediaSettings);
}
} catch (Exception Ex) {
disconnect();
Ex.printStackTrace();
throw Ex;
} finally {
// Restore original settings
dlms.setServerSystemTitle(serverSt);
dlms.setClientAddress(add);
dlms.setServerAddress(serverAdd);
dlms.setAuthentication(auth);
dlms.getCiphering().setSecurity(security);
dlms.setCtoSChallenge(challenge);
dlms.getCiphering().setSigning(signing);
}
//}
} catch (Exception e) {
e.printStackTrace();
}
return invocationCounter;
}
Hi, Try to read your meter…
Hi,
Try to read your meter with GXLMSDirector. It will help you to understand how to access your DLMS meter. It will also show the command line arguments that you can use to connect with the example client.
Please, don't copy example code here. It doesn't help.
BR,
Mikko