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. Generate Set/Action Request Frame With Python Code

Generate Set/Action Request Frame with python Code

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 sahbi said , 30 September, 2021
Forums
Gurux.DLMS

I have this code :
item = GXDLMSObject(classId, LN)
client = GXDLMSClient()
client.useLogicalNameReferencing = True
client.interfaceType = InterfaceType.HDLC
client.clientAddress = 0x02
client.serverAddressSize = 2
client.serverAddress = 0x0221
data = client.read(item, Att_Method)[0]

result= binascii.hexlify(data) ==============> it is OKK and i dont have a
probleme : 7E A01A 0221 05 54 2D85 E6E600C001C100010000600100FF0200 89A0 7E

But i can't find how can i generate a WriteRequest/ActionRequest Frame :
for exemple for ErrorRegister Obis Code :
SET :request Type
C1 : Class Obis Code
1 : class id
0000616100FF : logical name
2 : Attribut
D0 : Data To Write

Thanks For your helps

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

You can use client.write -method to generate Set frame. Usually, there are methods in COMSEM objects to generate Action messages. Ex.
remoteDisconnect and remoteReconnect in GXDLMSDisconnectControl. You can also use GXDLMSClient.method to generate Action requests if it is't missing from the COSEM object, but let me know if you need something that is missing and it's added to the COSEM object. It's easier to use in that way.

BR,
Mikko

sahbi said

4 years 8 months ago

Hi,

Hi,
Thanks for your response,
I need an example for setRequest Obis Code in python language .
Thanks,
SAID Sahbi

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

You can use write for this:

https://github.com/Gurux/Gurux.DLMS.Python/blob/6e3b8b710c9459fca893611…

Example setting the clock.

clock = GXDLMSClock()
clock.time =datetime.datetime.now()
self.write(clock, 2)

BR,
Mikko

sahbi said

4 years 8 months ago

Hi,

Hi,
First of all, thanks for your reactivity.
I need to create a function with param ; ClasssId, LN, Attribut/Access , Data( if set or action request)
Gurux support this type of functions ?
If yes,can you redirect me an example Code

Thanks
SAHBI

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

Yes it's supported. This example is for clock object where ClasssId = 8. Attribute index is #2.

clock = GXDLMSClock("Logical Name")
#Read
self.read(clock, 2)
#Write
self.write(clock, 2)

BR,
Mikko

sahbi said

4 years 8 months ago

Hi,

Hi,
Your propose is to create a class for each objectObisRequested.
But i search a solution to instanciate one class (GXDLMSRequestOBISCode who have a classID ,LN , ....)
For example,i can't create a write request for ErrorRegisterRequest

I hope the request is clear.
Thanks,
Sahbi

sahbi said

4 years 8 months ago

Hi,

Hi,
In readRequest,i don't need to instanciate from GXDLMSClock :
item = GXDLMSObject(8, "0.0.1.0.0.255")
res=client.read(item,2)[0]
====> 7EA0190321326FD8E6E600C001C100080000010000FF0200601A7E it is Ok for me
Now when i want to WriteRequest without GXDLMSClock :

register = GXDLMSRegister("0.0.97.97.0.255")
register.value = 0xD0
res=client.write(register,2)[0]
????!!!!!!!!!!!!!!!!!!!!!!!!! this is my problem exactly

Hope to help me .
Thanks
SAhbi

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

You lost a lot of features If you create objects like this:
item = GXDLMSObject(8, "0.0.1.0.0.255")

Then you will have to parse values by yourself. That is possible with simple data types, but you will have a lot of work when you are handling complex objects. You also need to handle all write operations by yourself. I strongly propose that you shouldn't use base class.

You can create objects from the object type like this:

register = GXDLMSClient.createObject(ObjectType.REGISTER)
register.logicalName = "0.0.97.97.0.255"
register.value = 0xD0
res=client.write(register,2)

Now you can work it and all data types are handled automatically.

BR,
Mikko

sahbi said

4 years 8 months ago

Hi,

Hi,
effectively, i need to SimpleObjectRequest in the moment
I have this result :
File " ~\Gurux.DLMS.python\GXDLMSClient.py", line 869, in write
return self.__write(item.name, value, type_, item.objectType, index)
File "~\Gurux.DLMS.python\gurux_dlms\GXDLMSClient.py", line 880, in __write
raise Exception("Invalid parameter. In python value type must give.")
Exception: Invalid parameter. In python value type must give.

Thanks,
Sahbi

sahbi said

4 years 8 months ago

Hi ,

Hi ,
it is worked with :

register = GXDLMSClient.createObject(ObjectType.DATA)
register.logicalName = "0.0.97.97.0.255"
register.value = 0xD0
register.setDataType(2,DataType.UINT64)
res = client.write(register, 2)[0]

Result : 7EA022032198D85EE6E600C101C100010000616100FF02001500000000000000D0B3667E
Have you a comment to propose?

Thanks,
Sahbi

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

I'm afraid that this will cause problems when you try to write something more than plain integer values, structures, etc.

You must define the data type and it must be correct or the meter doesn't accept it.
The easiest way is if you read the data type from the meter and save it somewhere.
Then update it before write.

Something like:

register.logicalName = "0.0.97.97.0.255"
register.value = 0xD0
register.setDataType(2, DataType.UINT32)
res=client.write(register,2)

If the data type is wrong, the meter returns an error.

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