Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - message from driver to app: (4 Items)
   
message from driver to app  
I am trying to send a message from my driver to my app using MsgSendPulse.

So I listen for message in my app:

	int chid = ChannelCreate(0);
	coid = ConnectAttach(0 , 0, chid, _NTO_SIDE_CHANNEL, 0);

	for (;;) {
		printf("waiting for pulse: chid = %x\, coid = %x\n", chid, coid);

		rcvid = MsgReceivePulse( chid, &pulse, sizeof (pulse),  NULL );
		printf("rcvid = %x\n", rcvid);

        }


And send pulse message from my driver:

		log_error(1,coid = %x\n", my_interrupt_info.coid);


		IntDebug3 = MsgSendPulse (my_interrupt_info.coid, 10, my_interrupt_info.level, my_interrupt_info.statusid);

I confirm that coid is the same value (passed to driver from app), and MsgSendPulse return 0. However, my app never seem
 to receive the pulse (the 2nd printf statement never print). What did I do wrong ?

Any help will be appreciated.

Thanks !!!

hung

Re: message from driver to app  
This won't work like this if the app and the driver are separate processes. The ConnectAttach() has to be done in the 
driver. To do that the driver needs at least the pid (process id) of the app and the chid from the app. That should then
 work.

But a cleaner way of doing this that's been provided for this purpose is for the app to fill a struct sigevent structure
 with a pulse and send that event structure to the driver in a message. The driver would then do MsgDeliverEvent() 
whenever it wanted to wake up the app. Since the app had put a pulse in the event structure, the MsgDeliverEvent() will 
result in a pulse being sent to the app.

See "Using MsgDeliverEvent() to send a pulse" here:
http://www.qnx.com/developers/articles/article_870_1.html

However, I see your driver is sending  my_interrupt_info.level and my_interrupt_info.statusid in the pulse. That won't 
work with the event method because the driver is 'not supposed' to know what's in the event, or to modify it. So use the
 event method only if the level and statusid info is unnecessary. Alternatively, when the app receives the pulse it can 
send a message to the driver asking for this info.

-Steven D.
Re: message from driver to app  
Thanks, Steven. I followed your advice and call ConnectAttach() in the driver. It works.

Thanks again for responding,

hung
Re: message from driver to app  
You're welcome, Hung.
-Steven D.