问题描述
我创建了一个守护进程。守护程序提供了一个dbus接口,其方法之一具有诸如(uu)
这样的签名-这是两个 uint32
字段。
I've created a daemon. The daemon provides a dbus interface, with one of its methods having a signature like this (uu)
-- that is a struct of two uint32
fields.
有没有现成的工具可供我调用方法,传递结构? dbus发送
和 d-feet
似乎没有帮助。
Is there a ready-to-use tool for me to invoke the method, to pass the struct in? dbus-send
and d-feet
doesn't seem to help.
任何指针吗?
推荐答案
gdbus
应该招。尝试执行以下操作:
gdbus
should do the trick. Try the equivalent of:
gdbus call --session --dest com.example.MyTest --object-path /com/example/MyTest --method com.example.MyTest.Test "(1,2)"
。 ..具有适合您情况的正确参数。
... with the correct parameters for your situation of course.
我已经使用Python D-Bus服务测试了上面的调用,如下所示:
I've tested the call above using a Python D-Bus service like this:
import gobject
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
OPATH = "/com/example/MyTest"
IFACE = "com.example.MyTest"
BUS_NAME = "com.example.MyTest"
class Example(dbus.service.Object):
def __init__(self):
bus = dbus.SessionBus()
bus.request_name(BUS_NAME)
bus_name = dbus.service.BusName(BUS_NAME, bus=bus)
dbus.service.Object.__init__(self, bus_name, OPATH)
@dbus.service.method(dbus_interface=IFACE,
in_signature="(uu)", out_signature="")
def Test(self, payload):
print "Got this from client:", payload
if __name__ == "__main__":
service = Example()
loop = gobject.MainLoop()
loop.run()
在Ubuntu 15.10计算机上,我在 gdbus
上由<$ c $提供c> libglib2.0-bin 软件包:
On the Ubuntu 15.10 machine I'm on gdbus
is provided by the libglib2.0-bin
package:
$ dpkg -L libglib2.0-bin | grep gdbus
/usr/bin/gdbus
/usr/share/bash-completion/completions/gdbus
/usr/share/man/man1/gdbus.1.gz
希望这会有所帮助。
这篇关于将结构传递给dbus方法的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!