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. Dynamic Invocation Counter Management In Python Using Gurux GXDLMS Library

Dynamic Invocation Counter Management in Python Using Gurux GXDLMS Library

By KavyaYanamandra , 22 January, 2025
Forums
Gurux.Serial

Hi Mikko,

I am working on a Python application using the Gurux GXDLMS library and need assistance with managing the invocation counter dynamically. Specifically, the counter value should be retrieved from the 16 association (logical name: 0.0.43.1.3.255) and then updated dynamically in the 48 association. The update can either use the exact value retrieved from the 16 association or apply an increment (e.g., adding +1 or +10 to the retrieved value). I would appreciate guidance or examples on how to implement this functionality effectively to ensure accurate and dynamic updates.

####
as this is code i wrote individually for 16 association and read the invocation counter from the meter:
#####

# Initialize GXSerial connection
ser = GXSerial(port="COM3")
ser.__setBaudRate = int(9600)
ser.__setDataBits = 8
ser.__setStopBits = 1
ser.__setParity = 0
ser.open()

if ser.isOpen():
print("Serial port opened")

# Initialize settings and secure client
settings = GXSettings()
client = GXDLMSSecureClient()

# Assign the client and media to settings
settings.client = client
settings.media = ser
settings.trace = TraceLevel.INFO
settings.outputFile = "output.xml"
# Client properties
client.useLogicalNameReferencing= True
client.clientAddress=16
client.serverAddress=1
client.forAuthentication=Authentication.NONE
client.password=None
client.interfaceType=InterfaceType.HDLC

try:
# Initialize GXDLMSReader
reader = GXDLMSReader(client, ser, TraceLevel.INFO, invocationCounter=1)
reader.initializeConnection()

invocation_counter = GXDLMSData("0.0.43.1.3.255")
#invocation_counter = reader.invocationCounter
#invocation_counter += 10 # Or +1 as needed
invocation_counter = reader.read(invocation_counter,2)

# Use the updated invocation counter in subsequent requests
# reader.invocationCounter = invocation_counter

print("Updated Invocation Counter:", invocation_counter)

except Exception as ex:
print("Error during connection or reading:", ex)
finally:
ser.close()

##############################################
and this is my settings of 48 association i gave in my application:

settings = GXSettings()
global disc
settings.media = ser
reader = None
reader= GXDLMSReader(settings.client, settings.media, settings.trace, settings.invocationCounter)
settings.client.ciphering.security= Security.AUTHENTICATION_ENCRYPTION
settings.client.ciphering.blockCipherKey = bytes(str(Entry4.get()), encoding="UTF-8")
settings.client.ciphering.authenticationKey = bytes(str(Entry5.get()), encoding='UTF-8')
settings.client.ciphering.dedicatedKey = bytes(str(Entry6.get()), encoding="UTF-8")
settings.client.password = str(Entry1.get())
settings.client.clientAddress = 48
settings.client.serverAddress = 1
settings.trace = TraceLevel.INFO
settings.outputFile = "output.xml"
settings.client.ciphering.Security = SecuritySuite.AES_GCM_128
settings.client.hdlcSettings.DEFAULT_WINDOWS_SIZE_TX = 1
settings.client.hdlcSettings.DEFAULT_WINDOWS_SIZE_RX = 1
settings.client.isAuthenticationRequired = SourceDiagnostic.AUTHENTICATION_REQUIRED
settings.client.authentication = Authentication.HIGH

Regards

Kavya

Profile picture for user Kurumi

Kurumi

1 year 4 months ago

Hi, I can help you only with…

Hi,

I can help you only with DLMS-specific questions. You need to check the client example. It does what you want to do.

https://github.com/Gurux/Gurux.DLMS.Python/tree/master/Gurux.DLMS.Clien…

BR,
Mikko

  • 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