Two VIs Accessing the Same Serial Port Simultaneously Primary Software: LabVIEW Development Systems>>Professional Development SystemPrimary Software Version: 8.2.1 Primary Software Fixed Version: N/A Secondary Software: Driver Software>>NI-VISA
Problem: Can I simultaneously run two VIs, one that reads from a serial port and one that writes to the same serial port? Solution: The read and write buffers of a serial port are separate entities as well as the TX and RX pins, so there might be applications where you want to read from and write to the same serial port. When an application (like Hyperterminal) reserves the port, a different application (like LabVIEW) cannot make use of the same port while the first application is using it.
However, two VIs running under the same LabVIEW session can access the same port. You can try this with the VI Advanced Serial Read and Write.vi included in the LabVIEW examples:
Even though the two VIs have a VISA Configure Serial Port.vi, the reference passed by the second caller VI is the same as the reference obtained by the first VI. This is why the two VIs can perform read/write operations on the serial port as if they were in the same VI wired to the same open reference.
However, when building an executable out of each of these VIs, the parallel access to the same port is not possible since the two executables are seen as two different applications, unlike running the VIs under one LabVIEW session. You can verify this using Windows Task Manager.
A possible work-around is to create an upper level VI that calls the two Serial Read/Write VIs as subVIs, then create an executable out of that upper level VI. This way, there will be only one application running and the two subVIs will be threads under this application.
Related Links: Attachments:
Report Date: 12/03/2007 Last Updated: 04/03/2008 Document ID: 4G2D68YX |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
