Hello,
I am having a problem when using pgAppMessage() between two applications.
The two attached examples (based on msgdemo) illustrate the problem:
- run recvMsg in an xterm
- run sendMsg in another xterm
msgSend creates 10 int messages numbered 0 to 9 and quickly sends them
to msgRecv.
When the sleep() call in msgRecv is removed, it correctly displays
the sequence 0..9 .
With the sleep(1), however, msgRecv displays on my machine:
[~/Development/Tests]> ./msgRecv
Received msg: 0
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 8
Received msg: 9
Essentially, messages are lost when the receiver is slow to process them.
Are APPMSG's not queued for the receiver?
Thanks for any help!
-Christian
--
Christian Grigis | SMARTDATA SA
Software Engineer | PSE-A / EPFL
Phone: +41-(21)-693-84-98 | CH - 1015 Lausanne
mailto:[EMAIL PROTECTED] | http://www.smartdata.ch
#include <picogui.h>
void sendMsg (int * msg)
{
pghandle peer;
int * dup;
peer = pgFindWidget ("TestReceiver");
if (!peer)
{
printf ("Can't find receiver\n");
exit (1);
}
dup = (int *) malloc (sizeof (int));
*dup = *msg;
pgAppMessage (peer, pgFromTempMemory (dup, sizeof (int)));
}
int main (int argc, char * argv [])
{
int msg;
pgInit (argc, argv);
pgRegisterApp (PG_APP_NORMAL, "Send", 0);
for (msg = 0; msg < 10; msg++)
{
sendMsg (&msg);
}
pgFlushRequests ();
return 0;
}
#include <picogui.h>
int evt_handler (struct pgEvent * evt)
{
int msg;
msg = * ((int *) evt->e.data.pointer);
printf ("Received msg: %d\n", msg);
sleep (1);
return 0;
}
int main (int argc, char * argv [])
{
pgInit (argc, argv);
pgRegisterApp (PG_APP_NORMAL, "Recv", 0);
pgSetWidget (PGDEFAULT,
PG_WP_NAME, pgNewString ("TestReceiver"),
0);
pgBind (PGDEFAULT, PG_WE_APPMSG, &evt_handler, NULL);
pgEventLoop ();
return 0;
}