Search code examples
python-3.xdbus

how to decode dbus.Array fromat to hex or string in python


How to decode:

dbus.Array([dbus.Byte(1), dbus.Byte(35)], signature=dbus.Signature('y'))

to HEX or String in Python code.


Solution

  • Maybe what you want to do is to convert it to bytes; below you can see how I used to write it to a binary file.

        localFile = open ('/home/youruser/data.bin', 'wb')
        try:
            for byteValue in arrayValue:
                localFile.write(chr(byteValue))
        finally:
            localFile.close()