我已经制作了以下示例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-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属性的更多信息。
dbus-send --system --print-reply --type = method_call --dest = org.ofono / gemalto_0 org.ofono.Modem.SetProperty string:“Powered”variant:boolean:false