u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
79 stars 39 forks source link

Random characters #77

Closed huebrick closed 5 months ago

huebrick commented 5 months ago

Hey, I have a strange issue where im getting some characters that maybe shouldn't be there in the output of a get request.

Here is a part of a script table I have read from the meter:

[[1, [[1, 6, bytearray(b'\x00\x00\x0e\x00\x01\xff'), 4, bytearray(b'\x01')], 
[1, 6, bytearray(b'\x00\x00\x0e\x00\x02\xff'), 4, bytearray(b'\x01')], 
[1, 70, bytearray(b'\x00\x01`\x03\n\xff'), 3, 2]]], 

And here is part of the IDIS table on how it should look like:

  {1,{
          {1,6,0-0:14.0.1.255,4,*},
          {1,6,0-0:14.0.2.255,4,*},
          {2,70,0-1:96.3.10.255,[1..2],0}
        }
   },

Now all the values here are correct except the last OBIS code which has an "`" and "n" in it and has missing parts.

Krolken commented 5 months ago

Fear not 😄

It is just python representation of bytes. Check the values of a character in an ascii table and it will be clearer.

If you load the bytes into the Obis-class you can also see that it is correct. Obis codes are just sent as octet-string

Obis.from_bytes(bytearray(b'\x00\x00\x0e\x00\x01\xff')).to_string()
>>> '0-0:14.0.1.255'
Obis.from_bytes(bytearray(b'\x00\x00\x0e\x00\x02\xff')).to_string()
>>> '0-0:14.0.2.255'
Obis.from_bytes(bytearray(b'\x00\x01`\x03\n\xff')).to_string()
>>>'0-1:96.3.10.255'
huebrick commented 5 months ago

Hey, thanks :) Had a feeling that it was something dumb I was overlooking.