PtSetResource newb question

Hi,
Im trying to use PtSetResource to modify widget properties and its working fine. As soon as I use any PtSetResource within my timer activate callback, i get a Memory Fault (core dumped) error. I dont understand this, because the call to ptsetresource is working fine in other callbacks, such as the click of a button.

Any help would be great!!!

You might want to post some code, see if we can spot a problem.

yep, good point.
I have a function changelights, where the ptsetresource statements are. The function updategui, is called by the PtTimer callback activate.

void changelights(int xlight, int xcolour)
{
switch (xlight)
{
case 1:
//Ped light
switch (xcolour)
{
case 0: //red
PtSetResource(ABW_PedPGreen, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
PtSetResource(ABW_PedPRed, Pt_ARG_INSIDE_COLOR, Pg_RED, 0 );
break;
case 1: //green
PtSetResource(ABW_PedPGreen, Pt_ARG_INSIDE_COLOR, Pg_GREEN, 0 );
PtSetResource(ABW_PedPRed, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
break;
case 2: //amber
PtSetResource(ABW_PedPGreen, Pt_ARG_INSIDE_COLOR, Pg_YELLOW, 0 );
PtSetResource(ABW_PedPRed, Pt_ARG_INSIDE_COLOR, Pg_YELLOW, 0 );
break;
}
break;

case 2:
//Traffic light
switch (xcolour)
{
	case 0: //red
	PtSetResource(ABW_PedTGreen, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	PtSetResource(ABW_PedTRed, Pt_ARG_INSIDE_COLOR, Pg_RED, 0 );
	PtSetResource(ABW_PedTYellow, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	break;
	case 1: //green 
	PtSetResource(ABW_PedTGreen, Pt_ARG_INSIDE_COLOR, Pg_GREEN, 0 );
	PtSetResource(ABW_PedTRed, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	PtSetResource(ABW_PedTYellow, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	break;
	case 2: //amber
	PtSetResource(ABW_PedTGreen, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	PtSetResource(ABW_PedTRed, Pt_ARG_INSIDE_COLOR, Pg_BLACK, 0 );
	PtSetResource(ABW_PedTYellow, Pt_ARG_INSIDE_COLOR, Pg_YELLOW, 0 );
	break;
}
break;

}
}

int UpdateGUI( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )

{
changelights(1,1);
changelights(2,0);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}

hmm,

your code seems to be fine, tried it, no prob. (UpdateGUI as activateCB on a Timer, initial and repeat 1 msec)

Perhaps you try to set the color to early (i.e. when the widgets haven’t been realized yet). You could try to set a bigger value for Pt_ARG_TIMER_INITIAL.

If that doesn’t help, try if the timer callback itself works (just do a printf and check if you can see its output)…