Hello Dear SO Community :)
I am trying to get DBus working on my Raspberry Pi. The example code from libdbus-c++-1 is working fine when i am in the Pi Desktop environment -> (startx)
My researches on the internet and the examples i found on stackoverflow didnt help me :[.
However, when i am in the Shell-Mode i get the error message
./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
i also tried
eval 'dbus-launch --auto-syntax' ./client
eval 'dbus-launch --auto-syntax' ./server
but it does not work, the server app is starting a message daemon but it is not reachable from the client. Also the daemon stays active.
i got:
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
also it does not shown in the services list.
after this i tried another command
DISPLAY=":0" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/dbus/system_bus_socket" ./server
and i got:
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
:( after that is also not working i found a way to compile the dbus without the X11 Code with
./configure --with-x=no
unfortunately it has no effect. Still require X11 to start my applications... What do i wrong?
but commands like
eval 'dbus-launch --auto-syntax' dbus-monitor
How can i start my applications without starting X11 i dont need it and i dont want it. Thank you for your help and time.
kindly regards oOm
#Update i feel a bit silly now but i found a way to run it without the x11
first you need to start a dbus session daemon
dbus-launch
this will prompt you your DBUS_SESSION_BUS_ADRESS
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357
DBUS_SESSION_BUS_PID=2465
after that you can launch your c++ application like this
DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357" ./server
you can registered services with
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
and monitoring the messages with
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6aT4DZgmA1,guid=b1231a014a7b10e74e04f8ba531abdf9 dbus-monitor
but one question is left, how can i do it automatically?