【发布时间】:2014-04-16 06:52:50
【问题描述】:
尊敬的 SO 社区您好 :)
我正在尝试让 DBus 在我的 Raspberry Pi 上运行。 当我在 Pi 桌面环境中时,来自 libdbus-c++-1 的示例代码运行良好 -> (startx)
我在互联网上的研究以及我在 stackoverflow 上找到的示例对我没有帮助:[.
但是,当我处于 Shell 模式时,我会收到错误消息
./client
terminate called after throwing an instance of 'DBus::Error'
what(): /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
Aborted
我也试过了
eval 'dbus-launch --auto-syntax' ./client
eval 'dbus-launch --auto-syntax' ./server
但它不起作用,服务器应用程序正在启动消息守护程序,但无法从客户端访问。守护进程也保持活动状态。
我明白了:
terminate called after throwing an instance of 'DBus::Error'
what(): The name org.freedesktop.DBus.Examples.Echo was not provided by any .service files
call1: Aborted
它也没有显示在服务列表中。
在此之后我尝试了另一个命令
DISPLAY=":0" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/dbus/system_bus_socket" ./server
我得到了:
terminate called after throwing an instance of 'DBus::Error'
what(): Connection ":1.10" is not allowed to own the service "org.freedesktop.DBus.Examples.Echo" due to security policies in the configuration file
Aborted
:( 之后也无法正常工作,我找到了一种无需 X11 代码即可编译 dbus 的方法 与
./configure --with-x=no
不幸的是,它没有效果。仍然需要 X11 来启动我的应用程序... 我怎么了?
但是类似的命令
eval 'dbus-launch --auto-syntax' dbus-monitor
如何在不启动 X11 的情况下启动我的应用程序,我不需要它,我也不想要它。 感谢您的帮助和时间。
亲切的问候 呜呜
#更新 我现在觉得有点傻,但我找到了一种不用 x11 来运行它的方法
首先你需要启动一个 dbus 会话守护进程
dbus-launch
这将提示您您的 DBUS_SESSION_BUS_ADRESS
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357
DBUS_SESSION_BUS_PID=2465
之后,您可以像这样启动您的 c++ 应用程序
DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357" ./server
你可以注册服务
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6aT4DZgmA1,guid=b1231a014a7b10e74e04f8ba531abdf9 dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
和监控消息
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6aT4DZgmA1,guid=b1231a014a7b10e74e04f8ba531abdf9 dbus-monitor
还有一个问题,如何自动完成?
【问题讨论】:
-
抱歉,帖子太长了:)
-
你好,Dogan,我在你的页面上结束了,因为我在树莓派上遇到了类似的问题。在树莓派上找不到 dbus-launch 命令,我有一个没有 X 服务器的 pi 无头安装。如何获取 dbus-launch 包??
标签: linux shell x11 dbus raspbian