<html 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 name=Title content=""><meta name=Keywords content=""><meta http-equiv=Content-Type content="text/html; charset=utf-8"><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:12.0pt;
font-family:Calibri;}
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;
color:windowtext;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:Calibri;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body bgcolor=white lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt'>Hello!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>I have been playing around and writing my own DBus bindings for IPC using C++ to communicate using DBus signals to mimic “socket like” communications on top of the libdbus C API.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>This is the situation I am running into that I would like to see if there is some rules or exceptions I can use to work around some functionality:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>1. I have 2 processes attached to a session bus named “test.echo” on an object / interface named “pingpong” with a signal called “pingpong”.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>2. Each process can read and write to that signal to act as a pipe.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>3. Using synchronous reading and writing, process 2 reads the data and echo’s the data back for a ping pong demo.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>4. After process 1 sends data, process 2 then reads the data and echo’s it back, in which process 1 waits to read the data.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Eventually, I would like to attach multiple processes to the same signal for broadcasting.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Here is some sudo code<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt'>Process 1:</span></b><span style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> writeSignalData(“pingpong”)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> print(“Wrote pingpong”)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> while (true) {<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> message = readSignalData()<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> if (message.size()) {<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> print(“Echo received:” + message)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt'>Process 2:</span></b><span style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> while (true) {<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> message = readSignalData()<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> if (message.size()) {<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> print(“Echoing: “ + message)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> writeSignalData(message)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>The problem that I am running into is that in the echoing process 2 is receiving its own signal after process 2 calls “writeSignalData()” since it is also technically subscribed to the signal…<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>For example, the output of the sudo code would be:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 1 – Wrote pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 1 – Echo received: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>Process 2 – Echoing: pingpong<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>…<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>One way I can think of getting around this is to add a randomly generated serial (the serial functionality in a libdbus message) to each message sent and keep an internal list of ignored serials after echoing. If the serial from the message received is a part of the blacklisted serials, then pop the message, ignore it, and move on.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>I didn’t know if there was a better way to do this using rules, or possibly using two signals for bi-directional communications so that I don’t get my own sent data. I found very little for examples on the net for this way of using DBus.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>I know I may not be using the DBus the way it was intended… I just like the fact that all of the TCP packet parsing is already done and grouped, also the fact that it is typed data transactions.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;color:black'>Derrill Vezina, PE<br><a href="mailto:vezinadj@gmail.com"><span style='color:#0563C1'>vezinadj@gmail.com</span></a><br>207-251-9072</span><o:p></o:p></p></div></body></html>