| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		tkm
 
 
  Joined: 18 Jan 2011 Posts: 72
 
  | 
		
			
				 Posted: Tue Jan 25, 2011 11:28 am    Post subject: Pls help--unable to display/catch call_control info | 
				     | 
			 
			
				
  | 
			 
			
				Hello,
 
  I am trying to get call_control info on display below, but I am receiving garbage. Please help.
 
 
 	  | Code: | 	 		  
 
void disply (void * x)
 
{
 
      display_text_raw (x, Q_DISPLAY_TEXT_HIGH_PRIORITY |
 
            Q_DISPLAY_TEXT_DELAY_CLEAR);
 
} 
 
 
void call_control (u8 * s)
 
{
 
u8 *get_resp_call;
 
u8 get_resp_call_len = 0;
 
u8 *tmp = malloc (100); 
 
 
get_resp_call[get_resp_call_len++] = CALL_STAT_MODIFY;
 
get_resp_call[get_resp_call_len++] = 0x00;   //len
 
get_resp_call[get_resp_call_len++] = T_ADDRESS;   
 
get_resp_call[get_resp_call_len++] = 0x00;   //len
 
get_resp_call[get_resp_call_len++] = 0x81;
 
.........
 
..........
 
 
memcpy(tmp, get_resp_call, (get_resp_call_len - 2)); 
 
tmp[get_resp_call_len-1]='\0'; 
 
stk_thread(disply, tmp);
 
}
 
 | 	  
 
 
It would be really helpful if someone can kindly point out where I am doing wrong in capturing the array info. Many thanks. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz
 
 
  Joined: 12 Mar 2004 Posts: 1161
 
  | 
		
			
				 Posted: Wed Jan 26, 2011 6:42 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				You are trying to print non-ascii/printable chars, so you get garbage.
 
Use some converstion to hex, sprintch()...
 
 
Don't forget to free(tmp) | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		tkm
 
 
  Joined: 18 Jan 2011 Posts: 72
 
  | 
		
			
				 Posted: Fri Jan 28, 2011 12:06 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				 	  | pz wrote: | 	 		  You are trying to print non-ascii/printable chars, so you get garbage.
 
Use some converstion to hex, sprintch()...
 
 
Don't forget to free(tmp) | 	  
 
Thanks a lot,pz. Sorry for the late reply. Didn't realize u replied. I will use sprintch to convert to hex before displaying. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		tkm
 
 
  Joined: 18 Jan 2011 Posts: 72
 
  | 
		
			
				 Posted: Mon Jan 31, 2011 4:01 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Hi pz, 
 
I would really appreciate a bit further help on this. This is how I am trying to access T_ADDRESS of call_control but still getting garbage.
 
 	  | Code: | 	 		  
 
u8 j2,l2,i2;   
 
u8 *r2 = buf_B ();
 
u8 *buf = malloc (200); 
 
memcpy(buf, &get_resp_call[2] , get_resp_call_len ); 
 
 
j2 = get_tag (buf, T_ADDRESS);
 
 
if (j2 != 0)
 
{
 
 
   l2 = buf[j2 + 1];
 
   for (i2 = 0; i2 < l2; i2++)
 
     r2 = sprintch (r2, buf[j2 + 2 + i2]);
 
   r2 = sprintc (r2, '\0');
 
}
 
stk_thread(bum, buf_B()); //calling display_text_raw
 
free(buf);
 
 | 	  
 
 
Please can you help me on what I am doing wrong? Many thanks. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz
 
 
  Joined: 12 Mar 2004 Posts: 1161
 
  | 
		
			
				 Posted: Tue Feb 08, 2011 9:55 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Try memcpy(buf, &get_resp_call[1] ,  get_resp_call[1]+1); 
 
get_tag() should point to buffer starting with len, you are skipping it. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		tkm
 
 
  Joined: 18 Jan 2011 Posts: 72
 
  | 
		
			
				 Posted: Fri Feb 11, 2011 2:57 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				 	  | pz wrote: | 	 		  Try memcpy(buf, &get_resp_call[1] ,  get_resp_call[1]+1); 
 
get_tag() should point to buffer starting with len, you are skipping it. | 	  
 
Many thanks,pz. Will do. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |