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
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.
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
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
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
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:
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.
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.
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
Hi,
Hi,
Thanks for your response,
I need an example for setRequest Obis Code in python language .
Thanks,
SAID Sahbi
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
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
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
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
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
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
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
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
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