Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Example Code For Write and Action Methods

Example code for Write and Action Methods

Forum Rules

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.

By utkarsh , 16 January, 2020
Forums
Gurux DLMS for Java

Hi Mikko,

Can you please share example code for write and action methods.
Example for Disconnect control to make Connect from Disconnect.

Regards,
Utkarsh

Profile picture for user Kurumi

Kurumi

6 years 4 months ago

Hi Utkarsh,

Hi Utkarsh,

You can do actions like this:

GXReplyData reply = new GXReplyData();
GXDLMSDisconnectControl d = new GXDLMSDisconnectControl();
readDLMSPacket(d.remoteReconnect(dlms), reply);

Check the client example. There is a write-method that writes wanted object attribute to the meter.

BR,
Mikko

BR,
Mikko

utkarsh

6 years 4 months ago

Thanks Mikko. But meter

Thanks Mikko. But meter (server) side implementation will be the same ?
Currently below are the messages

Client Connected.
RX: 00 01 00 30 00 01 00 70 60 6E A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 E4 A4 FC 17 BA AB 5A 87 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 4E 37 64 78 66 6D 48 78 7A 43 67 32 38 34 72 65 BE 34 04 32 21 30 30 00 00 00 54 99 61 92 95 A4 8A BB 0C 79 AD C5 75 CC 57 7E 4E 78 97 ED C8 68 BC B4 F7 73 83 0A 84 A9 9E 44 FB D3 8C A9 00 CB 60 EB B3 39 E6 97
Jan 20, 2020 2:34:38 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: AARQ Request
TX: 00 01 00 01 00 30 00 6B 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 41 42 43 44 45 46 47 48 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 73 71 4B 39 13 43 2F 07 65 62 24 72 77 03 28 24 BE 23 04 21 28 1F 30 00 00 00 00 F0 72 25 65 5B 37 8D 02 B8 69 79 E5 8B FC 6A 1B 2D 19 2F EF 66 AA C2 19 6A CF
RX: 00 01 00 30 00 01 00 32 CB 30 30 00 00 00 55 01 AC 42 B7 91 CB F6 B6 3E 42 67 F5 F5 CD 3A EF 54 0C 8E 24 33 DB 4B 03 7E 2B 8C 8E 2E 47 D6 6B 98 AD 40 19 4E 43 5E 56 B7 C6 9A
Jan 20, 2020 2:34:38 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: Method Request
TX: 00 01 00 01 00 30 00 2B CF 29 30 00 00 00 00 3F 73 E2 3A 45 33 84 12 12 FC 70 EE 47 DE 08 9E A2 07 02 58 4A 2A DD 29 30 12 D1 F0 9C 2C C2 73 FA C7 7C C8
RX: 00 01 00 30 00 01 00 20 D0 1E 30 00 00 00 56 E2 28 2B 42 40 C7 15 EB 66 24 3E DF 68 A1 7F 39 6A 90 81 5E E9 4E D9 E2 53
Jan 20, 2020 2:34:38 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: Get Request
Client Read value from 0.0.96.3.10.255 attribute: 4.
TX: 7E A0 07 61 03 97 5D E7 7E
RX: 00 01 00 30 00 01 00 20 D0 1E 30 00 00 00 56 E2 28 2B 42 40 C7 15 EB 66 24 3E DF 68 A1 7F 39 6A 90 81 5E E9 4E D9 E2 53
Jan 20, 2020 2:34:58 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: Get Request
Client Read value from 0.0.96.3.10.255 attribute: 4.
TX: 7E A0 07 61 03 97 5D E7 7E
RX: 00 01 00 30 00 01 00 20 D0 1E 30 00 00 00 56 E2 28 2B 42 40 C7 15 EB 66 24 3E DF 68 A1 7F 39 6A 90 81 5E E9 4E D9 E2 53
Jan 20, 2020 2:35:18 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: Get Request
Client Read value from 0.0.96.3.10.255 attribute: 4.
TX: 7E A0 07 61 03 97 5D E7 7E
RX: 00 01 00 30 00 01 00 20 D0 1E 30 00 00 00 56 E2 28 2B 42 40 C7 15 EB 66 24 3E DF 68 A1 7F 39 6A 90 81 5E E9 4E D9 E2 53
Jan 20, 2020 2:35:38 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: Get Request
Client Read value from 0.0.96.3.10.255 attribute: 4.
TX: 7E A0 07 61 03 97 5D E7 7E
RX: 00 01 00 30 00 01 00 3B 62 39 80 01 00 BE 34 04 32 21 30 30 00 00 00 54 99 61 92 95 A4 8A BB 0C 79 AD C5 75 CC 57 7E 4E 78 97 ED C8 68 BC B4 F7 73 83 0A 84 A9 9E 44 FB D3 8C A9 00 CB 60 EB B3 39 E6 97
Jan 20, 2020 2:35:58 AM gurux.dlms.GXDLMSServerBase handleCommand
INFO: RELEASE Request
TX: 00 01 00 01 00 30 00 2A 63 24 80 01 00 BE 22 04 21 28 1F 30 00 00 00 01 4F B0 2C B4 68 C1 70 10 B8 6D AB 24 32 09 D3 C9 86 DE D2 30 BD 21 A9 98 23 04
Client Disconnected.

