Page 1 of 1

Read RS232

Posted: Tue Sep 18, 2012 6:18 am
by Desdewit
Hi Guys

What would be the best way (Array or String) to read 8 packets of 14 bytes coming in every 10sec via rs232 :?:
I want to keep the data in bytes so some of it can be changed and send back out after a few seconds.

Re: Read RS232

Posted: Tue Sep 18, 2012 9:09 am
by Enamul
Hi,
I think it's better to use RXINT for RS232 read. As this helps you to keep your controller busy in doing other stuffs but can read RS232 data meanwhile..which you can put in a pre-defined array of your data length. You can initialize array index to count how many bytes you have received to be confirm that you have received 8*14. At the end of all byte reception you can simply re-initialize index which will enable you for another reception.

I am attaching here two code using RXINT as a start..

Re: Read RS232

Posted: Wed Sep 19, 2012 12:42 pm
by Desdewit
Hi Enamul

Thanks for the reply, the RXInt is working realy well with one byte at a time but when I receive a string of 14 bytes at once and try to read one byte from the string like Data[4] the lcd display nothing.
Sending one character at a time like ascii "A" prints on the lcd but sending "AA" leaves the lcd blank

Re: Read RS232

Posted: Wed Sep 19, 2012 12:49 pm
by Enamul
That's why I told you not to use string read rather use char read..but use an index variable to mark string byte number. If you are not quite clear I can post something for you..

Re: Read RS232

Posted: Wed Sep 19, 2012 1:19 pm
by Desdewit
Hi Enamul

At last I got it to work with RXint.
Thanks for the support. :lol: