Hi,
I have problem with changing value of object, which has 'bytearray' - as I could see after reading that OBIS. For changing "normal" values, such as APN, I use the following python snippet:
d = GXDLMSData("obis")
d.apn = "newAPN"
self.write(d, 2)
And it works fine, but there's also manufacturer's specific object - pinging setup, which consists of target IP and interval. First one is bytearray, second is integer. After reading this object it looks like below:
-------- Reading 1 0.0.131.6.0.255 Manufacturer specific
Attribute: 1 Value: 0.0.131.6.0.255
Attribute: 2 Value: bytearray(b''), 0
Or, if it is enabled:
Attribute: 2 Value: bytearray(b'8.8.8.8'), 60
But when I use:
d = GXDLMSData("0.0.131.6.0.255")
d.value = bytearray(b"8.8.8.8"), 60
self.write(d, 2)
then I have error: Exception: Invalid parameter. In python value type must give.
Any ideas how to solve that problem?
Hi, I believe that you need…
Hi,
I believe that you need to write a structure. You can do it like this:
s = GXStructure()
s.append(bytearray(b"8.8.8.8"))
s.append(GXUInt8(60))
BR,
Mikko
I did as suggested: self…
I did as suggested:
self.newObisValue = GXStructure()
self.newObisValue.append(bytearray(b"8.8.8.8"))
self.newObisValue.append(GXUInt16(60))
in GXDLMSReader.py:
d = GXDLMSData("0.0.131.6.0.255")
d.value = newValue #(self.newObisValue from previous)
So using write() it was writing it:
[bytearray(b'8.8.8.8'), 60]
Still, it gave error: Exception: Invalid parameter. In python value type must give.
Specifically, from write() function:
File "C:\Users\x\Desktop\GURUX\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 316, in write
data = self.client.write(item, attributeIndex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1082, in write
return self.__write(item.name, value, type_, item.objectType, index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1093, in __write
raise Exception("Invalid parameter. In python value type must give.")
If you'd need more information: I was able to read this obis from GXDLMSDirector app:
<Structure>
<OctetString Value="382E382E382E38" />
<UInt16 Value="001E" />
</Structure>
And from xml:
<WRAPPER len="1B" >
<SourceAddress Value="1" />
<TargetAddress Value="1" />
<PDU>
<SetRequest>
<SetRequestNormal>
<!-- Priority: Normal, ServiceClass: Confirmed, Invoke ID: 1 -->
<InvokeIdAndPriority Value="41" />
<AttributeDescriptor>
<!-- Data -->
<ClassId Value="0001" />
<!-- 0.0.131.6.0.255 -->
<InstanceId Value="0000830600FF" />
<!-- Value -->
<AttributeId Value="02" />
</AttributeDescriptor>
<Value>
<Structure Qty="02" >
<!-- 8.8.8.8 -->
<OctetString Value="382E382E382E38" />
<UInt16 Value="001E" />
</Structure>
</Value>
</SetRequestNormal>
</SetRequest>
</PDU>
</WRAPPER>
Hi, You need also set the…
Hi,
You need also set the data type like this:
d = GXDLMSData("0.0.131.6.0.255")
d.setDataType(2, DataType.STRUCTURE)
BR,
Mikko
That did work, many thanks!
That did work, many thanks!