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. Skeleton C/cpp Example Code To Connect To Holley Meter Using HLS-5/GMAC?

skeleton c/cpp example code to Connect to Holley meter using HLS-5/GMAC?

By Joe0x7F , 31 December, 2024
Forums
Gurux DLMS for ANSI C

Hi Mikko,

I hope you had or are having a very good holiday season if you celebrate.

I need to develop a c/cpp Linux program that will Connect to/Read Object/Disconnect from a Holley DLMS meter using HLS-5/GMAC.

I was able to perform these functions successfully with DLMSDirector, as described in thread https://www.gurux.fi/node/25689.

Do you have a good skeleton c/cpp example program that will perform at least the Connect (HLS-5/GMAC) function that I can use to start my development?

I assume that DLMSDirector source code is not available?

Thank you!

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

HI, You can use the client…

HI,

You can use the client example to connect and read your meter. GXDLMSDirector shows the command line parameters when you select the meter.

https://github.com/Gurux/GuruxDLMS.c/tree/master/GuruxDLMSClientExample

BR,
Mikko

Joe0x7F

1 year 5 months ago

Thanks, Mikko. The Windows…

Thanks, Mikko.

The Windows version of DLMDirector works with this meter.

And, I was able to build gurux.dlms.client.bin on Linux.

But, when I run gurux.dlms.client.bin with the command line found in DLMSDirector, it just returns the help screen and no error message, and does not work.

Any idea how I can run gurux.dlms.client.bin to Connect and Read Object?

This is what I tried:

(Note that the serial connection in Linux is "/dev/ttyUSB0" and not COM1.)

---

joe@joe-virtual-machine:~/GuruxDLMS.c/GuruxDLMSClientExample/bin$ sudo ./gurux.dlms.client.bin -S /dev/ttyUSB0:9600:8NoneOne -c 32 -s 156 -a HighGMAC -C AuthenticationEncryption -T 73797374656D7469 -A 00000000000000000000000000000000 -B 00000000000000000000000000000000 -v 0.0.43.1.2.255 -w 1 -f 128 -t Verbose
[sudo] password for joe:
GuruxDlmsSample reads data from the DLMS/COSEM device.
GuruxDlmsSample -h [Meter IP Address] -p [Meter Port No] -c 16 -s 1 -r SN
-h host name or IP address.
-p port number or name (Example: 1000).
-u UDP is used. -S serial port.
-a Authentication (None, Low, High, HighMd5, HighSha1, HighGmac, HighSha256).
-P Password for authentication.
-c Client address. (Default: 16)
-s Server address. (Default: 1)
-n Server address as serial number.
-r [sn, sn] Short name or Logican Name (default) referencing is used.
-w WRAPPER profile is used. HDLC is default.
-t Trace messages.
-g Get selected object(s) with given attribute index. Ex -g "0.0.1.0.0.255:1; 0.0.1.0.0.255:2"
-C Security Level. (None, Authentication, Encrypted, AuthenticationEncryption)
-v Invocation counter data object Logical Name. Ex. 0.0.43.1.1.255
-I Auto increase invoke ID
-o Cache association view to make reading faster. Ex. -o C:\device.bin -T System title that is used with chiphering. Ex -T 4775727578313233
-A Authentication key that is used with chiphering. Ex -A D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF
-B Block cipher key that is used with chiphering. Ex -B 000102030405060708090A0B0C0D0E0F
-b Broadcast Block cipher key that is used with chiphering. Ex -b 000102030405060708090A0B0C0D0E0F -D Dedicated key that is used with chiphering. Ex -D 00112233445566778899AABBCCDDEEFF
-i Used communication interface. Ex. -i WRAPPER. -m Used PLC MAC address. Ex. -m 1. -R Data is send as a broadcast (UnConfirmed, Confirmed).Example:
Read LG device using TCP/IP connection.
GuruxDlmsSample -r SN -c 16 -s 1 -h [Meter IP Address] -p [Meter Port No]
Read LG device using serial port connection.
GuruxDlmsSample -r SN -c 16 -s 1 -sp COM1 -i
Read Indian device using serial port connection.
GuruxDlmsSample -S COM1 -c 16 -s 1 -a Low -P [password]
joe@joe-virtual-machine:~/GuruxDLMS.c/GuruxDLMSClientExample/bin$

---

Thank you!

Joe0x7F

1 year 5 months ago

Same results with this…

Same results with this command:

joe@joe-virtual-machine:~/GuruxDLMS.c/GuruxDLMSClientExample/bin$ sudo ./gurux.dlms.client.bin -S /dev/ttyUSB0 -c 32 -s 156 -a HighGMAC -C AuthenticationEncryption -T 73797374656D7469 -A 00000000000000000000000000000000 -B 00000000000000000000000000000000 -v 0.0.43.1.2.255 -w 1 -f 128 -t Verbose

