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. How Can I Send SNRM and AARQ Command By GXSerial and How Can I Received Data From Energy Meter By GX Serial

How can I send SNRM and AARQ command by GXSerial and how can I received data from energy meter by GX Serial

By satishjyoti1998 , 8 September, 2023
Forums
Gurux.Serial

import time
from gurux_common import ReceiveParameters
from gurux_common import IGXMediaListener
from gurux_common.enums.TraceLevel import TraceLevel
from gurux_serial import GXSerial

#pylint: disable=no-self-argument
class sampleclient(IGXMediaListener):

def __init__(self):
#List available serial ports.
print("Available ports:")
print(str(GXSerial.getPortNames()))
#Define End Of Packet char.
#eop = '\r'
#eop = '\~'
#eop = None
eop = 0x7E
#eop = ''
#TODO: Update correct port and serial port settings.
media = GXSerial("COM3")
#Start to listen events from the media.
media.addListener(self)
media.
#Show all traces.
media.trace = TraceLevel.VERBOSE
#Set EOP for the media.
media.eop = eop
try:
#Open the connection.
media.open()
r = ReceiveParameters()
r.eop = eop
#Minimium amount of bytes to receive.
r.count = 100
#Wait reply for 2 seconds.
r.waitTime = 1000
############################
#Send data synchronously.
with media.getSynchronous():
list1 = [0x7E, 0xA0, 0x07, 0x03, 0x21, 0x53, 0x03, 0xC7, 0x7E]
list1 = bytearray(list1)
#media.send("Hello world!")
media.send(list1)
#Send EOP
#media.send('\r')
ret = media.receive(r)
if ret:
print(str(r.reply.decode("ascii")))
else:
raise Exception("Failed to receive reply from the server.")
############################
#Send async data.
media.send("Notify from the meter!\r")
#Wait 1 second to receive reply from the server.
time.sleep(1)
except Exception as ex:
print(ex)
media.close()
media.removeListener(self)

def onError(self, sender, ex):
"""
Represents the method that will handle the error event of a Gurux
component.

sender : The source of the event.
ex : An Exception object that contains the event data.
"""
print("Error has occured. " + str(ex))

def onReceived(self, sender, e):
"""Media component sends received data through this method.

sender : The source of the event.
e : Event arguments.
"""
print("New data is received. " + str(e))

def onMediaStateChange(self, sender, e):
"""Media component sends notification, when its state changes.
sender : The source of the event.
e : Event arguments.
"""
print("Media state changed. " + str(e))

def onTrace(self, sender, e):
"""Called when the Media is sending or receiving data.

sender : The source of the event.
e : Event arguments.
"""
print("trace:" + str(e))

def onPropertyChanged(self, sender, e):
"""
Event is raised when a property is changed on a component.

sender : The source of the event.
e : Event arguments.
"""
print("Property {!r} has hanged.".format(str(e)))

if __name__ == '__main__':
sampleclient()

Profile picture for user Kurumi

Kurumi

2 years 8 months ago

Hi, You need to use DLMS…

Hi,

You need to use DLMS client example for that.
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