my program crash with the following
Process 626702 (brakeNiNo_NB1207405500342) terminated SIGSEGV code=1 fltno=11 ip=0117e154 mapaddr=00101154. ref=00000014
while a try to change the labe contain.
I am a noob with QNX and this is my first try. Had been look at these error for a long time… hope some one can help me out here.
Thanks!!
The code are:
/* Y o u r D e s c r i p t i o n */
/* AppBuilder Photon Code Lib */
/* Version 2.03 */
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <sys/wait.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
#define action1 "Brake - Moderate Braking."
#define action2 "Brake - Fully Engage."
#define action3 "Brake - No Braking"
#define action4 "Accelerator - Disable."
#define action5 "Accelerator - User Control."
#define action6 "System error!!!."
extern int thread_ID;
double d[22];// = {2.0,1.9,1.8,1.7,1.6,1.5,1.4;
double s[22];
char cd[10];
char cs[10];
char note[40];
char uc;
char rm;
int i,p,j;
void* function( void* arg )
{
//printf( "This is thread %d\n", pthread_self() );
d[0] = 2.0;
s[0] = 12.0;
d[1] = 1.9;
s[1] = 11.0;
d[2] = 1.8;
s[2] = 10.5;
d[3] = 1.7;
s[3] = 10.0;
d[4] = 1.6;
s[4] = 9.9;
d[5] = 1.5;
s[5] = 9.8;
d[6] = 0.8;
s[6] = 9.7;
d[7] = 0.5;
s[7] = 8.9;
d[8] = 0.5;
s[8] = 8.8;
d[9] = 0.5;
s[9] = 8.8;
d[10] = 0.6;
s[10] = 8.7;
d[11] = 0.6;;
s[11] = 8.6;;
d[12] = 0.5;
s[12] = 8.5;
d[13] = 0.5;
s[13] = 8.4;
d[14] = 0.4;
s[14] = 9.2;
d[15] = 0.3;
s[15] = 8.0;
d[16] = 0.3;
s[16] = 8.0;
d[17] = 0.3;
s[17] = 7.0;
d[18] = 0.2;
s[18] = 6.0;
d[19] = 0.1;
s[19] = 5.0;
d[20] = 0.0;
s[20] = 0.0;
d[21] = 0.0;
s[21] = 0.0;
for (i=0;i<20;i++){
sprintf(cs, "%2.1f",s[i]);
sprintf(cd, "%2.1f",d[i]);
///PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
//PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
if (d[i]>=1.0 && s[i]>=10.0)
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action1, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action4, 0);
}
else if(d[i]>1.0 && s[i]<10.0)
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action3, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action5, 0);
}
else if(d[i]>= 0.5 && d[i]<= 1.0)
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action1, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action4, 0);
}
else if(d[i] > 0.2 && d[i]< 0.5)
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action2, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action4, 0);
}
else if(d[i] < 0.2)
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action2, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action4, 0);
}
else
{
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
PtSetResource( ABW_Ptlbl_N1, Pt_ARG_TEXT_STRING,action6, 0);
PtSetResource( ABW_Ptlbl_N2, Pt_ARG_TEXT_STRING,action6, 0);
}*/
//delay(20);
//for ( p=0; p<200000; p++){
//for( j=0; j<200; j++){}
//}
//sleep(1);
//for ( p=0; p<1000; p++){}
/*for (j=0; p<10; p++){
cs[i] = NULL;
cd[i]=NULL;
}
//cs="";
//cd="";
}
while(1){}
return( 0 );
}
int
toggle( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
////printf("This is a test msg \n");
//PtSetResource( ABW_PtLabel1, Pt_ARG_TEXT_STRING,"1.00", 0);
pthread_create(&thread_ID, NULL, &function, NULL);
//while(1);
return( Pt_CONTINUE );
}