Joe0x7F

1 year 5 months ago

It did not like the "-w 1 -f…

It did not like the "-w 1 -f 128" options.

Now I'm getting "InvocationCounterError".

joe@joe-virtual-machine:~/GuruxDLMS.c/GuruxDLMSClientExample/bin$ sudo ./gurux.dlms.client.bin -S /dev/ttyUSB0 -c 32 -s 156 -a HighGMAC -C AuthenticationEncryption -T 73797374656D7469 -A 00000000000000000000000000000000 -B 00000000000000000000000000000000 -v 0.0.43.1.2.255 -t Verbose
updateInvocationCounter

TX: 7E A0 08 02 39 21 93 52 92 7E

RX: 7E A0 1F 21 02 39 73 07 AF 81 80 12 05 01 C8 06 01 C8 07 04 00 00 00 01 08 04 00 00 00 01 AC B3 7E

TX: 7E A0 2C 02 39 21 10 40 69 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 40 1E 1D FF FF E7 25 7E

RX: 7E A0 38 21 02 39 30 D5 8F 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 12 1C 01 90 00 07 7E 7B 7E

TX: 7E A0 1A 02 39 21 32 19 84 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E

RX: 7E A0 16 21 02 39 52 E8 CE E6 E7 00 C4 01 C1 00 06 79 73 74 67 FA 54 7E
Invocation counter: 2037609576 (0x79737468)

TX: 7E A0 08 02 39 21 53 5E 54 7E

RX: 7E A0 1F 21 02 39 73 07 AF 81 80 12 05 01 C8 06 01 C8 07 04 00 00 00 01 08 04 00 00 00 01 AC B3 7E
InitializeConnection

TX: 7E A0 08 02 39 41 93 07 F7 7E

RX: 7E A0 1F 41 02 39 73 E3 36 81 80 12 05 01 C8 06 01 C8 07 04 00 00 00 01 08 04 00 00 00 01 AC B3 7E

TX: 7E A0 6C 02 39 41 10 37 CD E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 73 79 73 74 65 6D 74 69 8A 02 07 80 8B 07 60 85 74 05 08 02 05 AC 12 80 10 70 38 9C CE 67 B3 59 AC 56 AB 55 2A 15 8A 45 22 BE 23 04 21 21 1F 30 79 73 74 68 72 F4 4F 79 5E 4A 36 DB 38 4A 15 79 20 5B 18 13 BF D1 3C BC CA F8 E5 87 38 E0 A8 BF 7E

RX: 7E A0 78 41 02 39 30 13 D7 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 48 4F 4C 00 0C EC 4F 83 88 02 07 80 89 07 60 85 74 05 08 02 05 AA 12 80 10 67 09 30 4C 8B 3C 72 2E 8B C8 3F 27 3C 18 88 51 BE 23 04 21 28 1F 30 00 00 00 D6 9D 0A DE 3C 13 0B 55 B2 10 B0 86 5C 2C 81 53 AF 44 55 6A 46 13 C4 F0 67 A4 2A 5F 4A 7E

TX: 7E A0 49 02 39 41 32 E2 89 E6 E6 00 DB 08 73 79 73 74 65 6D 74 69 31 30 79 73 74 6B B0 E0 0A 58 16 C8 59 F6 ED DE 95 80 C1 E9 5A DD 61 F6 A2 C6 A6 D0 A3 68 CE 37 48 93 3E D4 82 1D BF A8 A5 BF C9 65 B9 D8 94 58 32 6F F9 AE 7E

RX: 7E A0 10 41 02 39 52 94 6C E6 E7 00 D8 01 06 83 37 7E

TX: 7E A0 08 02 39 41 53 0B 31 7E

RX: 7E A0 1F 41 02 39 73 E3 36 81 80 12 05 01 C8 06 01 C8 07 04 00 00 00 01 08 04 00 00 00 01 AC B3 7E
InvocationCounterError
joe@joe-virtual-machine:~/GuruxDLMS.c/GuruxDLMSClientExample/bin$

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

Hi, Have you modified the…

Hi,

Have you modified the source code? The invocation counter is increased too much. It should be increased only by one. I believe that is the reason for this.

BR,
Mikko

Joe0x7F

1 year 5 months ago

Hi Mikko, No, I have not…

Hi Mikko,

No, I have not modified the source code at all.

Thanks!

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

Hi, The invocation counter…

Hi,

The invocation counter was increased twice. This works with other meters, but because this is an issue it's fixed. Get the latest version from GitHub.

BR,
Mikko

Joe0x7F

1 year 5 months ago

> Get the latest version…

> Get the latest version from GitHub.

It is working now, Mikko.

Thank you!

  • 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
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin