Skip to main content
Home
for DLMS smart meters

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

5 months 3 weeks 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

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 07/09/2025 - 16:41
    Gurux.Serial.Android 2.0.13
  • Wed, 07/09/2025 - 12:07
    gurux.dlms.c 9.0.2507.0901
  • Sat, 07/05/2025 - 15:04
    Gurux.DLMS.Python 1.0.188
  • Tue, 07/01/2025 - 10:09
    Gurux.DLMS.Python 1.0.187
  • Tue, 07/01/2025 - 09:54
    gurux.dlms.c 9.0.2507.0101

New forum topics

  • DLMS communication issue when routing through VPN on Android
  • ESP32-Based Smart Meter Interface via DLMS/COSEM
  • svr_postWrite: args->size Always Zero
  • DLMS over LoraWan in water metering
  • Update High password - any way to cipher new password
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin