How to decode:
dbus.Array([dbus.Byte(1), dbus.Byte(35)], signature=dbus.Signature('y'))
to HEX or String in Python code.
As the DBus specification says, y
means byte.
So dbus.Array([...], signature=dbus.Signature('y'))
is an array of bytes.
Let's consider this value:
value = dbus.Array([dbus.Byte(76), dbus.Byte(97), dbus.Byte(98), dbus.Byte(65), dbus.Byte(80), dbus.Byte(97), dbus.Byte(114), dbus.Byte(116)], signature=dbus.Signature('y'))
If you know your value contains a string:
print("value:%s" % ''.join([str(v) for v in value]))
# Will print 'value:LabAPart'
For an array of byte:
print("value:%s" % [bytes([v]) for v in value])
# Will print 'value:[b'L', b'a', b'b', b'A', b'P', b'a', b'r', b't']'
For an array of integer:
print("value:%s" % [int(v) for v in value])
# Will print 'value:[76, 97, 98, 65, 80, 97, 114, 116]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With