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

passing arrays via RS232

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







passing arrays via RS232
PostPosted: Tue Apr 20, 2004 9:49 am     Reply with quote

Hi All,

I am a newcomer to this compiler and I wish to send and recieve
an array via the RS232.

Which command and syntax do I use.

Eg.

int data [] = {5,6,7,8};

Which command would I use to send this array - printf??????
---------------------------------------------------------------------------

Which command would I use to recieve an array via RS232???

Best Regards
Guest








PostPosted: Tue Apr 20, 2004 10:50 am     Reply with quote

Quote:


Which command and syntax do I use.



You need the following command:

google >>> ("search") >>> ( "RS232" + "string")

rgds.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue Apr 20, 2004 4:51 pm     Reply with quote

I would start with something like this:

Code:

for(i=0;i<lastindex;i++)
{
   putc(array_to_send[i]);
  // optional use handshake lines or pace the data stream
  // with delay code
}


That would send the values from array_to_send[] as binary assuming they were 8 bit values.

Or if I wanted the ASCII representation of the values from array_to_send[] then I'd use
Code:
printf("%d",array_to_send[i])
if I was feeling lazy and had plenty of program space to spare. If program space was tight I'd probably use itoa() and putc() together.

If I didn't know the value for "lastindex", I could use the sizeof() operator to compute it for me.

If array_to_send[] is 16 or 32 bit elements then I'd combine putc() with the return value from make8().

So lots of information presented. Four things you should do. First is get yourself a copy of C Programming Language (2nd Edition) by Brian W. Kernighan & Dennis Ritchie (ISBN 0131103628 ). Second is read the book. Third is read the manual for CCS to learn its built-in functions. Fourth task is to practice your new skills. Very Happy
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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