Page 1 of 1

Reading string from RS232

Posted: Fri Mar 13, 2015 4:23 am
by kassa
I have spent hours trying to solve an issue that is probably very simple. I looked all over this forum and cannot find anyone experiencing the same issue I'm having.
1. I have a very simple setup to test RS232 read. I send 8 bytes to the serial port and find only the first two bytes are read and stored in the string variable. The remaining 6 bytes are all zero. I'm I missing something?

2. I found on this forum that UART RXINT1 interrupt cannot be simulated in Flowcode 6 as of yet. Please correct me if I'm wrong.

Thank you in advance for the help!

Re: Reading string from RS232

Posted: Fri Mar 13, 2015 3:07 pm
by LeighM
You could try increasing the timeout value for the ReceiveString, that will allow more time between characters. Although if you are typing characters by hand on a keyboard it is likely the macro will still timeout between characters. This will only work for automated streams. For slow input, you could use ReceiveChar instead and save the received characters into the buffer yourself. The ReceiveChar macro will return 255 if nothing was received, so you could loop waiting for non-255 results.

Another issue with your test program is that you have a 5 second delay in the loop, this is best removed as this will dominate the loop time and cause you to miss input. As you point out the interrupt is not simulated.

Re: Reading string from RS232

Posted: Fri Mar 13, 2015 4:32 pm
by kassa
LeighM, thank you for the response. I have removed the 5 second delay and increased the timeout and got the same result. However, I found a post (http://www.matrixtsl.com/mmforums/viewt ... ing#p62250)on these forums that may solve my problem. My 3rd byte is 0x00. The string variable interprets the 0x00 as end of string instead of continuing to read the remaining bytes. It looks like I need to use ReveiveChar instead of ReceiveString and load into and array variable in a loop.

I will give that a shot and see.

thanks again.

Re: Reading string from RS232

Posted: Fri Mar 13, 2015 6:33 pm
by kassa
Solved! Received data always starts with one and I expect 8 bytes of data. So the following code now works!

Thanks again.