05-24-2012 10:05 AM
Hi all
I have a Doubt with serial comunication. I need read and write data. The data for read comes for external hardaware(microcontroller), and data for write is for send to microcontroller. The read and write work very well separately, but when I want user the two in a single VI, no work well. I use a stacked sequence with 3 frames. one for read, one with a delay and the last for write.but No work well....
Can you help me?
I need know how use read and write
05-24-2012 10:37 AM
Post your VI.
05-24-2012 10:38 AM
Do you mean you have a question? Don't have a doubt. It will work.
You will need to attach a VI so we can see what you might be doing wrong. The fact you said you have a 3 frame stacked sequence worries me to start with. Stacked sequences should be avoided. If you do need a sequence, then use a flat sequence structure.
Most devices, you need to write first to send out a command, then do a read to read back the response from the device. The way you describe it, it sounds like you have it backwards.
05-24-2012 11:37 AM
05-24-2012 12:05 PM
Your cases for 1 and 2 don't have a new line/linefeed character within the string constants 1 and 2 like your cases for 4 and 8 do.
Replace your Stacked Sequence with a Flat sequence then do a block diagram cleanup to make your code easier to read.
Other than that, nothing else seems obviously wrong.
05-24-2012 05:31 PM
Other than what Raven's Fan has pointed out, I don't see anything either. You are intending to see a carriage return to terminate your received data, correct? This is how you have it set up.
05-24-2012 06:42 PM
After you clean up the BD as Raven's Fan suggests, add an indicator on the output of Bytes at Port. Then you'll be able to see if you're getting the full number of bytes to complete the message. Changing the read buffer indicator to '\' Codes display any non-printable characters in your message.
If you know the length of the message, then you can monitor the Bytes at Port until you get the right number of bytes or see the termination character (\n). If you don't know how many bytes to expect, wait for some bytes then read until you get the termination character. Then you can eliminate those waits.
05-24-2012 11:17 PM
You can just probe the wire at Bytes at Port instead of using an indicator. Less clean-up that way.