11

I have made below sample xml and need some help in forming dbus-send command to set/get propoerty "Status". I know how to call methods, but not able to read/write property using dbus-send.

xml:

<node>
    <interface name="com.pgaur.GDBUS">
        <method name="HelloWorld">
            <arg name="greeting" direction="in" type="s"/>
            <arg name="response" direction="out" type="s"/>
        </method>
        <signal name="Notification">
            <arg name="roll_number" type="i"/>
            <arg name="name" type="s"/>
        </signal>
        <property name="Status" type="u" access="readwrite"/>
    </interface>
</node>
Prashant Gaur
  • 135
  • 1
  • 1
  • 5

2 Answers2

21

You can Get/Set DBus properties for your DBus interface using below dbus-send commands. Replace $BUS_NAME and $OBJECT_PATH with respective names.

Get Property:

dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
org.freedesktop.DBus.Properties.Get string:com.pgaur.GDBUS string:Status

Set Property:

dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
 org.freedesktop.DBus.Properties.Set string:com.pgaur.GDBUS string:Status variant:uint32:10

You can read DBus specification to know more about DBus Properties.

Ravi
  • 986
  • 12
  • 18
  • How am I supposed to know what values to use for $BUS_NAME and $OBJECT_PATH? If I use `org.freedesktop.DBus` and `/` (as I use for other dbus-send commands which work), I get > Error org.freedesktop.DBus.Error.UnknownInterface: org.freedesktop.DBus does not understand message Get – earboxer May 27 '23 at 12:07
-2

dbus-send --system --print-reply --type=method_call --dest=org.ofono /gemalto_0 org.ofono.Modem.SetProperty string:"Powered" variant:boolean:false

chetanya gehlot
  • 564
  • 4
  • 11