ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Port VISA Resource

I have a Command/Status VI (Ver 6.1) that uses VISA serial port communications to continually read status or write commands when new commands are entered. I have added a selectable button to pause the command/status operation, open a sub-VI screen, and allow the user to enter unique commands to change a set of unique parameters. After the pop-up VI writes the commands and is closed, the VI continues normal Command/Status operation. Both the Command/Status VI and sub-VI close the serial port after each read or write, and work stand-alone. The Main VI and sub-VI also both use the same serial com port (and VISA resource).
The problem is that the Command/Status VI gets communications errors for several seconds after the sub-VI is closed befor
e working properly. Is the cause of the problem the common VISA resource? Will using re-entrant solve the problem? Any comments or suggestions would be appreciated?

Thanks,
Dave H.
0 Kudos
Message 1 of 5
(3,199 Views)
What type of communications errors are you getting? Does NI Spy show the serial port activity that you expect? I am not sure, but maybe it is a matter of flushing the buffers prior to closing the sub-VI.
=====================
LabVIEW 2012


0 Kudos
Message 2 of 5
(3,199 Views)
It is my own error message rather than a NI error message. I have a time-out built into the read function that exits the read if there is no data available after 200 tries. The time-out message allows the user to either continue operation or exit the program. I get several of these in the Command/Status VI (after returning from the sub-VI) and then it seems to continue normal operation.
0 Kudos
Message 3 of 5
(3,199 Views)
You do not need to close the port after every read and write. If you open a session to the port, you can use the reference throughout your VIs. Although it is redundant, I prefer to use VISA open in the beginning, VISA read/write commands in the middle ,and VISA Close at the end. Passing the reference created in the main VI to the subVI and back out is fine. I suspect overhead from opening a session and closing it is why you get the error. Be sure to wire the error clusters so that you can see the error codes created.

I do not believe that setting the VI re-enterant will help. Re-enterant VIs just make a new copy of the VI in memory when they are run as opposed to using the same place in memory.

Jeremy Braden
National Instruments
0 Kudos
Message 4 of 5
(3,199 Views)
Thanks!
0 Kudos
Message 5 of 5
(3,199 Views)