<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi all, I am in the process of considering using sd-bus to coordinate a system-wide multicast messaging system between daemons. At this time I only have resources to look into using libsystemd without system running. It seems the sd-bus
documentation is very sparse compared to sd-event – does this mean sd-bus is more immature?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My initial goal is to be able to select() on dbus-signals. Unfortunately my dbus experience is quite minimal, and I am not sure what this will take. Here is my initial attempt adapted from Lennarts tutorial – I have no idea if this is the
right approach I was hoping if this list could perhaps provide some guidance as I suspect I am doing a few things wrong.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">int main(int argc, char *argv[]) {<o:p></o:p></p>
<p class="MsoNormal"> sd_bus_slot *slot = NULL;<o:p></o:p></p>
<p class="MsoNormal"> sd_bus *bus = NULL;<o:p></o:p></p>
<p class="MsoNormal"> int r;<o:p></o:p></p>
<p class="MsoNormal"> int fd;<o:p></o:p></p>
<p class="MsoNormal"> fd_set rd_fdset;<o:p></o:p></p>
<p class="MsoNormal"> int my_user_data;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> /* Connect to the system bus this time */<o:p></o:p></p>
<p class="MsoNormal"> r = sd_bus_open_system(&bus);<o:p></o:p></p>
<p class="MsoNormal"> if (r < 0) {<o:p></o:p></p>
<p class="MsoNormal"> fprintf(stderr, "Failed to connect to bus: %s\n", strerror(-r));<o:p></o:p></p>
<p class="MsoNormal"> goto finish;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> r = sd_bus_request_name(bus, "Test.Me", 0);<o:p></o:p></p>
<p class="MsoNormal"> if (r < 0) {<o:p></o:p></p>
<p class="MsoNormal"> fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r));<o:p></o:p></p>
<p class="MsoNormal"> goto finish;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> r = sd_bus_add_match(<o:p></o:p></p>
<p class="MsoNormal"> bus,<o:p></o:p></p>
<p class="MsoNormal"> slot,<o:p></o:p></p>
<p class="MsoNormal"> "type='signal',"<o:p></o:p></p>
<p class="MsoNormal"> "sender='testsignal',"<o:p></o:p></p>
<p class="MsoNormal"> "interface='Japan.Reset',"<o:p></o:p></p>
<p class="MsoNormal"> "member='Test',"<o:p></o:p></p>
<p class="MsoNormal"> "path='/Japan'",<o:p></o:p></p>
<p class="MsoNormal"> my_signal_callback,<o:p></o:p></p>
<p class="MsoNormal"> my_user_data);<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> fd = sd_bus_get_fd(bus);<o:p></o:p></p>
<p class="MsoNormal"> if (fd < 0)<o:p></o:p></p>
<p class="MsoNormal"> assert(0);<o:p></o:p></p>
<p class="MsoNormal"> FD_ZERO(&rd_fdset);<o:p></o:p></p>
<p class="MsoNormal"> FD_SET(fd, &rd_fdset);<o:p></o:p></p>
<p class="MsoNormal"> for (;;) {<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:.5in">select(fd +1, &rd_fdset, NULL, NULL,NULL);<o:p></o:p></p>
<p class="MsoNormal"> r = sd_bus_process(bus, NULL);<o:p></o:p></p>
<p class="MsoNormal"> if (r < 0) {<o:p></o:p></p>
<p class="MsoNormal"> fprintf(stderr, "Failed to process bus: %s\n", strerror(-r));<o:p></o:p></p>
<p class="MsoNormal"> goto finish;<o:p></o:p></p>
<p class="MsoNormal"> }
<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">From here I was hoping to run something like “dbus-send –system –dest=Test.Me –print-reply /Japan Japan.Reset.Test string:”Hello””<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It currently get errors about DBUs complaining that Test.Me was not provided in any .service files when executing the above command. Any suggestion how to get around that issue would be helpful. My initial attempt at copying:<o:p></o:p></p>
<p class="MsoNormal"><a href="http://kkaempf.blogspot.com/2009/03/d-bus-service-on-demand.html">http://kkaempf.blogspot.com/2009/03/d-bus-service-on-demand.html</a> to create a ini file was was unsuccessful. It seems busctl cannot send signals?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Brian<o:p></o:p></p>
</div>
</body>
</html>