Neutrino message passing & PtAppAddInput

Can anyone tell me how a make a Neutrino process establish a connection with
a Photon application such that the Photon application handles messages and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if it
can’t be done then PtAppAddInput might as well be removed from the library.

Jim Douglas

Hello Jim

Check out name_open, and name_attach in the helpviewer. Your Photon app does the name_attach and your other process does the name_open. This should allow you to find your Photon app.

Thanks
Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:

Thanks Markus,

There are a couple of examples that show how to set up the Photon side of
the equation which is not different from how it was in QNX4. The trouble is
they don’t show how the Neutrino process finds the Photon process and opens
a communications channel to it. In QNX4 it was simple, you just did a
‘qnx_name_locate’ and then ‘Send’ to the PID. With Photon 2+Neutrino life
isn’t so easy…

Jim

“Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
news:97dnka$sfl$> 1@inn.qnx.com> …
Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc, under
PtAppAddInput. Did you try this one? However, it uses message queues.
Markus

“Jim Douglas” <> jim@dramatec.co.uk> > wrote in message
news:97din3$pq9$> 1@inn.qnx.com> …
Can anyone tell me how a make a Neutrino process establish a connection
with
a Photon application such that the Photon application handles messages
and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Jim Douglas




\

Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc, under
PtAppAddInput. Did you try this one? However, it uses message queues.
Markus

“Jim Douglas” <jim@dramatec.co.uk> wrote in message
news:97din3$pq9$1@inn.qnx.com

Can anyone tell me how a make a Neutrino process establish a connection
with
a Photon application such that the Photon application handles messages and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if it
can’t be done then PtAppAddInput might as well be removed from the
library.

Jim Douglas

Jim Douglas <jim@dramatec.co.uk> wrote:

Can anyone tell me how a make a Neutrino process establish a connection with
a Photon application such that the Photon application handles messages and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

ConnectAttach()?

For pulses, check out PtAppCreatePulse() and PtPulseArm().

Assume that both processes are on the same node, and that all information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if it
can’t be done then PtAppAddInput might as well be removed from the library.

Not really. Even if you don’t find “raw” PtAppAddInput() useful, there
are a few other mechanisms in the library that use it.



\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Thanks Markus,

There are a couple of examples that show how to set up the Photon side of
the equation which is not different from how it was in QNX4. The trouble is
they don’t show how the Neutrino process finds the Photon process and opens
a communications channel to it. In QNX4 it was simple, you just did a
‘qnx_name_locate’ and then ‘Send’ to the PID. With Photon 2+Neutrino life
isn’t so easy…

Jim

“Markus Loffler” <loffler@ces.clemson.edu> wrote in message
news:97dnka$sfl$1@inn.qnx.com

Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc, under
PtAppAddInput. Did you try this one? However, it uses message queues.
Markus

“Jim Douglas” <> jim@dramatec.co.uk> > wrote in message
news:97din3$pq9$> 1@inn.qnx.com> …
Can anyone tell me how a make a Neutrino process establish a connection
with
a Photon application such that the Photon application handles messages
and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Jim Douglas

\

“Wojtek Lerch” <wojtek@qnx.com> wrote in message
news:97edcj$rjt$1@nntp.qnx.com

Jim Douglas <> jim@dramatec.co.uk> > wrote:
Can anyone tell me how a make a Neutrino process establish a connection
with
a Photon application such that the Photon application handles messages
and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

ConnectAttach()?

ConnectAttach() requires a CHID and I can’t see how to obtain it. I assume
PtAppAddInput attaches a channel, but where is the Id? If I explicitly
attach a channel then I would have to perfom a MsgReceive on it from a
separate thread. Either way I can’t win…

For pulses, check out PtAppCreatePulse() and PtPulseArm().

Are you categorically stating that Neutrino pulses and Photon Pulses are
exactly the same?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Not really. Even if you don’t find “raw” PtAppAddInput() useful, there
are a few other mechanisms in the library that use it.

Such as?


Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Jim Douglas

Rodney,

Sorry, I tried this and it does not appear to work. The Nto process can
locate the Ph process and send a message to it but it is not intercepted by
the PtAppAddInput handler. My guess is that it ends up in a queue (channel)
waiting for a MsgReceive. Do you have a working example? Or is it a case of
it should work but it’s broken?

Jim

<gui@qnx.com> wrote in message
news:Voyager.010226165708.1048612A@rdowdall…

Hello Jim

Check out name_open, and name_attach in the helpviewer. Your Photon app
does the name_attach and your other process does the name_open. This should

allow you to find your Photon app.

Thanks
Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:
Thanks Markus,

There are a couple of examples that show how to set up the Photon side
of
the equation which is not different from how it was in QNX4. The trouble
is
they don’t show how the Neutrino process finds the Photon process and
opens
a communications channel to it. In QNX4 it was simple, you just did a
‘qnx_name_locate’ and then ‘Send’ to the PID. With Photon 2+Neutrino
life
isn’t so easy…

