<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2>I'm trying to use dbus to send information from one
process to other, using low level C. The frecuency that this application send
signal is about 1200 per seconds, and each signal is a struct of 4 or 7 basic
datas (there are 2 different signals).</FONT></DIV>
<DIV><FONT face=Arial size=2>I think I'm writing signal correctly (at less I can
monitory them correctly from dbus-monitor utility), but when I'm reading it from
the other application, I have some loosing data (or not received signal)
randomly.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This is my receive method using C</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>void receive()<BR>{<BR> DBusMessage*
msg, *msgaux;<BR> DBusMessageIter args, item;<BR>
DBusConnection* conn;<BR> DBusError err;<BR> int
ret;<BR> unsigned short datox, datoy, datoz;<BR>
unsigned short datox2, datoy2, datoz2;<BR> unsigned int
time;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // initialise the
errors<BR> dbus_error_init(&err);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> conn = dbus_bus_get(DBUS_BUS_SYSTEM,
&err);<BR> if (dbus_error_is_set(&err))
{<BR> fprintf(stderr, "Connection Error (%s)\n",
err.message);<BR>
dbus_error_free(&err);<BR> }<BR> if (NULL == conn)
{<BR> exit(1);<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // add a rule for which messages we
want to see<BR> dbus_bus_add_match(conn,
"type='signal',interface='device.sensors.rawdata'", &err); // see signals
from the given interface<BR>
dbus_connection_flush(conn);<BR> if (dbus_error_is_set(&err))
{<BR> fprintf(stderr, "Match Error (%s)\n",
err.message);<BR> exit(1);<BR>
}<BR> printf("Match rule sent\n");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // loop listening for signals being
emmitted<BR> while (true)<BR>
{<BR> // non blocking read of the next available
message<BR> dbus_connection_read_write(conn,
-1);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> msgaux =
dbus_connection_pop_message(conn);<BR> while
(msgaux!= NULL)<BR> {<BR>
msg = msgaux;<BR> msgaux =
dbus_connection_pop_message(conn);<BR>
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // check if the
message is a signal from the correct interface and with the correct
name<BR> if (dbus_message_is_signal(msg,
"device.sensors.rawdata", "MGData"))<BR>
{<BR> // read the
parameters<BR> if
(!dbus_message_iter_init(msg,
&args))<BR>
fprintf(stderr, "Message Has No
Parameters\n");<BR>
else<BR> {<BR>
dbus_message_iter_recurse(&args, &item);<BR>
dbus_message_iter_get_basic(&item, &datox);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoy);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoz);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &time);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_next(&args);<BR> printf("\n\tMg: %d, %d,
%d, time: %d\n", datox, datoy, datoz,
time);<BR>
}<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> if (dbus_message_is_signal(msg,
"device.sensors.rawdata",
"ACData"))<BR> {<BR> // read the
parameters<BR> if (!dbus_message_iter_init(msg,
&args))<BR> fprintf(stderr, "Message Has No
Parameters\n");<BR> else<BR>
{<BR> dbus_message_iter_recurse(&args,
&item);<BR> dbus_message_iter_get_basic(&item,
&datox);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoy);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoz);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datox2);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoy2);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &datoz2);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_get_basic(&item, &time);<BR>
dbus_message_iter_next(&item);<BR>
dbus_message_iter_next(&args);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> printf("\n\tAce 1: %d, %d,
%d \tAce 2: %d, %d, %d, time: %d\n", datox, datoy, datoz, datox2, datoy2,
datoz2, time);<BR>
}<BR> }<BR> // free the
message<BR>
dbus_message_unref(msg);<BR> }<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>