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

rs232

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



Joined: 31 Mar 2008
Posts: 29
Location: Mumbai, India

View user's profile Send private message Visit poster's website

rs232
PostPosted: Thu Jun 05, 2008 3:48 am     Reply with quote

hello,

I have this problem with rs232. I want to input float value but i am not able to find anything related except rs takes only char ? that is, with the help of functions getc(), putc(), getch() ?

may be i m mistaken with something ?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 8:02 am     Reply with quote

The UART only knows bytes. Those bytes can represent chars, or int8s, or parts of bigger variables. Look at the make8(), make16(), and make32() compiler functions.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 8:39 am     Reply with quote

RS232 is a standard only describing the hardware. It allows you to send and receive bytes.

A floating point number consists of multiple bytes, 4 in the CCS compiler, sometimes more in other compilers. You will have to break up the number in byte size blocks, for example with the make8 and make32 functions mentioned by SherpaDoug. The sequence of how you transmit these bytes also depends on the program listening at the receiver side.

What program are you using at the receiver?

Sending the data as readable text is a bit easier, use fprintf with the %f format specifier.
ferrousduke



Joined: 31 Mar 2008
Posts: 29
Location: Mumbai, India

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 05, 2008 8:59 am     Reply with quote

Indy wrote:
RS232 is a standard only describing the hardware. It allows you to send and receive bytes.

A floating point number consists of multiple bytes, 4 in the CCS compiler, sometimes more in other compilers. You will have to break up the number in byte size blocks, for example with the make8 and make32 functions mentioned by SherpaDoug. The sequence of how you transmit these bytes also depends on the program listening at the receiver side.

What program are you using at the receiver?

Sending the data as readable text is a bit easier, use fprintf with the %f format specifier.



lets say I have a string stored which was earlier gets() from the terminal, this string contains a 6 digit number. so I need to convert the string into a float or int value for further calculations. can you help me with that ?
Steve H
Guest







PostPosted: Thu Jun 05, 2008 1:14 pm     Reply with quote

Check the standard C functions

atoi
atol
atof

HTH - Steve H.
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