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. Node
  3. 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

3 years 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

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin