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. Forums
  3. Write Data To Object In DLMS Meter

Write data to object in DLMS Meter

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By ajuz , 14 November, 2022
Forums
Gurux.DLMS

Hello,

I just want to simply read and write value to an object and I use Client example for that by passing the required values arguments through an api request . But the write operation returns an error.

Also I will I pass my desired value to be written on to write function , i think doesn't use a value argument . Could you help me to figure this out?

//After Association view
self.getReadOut()
self.getProfileGenerics()
data = GXDLMSData("0.2.0.0.0.255")
print(self.read(data,2))
self.write(data,2)
except (KeyboardInterrupt, SystemExit):
#Don't send anything if user is closing the app.
self.media = None
raise
finally:
self.close()

Out:

100 #value as requested
DisconnectRequest
Access Error : Device reports Read-Write denied.
Ended. Press any key to continue.

Profile picture for user Kurumi

Kurumi

3 years 6 months ago

Hi,

Hi,

I believe that you have connected without authentication and you don't have the access right to write the object. You need to check that first.

BR,
Mikko

ajuz

3 years 6 months ago

Hi,

Hi,

I also have another doubt. If I want to write or set value 200 into my object item how will i pass that value into our write function?

def write(self, item, attributeIndex):
data = self.client.write(item, attributeIndex)
self.readDLMSPacket(data)

Profile picture for user Kurumi

Kurumi

3 years 6 months ago

Hi,

Hi,

You can do it like this:

data = GXDLMSData("0.2.0.0.0.255")
#Change GXInt16 to data type what you want to write.
data.value = GXInt16(200)
write(data, 2)

BR,
Mikko

ajuz

3 years 6 months ago

Hi,

Hi,
Thank you so much for your fast help. I am new to this environment . When I try to run write function with mentioned given
data = GXDLMSData("0.2.0.0.0.255")
data.value= GXInt16(200)
reader.write(data,2)

return an error in write function client.py line no937 mentioning that invalid parameter and value type must give
if value is not None and type_ == DataType.NONE:
raise Exception("Invalid parameter. In python value type must give.")

error:

Traceback (most recent call last):
File "main.py", line 124, in main
print(reader.write(data,2))
File "/media/sf_shared/Gurux.DLMS.Python-master/Gurux.DLMS.Client.Example.python/GXDLMSReader.py", line 365, in write
data = self.client.write(item, int(attributeIndex))
File "/home/ajuzz/venv_aj/lib/python3.8/site-packages/gurux_dlms/GXDLMSClient.py", line 927, in write
return self.__write(item.name, value, type_, item.objectType, index)
File "/home/ajuzz/venv_aj/lib/python3.8/site-packages/gurux_dlms/GXDLMSClient.py", line 938, in __write
raise Exception("Invalid parameter. In python value type must give.")
Exception: Invalid parameter. In python value type must give.
Ended. Press any key to continue.

Profile picture for user Kurumi

Kurumi

3 years 6 months ago

Hi,

Hi,

I'm sorry. I didn't remember this. There is a legacy reason for this. I hope it can be removed at some point. You need to set the data type like this at the moment:

data = GXDLMSData("0.2.0.0.0.255")
item.setDataType(index, DataType.UINT32)
data.value= GXInt16(200)
reader.write(data,2)

BR,
Mikko

ajuz

3 years 6 months ago

Hi

Hi
Yeah. It works fine ,was issue with datatype was not set.

Thanks
Ajith

Aritza2

3 years ago

Hi I need help with this…

Hi

I need help with this code, i dont understand this:

data = GXDLMSData("0.2.0.0.0.255")
item.setDataType(index, DataType.UINT32)
data.value= GXInt16(200)
reader.write(data,2)

you want write 200 in your device, and the type es int16, why you set data type first to UINT32?

I want write a UINT8 data and the device return: gurux_dlms.GXDLMSException.GXDLMSException: Access Error : Device reports a unmatched type.

thanks

Profile picture for user Kurumi

Kurumi

3 years ago

Hi Aritza, The data is write…

Hi Aritza,

The data is write using UINT32, because datatype overrides the GXInt16.
The data can be directly int like this:
data.value= 200;

The device reports an unmatched type means that you try to write value where types don't match. Read the value from the meter and check the data type. You need to use the same data type when you write a value for the meter.

BR,
Mikko

Aritza2

3 years ago

thanks for your answer. I…

thanks for your answer.

I have already solved my mistake and I have already managed to learn to write with your program.

Now I need to write an octet string and I don't know how I should pass it to my computer, I am using GXbytebuffer and I have generated a buffer with my code, would it be passed in the same way? putting data.value = buffer that I just created with my code.

Sorry for the inconvenience. Thank you

Profile picture for user Kurumi

Kurumi

3 years ago

Hi, You can write the value…

Hi,

You can write the value by returning bytebuffers value as byte array. Like this:

GXByteBuffer bb = new GXByteBuffer();
// Set bb value....

GXDLMSData d = new GXDLMSData();
d.Value = bb.ToArray();
//Write value for the meter.

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

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin