I had created a Photon program without PhAB and add a extra message handler
with PtAppAddInput , my question is how to send message to the Photon from
other process . I don’t know how to do it because I do not know the channel
Id of the Photon…
waity <waity@hongkong.com> wrote:
I had created a Photon program without PhAB and add a extra message handler
with PtAppAddInput , my question is how to send message to the Photon from
other process . I don’t know how to do it because I do not know the channel
Id of the Photon…
Attach a name using name_attach(), and then let the photon
library know that you want it to watch the resulting channel via
PhChannelAttach().
Here’s a snippet of code for the program that does the name
attach:
************* begins *************************
/*-----------------------------------------------------------
*
- init - Application initialization function.
---------------------------------------------------------/
int
init( int argc, char argv[] )
{
/
- attach a name so that other processes can find us
/
if( (attach = name_attach( NULL, “GUIapp”, 0 ))
== NULL )
{
perror( “failed name_attach()” );
exit( EXIT_FAILURE );
}
/ - let the Photon library know that it’s supposed to watch
- the channel associated with the name we’ve attached
/
PhChannelAttach( attach->chid, -1, NULL );
/ - set up the input function so that it will be called whenever
- a message is received that is not for Photon; note the “0”
- as second parameter – we want to be called in response to
- messages from any process at all
/
PtAppAddInput( NULL, 0, inputFunction, NULL );
/ eliminate ‘unreferenced’ warnings */
argc = argc, argv = argv;
return( Pt_CONTINUE );
}
************** ends **************************
Here’s what the other side does:
************* begins *************************
coid_to_GUIapp = name_open( “GUIapp”, 0 );
************** ends **************************
I hope this helps.
Norbert Black
QSSL Training Services
I will try it!Thank you very much!
“Norbert Black” <nblack@qnx.com> ¼¶¼g©ó¶l¥ó
news:9k931s$flo$1@nntp.qnx.com…
waity <> waity@hongkong.com> > wrote:
I had created a Photon program without PhAB and add a extra message
handler
with PtAppAddInput , my question is how to send message to the Photon
from
other process . I don’t know how to do it because I do not know the
channel
Id of the Photon…
Attach a name using name_attach(), and then let the photon
library know that you want it to watch the resulting channel via
PhChannelAttach().
Here’s a snippet of code for the program that does the name
attach:************* begins *************************
/*-----------------------------------------------------------
*
- init - Application initialization function.
---------------------------------------------------------/
int
init( int argc, char argv[] )
{
/
- attach a name so that other processes can find us
/
if( (attach = name_attach( NULL, “GUIapp”, 0 ))
== NULL )
{
perror( “failed name_attach()” );
exit( EXIT_FAILURE );
}
/- let the Photon library know that it’s supposed to watch
- the channel associated with the name we’ve attached
/
PhChannelAttach( attach->chid, -1, NULL );
/- set up the input function so that it will be called whenever
- a message is received that is not for Photon; note the “0”
- as second parameter – we want to be called in response to
- messages from any process at all
/
PtAppAddInput( NULL, 0, inputFunction, NULL );
/ eliminate ‘unreferenced’ warnings */
argc = argc, argv = argv;return( Pt_CONTINUE );
}************** ends **************************
Here’s what the other side does:
************* begins *************************
coid_to_GUIapp = name_open( “GUIapp”, 0 );
************** ends **************************
I hope this helps.
Norbert Black
QSSL Training Services