LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication: write message exactly once?

Solved!
Go to solution

Hello. I'm using the Continuous Serial Read and Write.vi example in LabVIEW, and I want to modify it so that I only write a single message rather than having it write continuously. How can I do this? I've been trying to figure out how to do it but the problem is I'm having very inconsistent results with reading back what I send, so I have no idea what's actually working and what isn't. What I think works is setting the Write switch mechanical action to Latch When Released, which seems to work most of the time...but sometimes when I click Read I don't get anything after writing.

0 Kudos
Message 1 of 4
(3,548 Views)
Solution
Accepted by topic author achb

Don't use a switch or a case structure at all for the read.  Just let it read.

You are best off putting the write and read in the same case structure for the write button.  You click the button, it writes.  It reads, if you don't get anything back within the timeout period, it would certainly be a problem with your device or cable rather than with LabVIEW.

Message 2 of 4
(3,532 Views)

The Write and the Read buttons should be set to Latch When Released.

 

Are you using a loopback cable for your testing here?  Or are you trying to program a microcontroller that just does sends the same thing back to you?  I'm just looking for other things that could be wrong.  It might also help us give you better advice if you explained what your end goal is here.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(3,530 Views)

Wow I didn't even consider that at all. Thanks, I'll give that a shot!

 

edit: Yes, I am just sending messages to an Arduino which sends it back. I had tried sending the Read button to latch when released but that didn't seem to work. However, putting the read operation directly after the write without having a separate button did the trick.

0 Kudos
Message 4 of 4
(3,529 Views)