RtTimerCreate question

my small example doesn’t work

why ?

//QNX 6.1 Rtp

// QCC timer.cpp -o timer -lph

//source code

#include <Pt.h>

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <photon/realtime/RtTimer.h>

RtTimer_t *ti;

int

rtn(RtTimer_t *timer,void *data) // routine doesn’t received never message

{

printf(“timer events!\n”);

return 0;

}

int

main(void)

{

struct itimerspec val = {0};

PtInit(NULL);

if (ti = RtTimerCreate(CLOCK_REALTIME,-1,&rtn,NULL))

{

val.it_value.tv_sec = 1;

val.it_interval.tv_sec = 1;

if (!RtTimerSetTime(ti,0,&val,NULL))

{

}


while (1) { usleep(10000); }

return 0;

}

rgb wrote:

my small example doesn’t work

why ?

If you are going to use Photon for timers (RtTimerCreate) then you must
use the Photon lib’s main loop (PtMainLoop()). The RtTimerCreate
function uses apulse that the photon main loop will get and call your
function. If you replace your while(1) with PtMainLoop() you will be fine.

Brian


//QNX 6.1 Rtp

// QCC timer.cpp -o timer -lph

//source code

#include <Pt.h

#include <stdio.h

#include <string.h

#include <stdlib.h

#include <photon/realtime/RtTimer.h

RtTimer_t *ti;

int

rtn(RtTimer_t *timer,void *data) // routine doesn’t received never message

{

printf(“timer events!\n”);

return 0;

}

int

main(void)

{

struct itimerspec val = {0};

PtInit(NULL);

if (ti = RtTimerCreate(CLOCK_REALTIME,-1,&rtn,NULL))

{

val.it_value.tv_sec = 1;

val.it_interval.tv_sec = 1;

if (!RtTimerSetTime(ti,0,&val,NULL))

{

}


while (1) { usleep(10000); }

return 0;

}

\

Brian Edmond (briane@qnx.com)
Software Development
QNX Sotware Systems Ltd.

i have miss this !
thanks,


“Brian Edmond” <briane@qnx.com> a écrit dans le message de news:
3C5EACB0.5050600@qnx.com

rgb wrote:

my small example doesn’t work

why ?



If you are going to use Photon for timers (RtTimerCreate) then you must
use the Photon lib’s main loop (PtMainLoop()). The RtTimerCreate
function uses apulse that the photon main loop will get and call your
function. If you replace your while(1) with PtMainLoop() you will be
fine.

Brian


//QNX 6.1 Rtp

// QCC timer.cpp -o timer -lph

//source code

#include <Pt.h

#include <stdio.h

#include <string.h

#include <stdlib.h

#include <photon/realtime/RtTimer.h

RtTimer_t *ti;

int

rtn(RtTimer_t *timer,void *data) // routine doesn’t received never
message

{

printf(“timer events!\n”);

return 0;

}

int

main(void)

{

struct itimerspec val = {0};

PtInit(NULL);

if (ti = RtTimerCreate(CLOCK_REALTIME,-1,&rtn,NULL))

{

val.it_value.tv_sec = 1;

val.it_interval.tv_sec = 1;

if (!RtTimerSetTime(ti,0,&val,NULL))

{

}


while (1) { usleep(10000); }

return 0;

}






\


Brian Edmond (> briane@qnx.com> )
Software Development
QNX Sotware Systems Ltd.