使用dbus-send设置/获取属性

问题描述 投票:1回答:2

我已经制作了以下示例xml,并在形成dbus-send命令以设置/获取propoerty“Status”时需要一些帮助。我知道如何调用方法,但不能使用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
2个回答
4
投票

您可以使用以下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属性的更多信息。


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.