LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing a serial port after executing a for loop of write and reads.

Hello,
 
Labview is opening and then closing each write to the port. I have tried to leave the close outside of the for loop, but labview wont allow it. What do I need to change to make all the writes and reads execute on 1 open and close of the serial port.?
 
Thanks.
0 Kudos
Message 1 of 5
(3,276 Views)
0 Kudos
Message 2 of 5
(3,273 Views)
J_es--
 
     The program that you posted looks to be ok for the most part, you might consider putting an open after your configure (but that's trivial). The other thing that is a minor issue is the loop tunnel coming out of your for loop is currently being auto-indexed.  This function is used to index data for each interation of the loop.  You are using a static address (not an array) and so you don't need this.  If you right-click and remove the auto-index the broken wire will go away. Other than that it should be ok.
 
     I would suggest looking at one of the shipping examples that come with LabVIEW.  "Basic Serial Read and Write" is essentially the same thing that you are doing and is tested here and might save you a bit of time.  Anyway, take a look if you have a second. Best of luck with your application!
 

John H.

Applications Engineer

National Instruments

http://www.ni.com/support

 
 
0 Kudos
Message 3 of 5
(3,242 Views)
Thanks for the help.
 
I solved my problem by using a stacked sequence instead of the for loop.
 
For some reason the stacked would allow the close outside the structure, but the for loop would not.
0 Kudos
Message 4 of 5
(3,236 Views)
Your problem is that you don't understand one of the basic operations of a for loop. An array will be automatically aut-indexed as it enters a for loop and a wire exiting a for loop will be automatically made into an array. If you had just right clicked on the exit tunnel and selected Disable Indexing, it would have worked. Even better would have been to use a shift register to pass in and out the error cluster. As it is, you have nothing to wire the error handler to. A stacked sequence structure will work but it's not very effecient code and usually results in some ugly wiring.
0 Kudos
Message 5 of 5
(3,233 Views)