Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - PtSetArg & char: (3 Items)
   
PtSetArg & char  
Hi How Can I display one byte variable type char in PtText ? 

char pgmData; 

printf("pgmData = %d %d %d %d",pgmDatap[0],pgmDatap[1],pgmDatap[2],pgmDatap[3]); 

display in console: pgmData = 0 1 0 1 ; // and it is correct 
and now how can I set one byte in PtText ? 

PtSetArg(&arg[0],Pt_ARG_TEXT_STRING,pgmData[0],0); //doesn;t work :/ 
PtSetResources(pole,1,arg);
Re: PtSetArg & char  
Hi,

use sprintf():

char pgmData, buf[50]; 
sprintf( buf, "pgmData = %d %d %d %d", pgmDatap[0], pgmDatap[1],
           pgmDatap[2], pgmDatap[3] ); 
PtSetResource( pole, Pt_ARG_TEXT_STRING, buf, 0 );

- Thomas
Re: PtSetArg & char  
Thanks you for your reply.
Ok it's work but not quite. 

I create thread with function which change value(bytes) pgmData for 1 second. 
pgmData value = 1000
next                  = 0100
next                  = 0010
and so on ...

And i write my function which should display current value: 

void *displayValue(void *arg){
args[0];
char buf[50];

while(true){
  PtSet(&args[0],Pt_ARG_TEXT_STRING,buf,0);
  PtSetResources(pole,1,args);
 sleep(1);

}
}

pthread_create(NULL,NULL,displayValue);

It works but set only one values and next i get error "Memory fault (core dumped)"
What is wrong ? . I should run "displayValue" in new thread or maybe invoke in "main" ??