OpenQNX :: The QNX Community Portal

Sep 07, 2008 - 07:24 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 48 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
dunno98
Post subject: how to send double to Pt_ARG_TEXT_STRING  PostPosted: Apr 05, 2008 - 10:26 AM
New Member


Joined: Apr 05, 2008
Posts: 5

Dear all,

I am new to qnx so kindly pardon me for my silly qns.

I am trying to display a value to a label using the following method

Code:

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);\


but is seems to crash the system

but when i used a static string like
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,"TEST", 0);

it seems to be ok.
It seems that i can use sprintf to pass the variable over.

Can anyhow help me out???
thanks in advance
 
 View user's profile Send private message  
Reply with quote Back to top
dunno98
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING  PostPosted: Apr 05, 2008 - 10:43 AM
New Member


Joined: Apr 05, 2008
Posts: 5

it seems that it is not due to sprintf but when i insert a loop into it

i am really puzzle why a loop will cause a crash

for (i=1;i<15;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);
}

error is:
Process 446480 (AntiB_gNiNo_NB1207392159576) terminated SIGSEGV code=1 fltno=11 ip=0117e154 mapaddr=00101154. ref=00000014
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING  PostPosted: Apr 05, 2008 - 06:03 PM
QNX Master


Joined: Jun 25, 2003
Posts: 1078

While this doesn't explain your problem, you might want to note that if your code was working, the first 14 time though the loop would accomplish nothing visible.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
mario
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING  PostPosted: Apr 08, 2008 - 08:40 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2849

To add to Mitch's comment, I find the i=1 odd typicaly it would be 0. Also how have you defined the cs and cd variables?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
martinj999
Post subject: RE: how to send double to Pt_ARG_TEXT_STRING  PostPosted: Apr 25, 2008 - 08:15 AM
New Member


Joined: Jan 11, 2007
Posts: 4
Location: UK
For the conversion in sprintf I would use 'lf' (LF) if the variable is defined as double, at waht point does it crash?
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.