Jim

“Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
news:97dnka$sfl$> 1@inn.qnx.com> …
Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc,
under
PtAppAddInput. Did you try this one? However, it uses message queues.
Markus

“Jim Douglas” <> jim@dramatec.co.uk> > wrote in message
news:97din3$pq9$> 1@inn.qnx.com> …
Can anyone tell me how a make a Neutrino process establish a
connection
with
a Photon application such that the Photon application handles
messages
and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and
if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Jim Douglas





\

Jim Douglas <jim@dramatec.co.uk> wrote:

“Wojtek Lerch” <> wojtek@qnx.com> > wrote in message
news:97edcj$rjt$> 1@nntp.qnx.com> …
Jim Douglas <> jim@dramatec.co.uk> > wrote:

ConnectAttach() requires a CHID and I can’t see how to obtain it. I assume
PtAppAddInput attaches a channel, but where is the Id? If I explicitly
attach a channel then I would have to perfom a MsgReceive on it from a
separate thread. Either way I can’t win…

PtChannelCreate() returns the CHID.

For pulses, check out PtAppCreatePulse() and PtPulseArm().

Are you categorically stating that Neutrino pulses and Photon Pulses are
exactly the same?

Photon pulses use (or, in a manner of speaking, are) Neutrino pulses.
How the Photon pulse “pid” maps to the Neutrino code and value is not
documented though.

In the next patch of the RTP, the Photon library will also let you use
your own hand-made pulses. Any pulse with the code in the “user” range
(_PULSE_CODE_MINAVAIL to _PULSE_CODE_MAXAVAIL) will be given to input
procs attached to pid 0.

I can’t find anything in the docs that tells me how to do this, and if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Not really. Even if you don’t find “raw” PtAppAddInput() useful, there
are a few other mechanisms in the library that use it.

Such as?

PtAppAddFd() (uses PtAppAddInput() and Photon pulses)
PtConnectorCreate() and friends (uses PtAppAddInput() and Photon pulses)
PtTty (uses PtAppAddFd())
PtClient/PtServer (use the PtConnectorCreate() stuff)
PtWebClient (uses PtClient)

pterm (uses a PtTty)
voyager (uses a PtWebClient)
helpviewer (uses a PtWebClient)


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Hello Jim

All you should have to do is the following

Server

name_attach_t *attach

attach = name_attach (NULL, “Some_Name”, 0);
PhChannelAttach (attach->chid, -1, NULL);
PtAppAddInput (NULL, 0, input_func, NULL);

int input_func (void *data, int rcvid, void *msg, size_t size)
{

// Only have to reply because Photon does the Receive for you
MsgReply (rcvid, reply_msg, …)
return (Pt_CONTINUE);
}


Client
coid = name_open (“Some_Name”, 0);

MsgSend (coid, &msg, sizeof (msg), NULL, 0);

That’s pretty much all you should have to do (Depending on what you are trying to do).

Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:

Rodney,

Sorry, I tried this and it does not appear to work. The Nto process can
locate the Ph process and send a message to it but it is not intercepted by
the PtAppAddInput handler. My guess is that it ends up in a queue (channel)
waiting for a MsgReceive. Do you have a working example? Or is it a case of
it should work but it’s broken?

Jim

gui@qnx.com> > wrote in message
news:Voyager.010226165708.1048612A@rdowdall…
Hello Jim

Check out name_open, and name_attach in the helpviewer. Your Photon app
does the name_attach and your other process does the name_open. This should
allow you to find your Photon app.

Thanks
Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:
Thanks Markus,

There are a couple of examples that show how to set up the Photon side
of
the equation which is not different from how it was in QNX4. The trouble
is
they don’t show how the Neutrino process finds the Photon process and
opens
a communications channel to it. In QNX4 it was simple, you just did a
‘qnx_name_locate’ and then ‘Send’ to the PID. With Photon 2+Neutrino
life
isn’t so easy…

Jim

“Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
news:97dnka$sfl$> 1@inn.qnx.com> …
Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc,
under
PtAppAddInput. Did you try this one? However, it uses message queues.
Markus

“Jim Douglas” <> jim@dramatec.co.uk> > wrote in message
news:97din3$pq9$> 1@inn.qnx.com> …
Can anyone tell me how a make a Neutrino process establish a
connection
with
a Photon application such that the Photon application handles
messages
and
(Neutrino) pulses using the callback attached with PtAppAddInput()?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this, and
if
it
can’t be done then PtAppAddInput might as well be removed from the
library.

Jim Douglas








\

Rodney,

I tried your suggestion and it almost works. The message gets through but
it’s garbage.

The call I had missed appears to be the PhChannelAttach() which hardly gets
mentioned in the docs. However if you do a full search on PhChannelAttach()
there are two warnings relating to the order in which you call it,
name_attach() and PtAppAddInput(). The warnings make no sense to me and you
appear to be violating them anyway:)

