【问题标题】:set/get property using dbus-send使用 dbus-send 设置/获取属性
【发布时间】:2018-07-16 20:47:43
【问题描述】:

我制作了下面的示例 xml,需要一些帮助来形成 dbus-send 命令来设置/获取属性“状态”。我知道如何调用方法,但无法使用 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>

【问题讨论】:

    标签: dbus gdbus


    【解决方案1】:

    您可以使用以下 dbus-send 命令获取/设置 DBus 接口的 DBus 属性。将 $BUS_NAME 和 $OBJECT_PATH 替换为各自的名称。

    获取属性:

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

    设置属性:

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

    您可以阅读 DBus specification 以了解有关 DBus 属性的更多信息。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • OP 知道如何调用方法,但不知道如何获取/设置属性。
      猜你喜欢
      • 2017-06-15
      • 2014-09-02
      • 2015-02-28
      • 2011-04-11
      • 2013-12-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-10
      • 2019-02-19
      相关资源
      最近更新 更多