PhEventEmit: No such process

I am writing an application that is using the PhEventEmit function. But the
function always returns with -1 and sets errno to ESRCH: No such process.
I use QNX 4.25 with Photon 1.13.

Trying to run the simple example from the documentation has the same effect.

----- BEGIN EXAMPLE

The following example emits an expose event from the device region. Because
the event will cover the entire event space, any visible part of the event
space will be refreshed:

#include <stdio.h>
#include <time.h>
#include <Ph.h>

main( int argc, char *argv[] )
{
PhEvent_t event;
PhRect_t rect;

if( NULL == PhAttach( NULL, NULL ) ) {
fprintf( stderr,
“Couldn’t attach Photon channel.\n”);
exit( EXIT_FAILURE );
}
event.type = Ph_EV_EXPOSE;
event.subtype = 0;
event.flags = 0;
event.num_rects = 1;
event.data_len = 0;
rect.ul.x = rect.ul.y = SHRT_MIN;
rect.lr.x = rect.lr.y = SHRT_MAX;
PhEventEmit( &event, &rect, NULL );
}
----- END EXAMPLE

Thanks.

Martin

Hello Vlastislav

Your just missing a couple of pieces to the puzzle that should have
been added to the example in the docs. See below.


Vlastislav sebesta <elsys@sky.cz> wrote:

I am writing an application that is using the PhEventEmit function. But the
function always returns with -1 and sets errno to ESRCH: No such process.
I use QNX 4.25 with Photon 1.13.

Trying to run the simple example from the documentation has the same effect.

----- BEGIN EXAMPLE

The following example emits an expose event from the device region. Because
the event will cover the entire event space, any visible part of the event
space will be refreshed:

#include <stdio.h
#include <time.h
#include <Ph.h

main( int argc, char *argv[] )
{
PhEvent_t event;

This should be

PhEvent_t event = { 0 };

This will make sure thet the event strucutre doesn’t contain any garbage when
you go to use it.

PhRect_t rect;

if( NULL == PhAttach( NULL, NULL ) ) {
fprintf( stderr,
“Couldn’t attach Photon channel.\n”);
exit( EXIT_FAILURE );
}

You should add a line
event.emitter.rid = Ph_DEV_RID;
so that the serever knows where the event is supposed to be emitted from.

Thanks
Rodney

event.type = Ph_EV_EXPOSE;
event.subtype = 0;
event.flags = 0;
event.num_rects = 1;
event.data_len = 0;
rect.ul.x = rect.ul.y = SHRT_MIN;
rect.lr.x = rect.lr.y = SHRT_MAX;
PhEventEmit( &event, &rect, NULL );
}
----- END EXAMPLE

Thanks.

Martin