To download NI software, including the products shown below, visit ni.com/downloads.
Overview
The purpose of this VI is to ensure that the VISA resource is closed even if the "X" glyph on the upper right hand corner is used to stop a running VI.
Description
This code was developed in order to be sure that the VISA resource was closed whether the stop button was pushed or the X button was pushed on the upper right hand corner of the window to close the VI. The base program can read and write from a serial port during timeout events of an event structure, but will check for a close action from the user before timeout (every 5ms). If the user choses to stop or close the window, the COM port reference is automatically closed before the window exits. This will ensure that any kind of resource allocation issues will take place if the VI is exited without first stopping.
Requirements
Software:
Hardware:
Steps to Implement or Execute Code
Additional Information or References
To verify that the reference is closed, you can run the I/O Trace application while the VI is open. You should see the COM closed step at the end of the I/O Trace log as shown below.
VI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.