取消
显示结果 
搜索替代 
您的意思是: 

Serial communication: write message exactly once?

已解决!
转到解答

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 项奖励
1 条消息(共 4 条)
4,121 次查看
解答
接受人 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.

2 条消息(共 4 条)
4,105 次查看

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.



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
3 条消息(共 4 条)
4,103 次查看

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 项奖励
4 条消息(共 4 条)
4,102 次查看