Regards,
Utkarsh

Profile picture for user Kurumi

Kurumi

6 years 4 months ago

Hi Utkarsh,

Hi Utkarsh,

You need to save values on the server side or if you are using disconnect control you need to get postAction and them disconnect the meter.
Check this:

https://www.gurux.fi/Gurux.DLMS.Server

BR,
Mikko

utkarsh

6 years 4 months ago

Hi Mikko,

Hi Mikko,

I don't want to save the values but just reply to HES successful SET or ACTION response.

As per README document, we can have own write/action implementation or it will be handled by framework. So I haven't changed write/action methods.

But getting exception while performing SET for ActivityCalendar.
In below code value is always NULL for ActivityCalendar object and get HARDWARE_FAULT exception.

private static void handleSetRequestNormal(final GXDLMSSettings settings,
final GXDLMSServerBase server, final GXByteBuffer data,
final int type, final GXDLMSLNParameters p,
final GXByteBuffer replyData, final GXDLMSTranslatorStructure xml)
throws Exception {
Object value = null;

if (value instanceof byte[]) {
DataType dt = obj.getDataType(index);
if (dt != DataType.NONE
&& dt != DataType.OCTET_STRING) {
value = GXDLMSClient.changeType((byte[]) value, dt);
}
}
e.setValue(value);
ValueEventArgs[] list = new ValueEventArgs[] { e };
if (p.isMultipleBlocks()) {
server.setTransaction(new GXDLMSLongTransaction(list,
Command.GET_REQUEST, data));
}
server.notifyWrite(list);
if (e.getError() != ErrorCode.OK) {
p.setStatus(e.getError().getValue());
} else if (!e.getHandled() && !p.isMultipleBlocks()) {
obj.setValue(settings, e); -> exception raised here.
}
server.notifyPostWrite(list);
p.setInvokeId(e.getInvokeId());
} catch (Exception ex) {
p.setStatus(ErrorCode.HARDWARE_FAULT.getValue());
}

Exception is raised from below code in GXDLMSActivityCalendar class
case 6:
tmp = new String((byte[]) e.getValue());

Regards,
Utkarsh

Profile picture for user Kurumi

Kurumi

6 years 4 months ago

Hi Utkarsh,

Hi Utkarsh,

We have clients who are using non-ASCII activity calendar names. For this reason, the name is expected to be HEX string as a default. I'll try to find a way how to handle this.
In the meantime, you need to do this in GXDLMSDirector.

Select "Access rights" from "Activity calendar". Then change "Active Calendar Name" UIType from None to String. See pic below. Now you can write names as ASCII string.

Now you can receive data as expected.

BR,
Mikko

Image
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin