Reading string from RS232

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
kassa
Posts: 3
Joined: Thu Mar 12, 2015 4:12 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Reading string from RS232

Post 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!
Attachments
rs232_test.fcfx
rs232 read
(5.34 KiB) Downloaded 221 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Reading string from RS232

Post 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.

kassa
Posts: 3
Joined: Thu Mar 12, 2015 4:12 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Reading string from RS232

Post 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.

kassa
Posts: 3
Joined: Thu Mar 12, 2015 4:12 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Reading string from RS232

Post by kassa »

Solved! Received data always starts with one and I expect 8 bytes of data. So the following code now works!

Thanks again.
Attachments
rs232_test.fcfx
(6.56 KiB) Downloaded 356 times

Post Reply