CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

problem with itoa and atoi

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gabo1024



Joined: 02 Apr 2012
Posts: 1

View user's profile Send private message

problem with itoa and atoi
PostPosted: Mon Apr 02, 2012 1:35 pm     Reply with quote

Hi, i have used this configuration for multiple usarts:
Code:

#use rs232(baud=9600,parity=n,xmit=PIN_A2,rcv=PIN_A3,bits=8,stream=display)//conexion a display
#use rs232(baud=9600,parity=e,xmit=PIN_C1,rcv=PIN_C2,bits=7,stream=balanza)//conexion a balanza
#use rs232(baud=9600,parity=e,xmit=PIN_A0,rcv=PIN_A1,bits=7,stream=pc)//conexion a PC

I receive this datagram in ASCII code: "02905" or 30,32...35 in hex, for example.

I need convert this datagram to decimal, process(divide for 100 or 1000) for later sending for others ports balanza, or pc.

as I can do ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 02, 2012 2:30 pm     Reply with quote

The atol() function (ASCII to long) requires a string as the input. The
ASCII digits must be in an array, and the digits must have a 0x00 byte at
the end. The array must be large enough to hold the ASCII numbers, and
the 0x00 byte.

If the ASCII digits don't have a 0x00 byte at the end, then you must
write code to put it there.

The atol() function can convert a signed decimal ASCII number from
-32768 to 32767, into a 'signed int16' value in CCS.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group