View previous topic :: View next topic |
Author |
Message |
richard Guest
|
passing arrays via RS232 |
Posted: Tue Apr 20, 2004 9:49 am |
|
|
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
|
|
Posted: Tue Apr 20, 2004 10:50 am |
|
|
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
|
|
Posted: Tue Apr 20, 2004 4:51 pm |
|
|
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. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|