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. Issue With DLMS Communication Via TCP/IP With Moxa Device

Issue with DLMS Communication via TCP/IP with Moxa Device

By fazamax , 27 March, 2025
Forums
Gurux.DLMS

Hello everyone,

I am currently working on a project where I need to communicate with an electricity meter using the DLMS/COSEM protocol via a Moxa device that acts as a TCP/IP converter. However, I am encountering an issue during the initialization of the DLMS session.

Here is the relevant part of my Python code:

from gurux_dlms.GXDLMSClient import GXDLMSClient
from gurux_net.GXNet import GXNet
from gurux_net.enums.NetworkType import NetworkType
from gurux_common.enums.TraceLevel import TraceLevel
import socket

# IP address and port of the Moxa device
MOXA_IP = "10.206.165.1"
MOXA_PORT = 4012

# Meter addresses
LOGICAL_ADDRESS = 1
HDLC_ADDRESS = 8209

# Set global timeout for sockets
socket.setdefaulttimeout(10)

try:
    # Configure TCP connection with Moxa
    connection = GXNet(NetworkType.TTCP, MOXA_IP, MOXA_PORT)

    # Configure DLMS client
    client = GXDLMSClient(
        useLogicalNameReferencing=True,
        clientAddress=LOGICAL_ADDRESS,
        serverAddress=HDLC_ADDRESS
    )
    client.trace = TraceLevel.VERBOSE

    # Open connection
    connection.open()

    # Initialize DLMS session
    snrm_request = client.snrmRequest()
    connection.send(snrm_request)

    # Receive SNRM response
    snrm_response = connection.receive(1024)
    print(f"SNRM Response: {snrm_response}")
    print(f"Type of SNRM Response: {type(snrm_response)}")
    if snrm_response is None:
        raise Exception("No response received for SNRM request.")
    if isinstance(snrm_response, int):
        raise Exception("Received an int value instead of the expected object.")
    client.parseUAResponse(snrm_response)

    # Send AARQ request
    aarq_request = client.aarqRequest()
    connection.send(aarq_request)

    # Receive AARQ response
    aarq_response = connection.receive(1024)
    if aarq_response is None:
        raise Exception("No response received for AARQ request.")
    client.parseAAREResponse(aarq_response)

    # Read data from the meter
    cosem_object = "1.1.1.8.0.255"
    data = client.read(connection, cosem_object)
    print(f"Read value: {data}")

except Exception as e:
    print(f"Communication error: {e.__class__.__name__} - {e}")
finally:
    try:
        connection.close()
    except Exception as e:
        print(f"Error closing connection: {e}")

The issue I am facing is that I receive an AttributeError: 'int' object has no attribute 'eop' when waiting for the SNRM response. The debug output shows that the type of snrm_response is int, which is unexpected.

Here is the debug output:

Creating TCP connection with Moxa...
Connection created: TCP 10.206.165.1:4012
DLMS client configured: <gurux_dlms.GXDLMSClient.GXDLMSClient object at 0x000001A7B52C3040>
Connecting to Moxa at 10.206.165.1:4012...
Connected to Moxa.
Initializing DLMS session...
SNRM Request: bytearray(b'~\xa0\x08\x80#\x03\x93&`~')
Waiting for SNRM response...
Communication error: AttributeError - 'int' object has no attribute 'eop'
Closing connection...
Connection closed.

I would appreciate any insights or suggestions on what might be causing this issue and how to resolve it.

Thank you in advance for your help!


 

Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Hi, I believe that the…

Hi,

I believe that the reason is in this line:
if isinstance(snrm_response, int):

When you send the SNRM request, you will receive UA response and you need to
use client.parseUAResponse to handle it. Check this:

https://gurux.fi/Gurux.DLMS.Client

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