IMHO the major failing is the docs, but there may be some bugs. In order to
crack it we would have to exchange test programs which is not appropriate
via the newsgroups. Either I can deal with you direct or I will post a full
report via tech support (Darren Learmonth) in the UK. Let me know. My email
is jim@dramatec.co.uk

Jim Douglas

<gui@qnx.com> wrote in message news:Voyager.010228101249.581672A@rdowdall…

Hello Jim

All you should have to do is the following

Server

name_attach_t *attach

attach = name_attach (NULL, “Some_Name”, 0);
PhChannelAttach (attach->chid, -1, NULL);
PtAppAddInput (NULL, 0, input_func, NULL);

int input_func (void *data, int rcvid, void *msg, size_t size)
{

// Only have to reply because Photon does the Receive for you
MsgReply (rcvid, reply_msg, …)
return (Pt_CONTINUE);
}


Client
coid = name_open (“Some_Name”, 0);

MsgSend (coid, &msg, sizeof (msg), NULL, 0);

That’s pretty much all you should have to do (Depending on what you are
trying to do).

Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:
Rodney,

Sorry, I tried this and it does not appear to work. The Nto process can
locate the Ph process and send a message to it but it is not intercepted
by
the PtAppAddInput handler. My guess is that it ends up in a queue
(channel)
waiting for a MsgReceive. Do you have a working example? Or is it a case
of
it should work but it’s broken?

Jim

gui@qnx.com> > wrote in message
news:Voyager.010226165708.1048612A@rdowdall…
Hello Jim

Check out name_open, and name_attach in the helpviewer. Your Photon
app
does the name_attach and your other process does the name_open. This
should
allow you to find your Photon app.

Thanks
Rodney


Previously, Jim Douglas wrote in qdn.public.qnxrtp.photon:
Thanks Markus,

There are a couple of examples that show how to set up the Photon
side
of
the equation which is not different from how it was in QNX4. The
trouble
is
they don’t show how the Neutrino process finds the Photon process
and
opens
a communications channel to it. In QNX4 it was simple, you just did
a
‘qnx_name_locate’ and then ‘Send’ to the PID. With Photon 2+Neutrino
life
isn’t so easy…

Jim

“Markus Loffler” <> loffler@ces.clemson.edu> > wrote in message
news:97dnka$sfl$> 1@inn.qnx.com> …
Hi Jim,
I’ve never used PtAppAddInput, but there is an example in the doc,
under
PtAppAddInput. Did you try this one? However, it uses message
queues.
Markus

“Jim Douglas” <> jim@dramatec.co.uk> > wrote in message
news:97din3$pq9$> 1@inn.qnx.com> …
Can anyone tell me how a make a Neutrino process establish a
connection
with
a Photon application such that the Photon application handles
messages
and
(Neutrino) pulses using the callback attached with
PtAppAddInput()?

Assume that both processes are on the same node, and that all
information
needed to establish the connection e.g. name, pid, chid, can be
made
available to the Neutrino process when it starts running.

I can’t find anything in the docs that tells me how to do this,
and
if
it
can’t be done then PtAppAddInput might as well be removed from
the
library.

Jim Douglas









\

Jim Douglas <jim@dramatec.co.uk> wrote:

I tried your suggestion and it almost works. The message gets through but
it’s garbage.

The call I had missed appears to be the PhChannelAttach() which hardly gets
mentioned in the docs. However if you do a full search on PhChannelAttach()
there are two warnings relating to the order in which you call it,
name_attach() and PtAppAddInput(). The warnings make no sense to me and you
appear to be violating them anyway:)

You’re referring to the following, right?

PtAppAddInput() and name_attach() both try to create a channel with
_NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX
Neutrino Library Reference). If your application calls both
functions, you need to let Photon use the same channel as
name_attach() or create your own channel without these flags set.
In either case, you need to call PhChannelAttach() first, like this:

PhChannelAttach( chid, -1, NULL );

before calling name_attach() or PtAppAddInput().

You’re right it’s not quite accurate; it should only say that
PhChannelAttach() needs to be called before any calls to
PtAppAddInput(). Otherwise, PtAppAddInput() will attempt to create a
channel with default settings.

In other words:

If you want to tell Photon what channel to use, you must give it to
PhChannelAttach() before any calls to PtAppAddInput(). If you want
to use the channel created by name_attach(), you will obviously have
to call name_attach() before PhChannelAttach().

If, on the other hand, you want to create a separate channel for
Photon, it doesn’t matter whether you create it and give it to
PhChannelAttach() before or after calling name_attach(). But keep
in mind that since certain mechanisms in Photon library expect the
Photon channel to have the two DISCONNECT flags, they might not work
properly if it doesn’t. At present, the only such mechanism is the
detection of broken connections (see PtConnectionClientSetError()
and PtConnectionServerSetError()) and anything that relies on it.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.