Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to print a buffer into a multitext using PtSetResource: (6 Items)
   
How to print a buffer into a multitext using PtSetResource  
hi guys..im working on PhAB, what im trying to do is put messages from an udp socket.. so i created a thread to send the
 messages but still dont know how to put the buffer into a multitext.. what ive been trying to do is.. for example

char buffer[100] = "Hello World";

PtSetResource(ABW_Multitext1, Pt_ARG_TEXT_STRING, buffer, 0);

this is a fragment of an arm callback of a botton

so help me if u can .. thanks

AW: How to print a buffer into a multitext using PtSetResource  
Hi Jorge,

your code snippet below looks just fine to me...

Does it compile correctly?
Are you sure your PtButton's arm callback is invoked?
Is your PtMultitext actually named "Multitext1" ?

Maybe you can zip up a small test app and post it here?

- Thomas

> -----Ursprungliche Nachricht-----
> Von: Jorge Inostroza [mailto:community-noreply@qnx.com]
> Gesendet: 12 September 2008 16:09
> An: momentics-community
> Betreff: How to print a buffer into a multitext using PtSetResource
> 
> 
> hi guys..im working on PhAB, what im trying to do is put 
> messages from an udp socket.. so i created a thread to send 
> the messages but still dont know how to put the buffer into a 
> multitext.. what ive been trying to do is.. for example
> 
> char buffer[100] = "Hello World";
> 
> PtSetResource(ABW_Multitext1, Pt_ARG_TEXT_STRING, buffer, 0);
> 
> this is a fragment of an arm callback of a botton
> 
> so help me if u can .. thanks
> 
> 
> 
> _______________________________________________
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post13332
> 
> 
Re: AW: How to print a buffer into a multitext using PtSetResource  
Hi Thomas... yeah my mistake was in the instance of the multitext, the name was wrong.. so i change it and it works.. 
thanks man... now im trying to sent a buffer wich is a thread, but i have synchronizim problems with the loop of the 
graphic interface... maybe ill post the code if anyone could help me.. thanks
Re: AW: How to print a buffer into a multitext using PtSetResource  
> Hi Thomas... yeah my mistake was in the instance of the multitext, the name 
> was wrong.. so i change it and it works.. thanks man... now im trying to sent 
> a buffer wich is a thread, but i have synchronizim problems with the loop of 
> the graphic interface... maybe ill post the code if anyone could help me.. 
> thanks


Unless you want to get fancy with queues and all that, there is need to create a thread to send a udp packet.

Re: AW: How to print a buffer into a multitext using PtSetResource  
> > Hi Thomas... yeah my mistake was in the instance of the multitext, the name 
> 
> > was wrong.. so i change it and it works.. thanks man... now im trying to 
> sent 
> > a buffer wich is a thread, but i have synchronizim problems with the loop of
>  
> > the graphic interface... maybe ill post the code if anyone could help me.. 
> > thanks
> 
> 
> Unless you want to get fancy with queues and all that, there is need to create
>  a thread to send a udp packet.

Sorry just realized you were receving, but unless your photon app is doing long operation with io_nofity you could 
receive the UDP stuff in your main application.

> 


Re: AW: How to print a buffer into a multitext using PtSetResource  
>>
> Sorry just realized you were receving, but unless your photon app is doing 
> long operation with io_nofity you could receive the UDP stuff in your main 
> application.
> 
> > 
yeah im receiving data, my code inside the abmain here

/*********************************************************************************************/	

	if (pthread_create(&child, NULL, &ChildFn1, 0) !=0){
	perror("Pthreads Error");
        pthread_join(child, NULL);
	}
/*********************************************************************************************/
	PtMainLoop( );
	PtExit( 0 );

	return 0;
	} //end of main 

/*********************************************************************************************/	
	void *ChildFn1(void *arg){
	int Socket_con_Servidor;
	
        Socket_con_Servidor = Abre_Conexion_Udp();
	
	if(Socket_con_Servidor == -1){
	printf("Cant establish connection with server\n");
        exit(-1);
	}

	while(1){
	Recibir_Mensaje(Socket_con_Servidor);
        sleep(1);
         }

        return NULL;
} 

/*****************************************************
//and my socket code here

int Abre_Conexion_Udp(){
struct sockaddr_in Direccion;
int sd = sizeof(Direccion);

	sd = socket (AF_INET, SOCK_DGRAM, 0);
	if (sd == -1){
	return (-1);
	}
	
	bzero(&Direccion, sizeof(Direccion)); 
	Direccion.sin_family = AF_INET;
	Direccion.sin_port = htons(8880); //listening port
	if (inet_aton("192.168.30.255", &Direccion.sin_addr) == 0)  
	perror("Wrong IP address");
	
	if (bind (sd, (struct sockaddr *)&Direccion, sizeof(Direccion)) == -1){
		printf("Bind problem\n");
		close(sd);
		return -1;
	}
	return (sd);
}

/******************************************************************************/
/* Receiving data from server*/

void Recibir_Mensaje(int sd){

struct sockaddr_in Servidor;
int bytes, LargoServidor = sizeof(Servidor);
char buffer[N];
	
	memset(buffer, 0, N);
	
	bytes = recvfrom(sd, buffer, sizeof(buffer), 0, (struct sockaddr *)&Servidor, &LargoServidor);
	//printf("\nBuffer: %s", buffer);
	PtSetResource(Multi, Pt_ARG_TEXT_STRING, buffer, 0);
	memset(buffer, 0, N);		
}

as you can see im trying to put the buffer received from my udp socket into a multitext, im using a thread, but when i 
executed i have memory dump problems... i think this is a synchronicism problem... can anyone help me ?