SolutionIf you are trying to communicate between an executable and VI running on the same machine
, the most common problem that you will run into is that each environment will usually attempt to use the default port of 3363 for its VI Server port. The first LabVIEW environment to load up under this port will usually maintain control of that port, which will cause other LabVIEW environments that attempt to access the port to fail. To avoid this, you must configure your other environments to use a different port number. This is the first thing you should confirm when troubleshooting environments running on the same machine.
The rest of this article applies to executables running both on the same machine as the development environment and those running on a remote machine:
- Communicating from the LabVIEW Development Environment to an Executable VI (LabVIEW Run-Time Engine)
Each Executable VI will launch its own instance of the LabVIEW Run-Time Environment, so in order to open an application reference of an executable VI from the development environment you must know the port number for that particular instance of the run-time engine. By default, the VI Server properties for an executable VI are setup to deny access from all TCP/IP requests, and to use port 3363. You will need to enable TCP/IP access for your project and allow network connections from the development computer by adding its IP address to the whitelist in the same menu. If you want to communicate with this VI from the development environment on the same machine, enable TCP/IP access for 'localhost' and use a different port number than the development environment (to avoid conflicts).
To configure the VI Server settings for the executable, right click My Computer and select Properties, then navigate to VI Server and configure the TCP/IP access.
The following is an example of a VI that can be used to open up a reference to the run-time engine running on the same machine as this VI at the port specified in the VI's properties. To modify this code for remote access, substitute the deployment computer's IP address for 'localhost' as input to the Open Application Reference VI.
The Application.Kind property node can be used to verify that you have successfully opened a reference to the run-time environment. The example also shows how once you have opened an application reference to the run-time environment, you no longer need a full path to open a VI reference to any VI that is currently loaded into memory in the run-time environment. It is good practice to specify VIs only by name rather than the full path to ensure that LabVIEW always uses the copy of the VI loaded by the EXE.
- Communicating to the LabVIEW Development Environment from an Executable
The easiest way to accomplish this on the same machine is to place the development environment on a port that is different than the run-time engine and enable TCP/IP access for 'localhost'. If the executable is already setup to load into a unique port by setting the server.tcp.port setting in its .ini file, then the only change that will need to be made to LabVIEW is the TCP/IP settings. The TCP/IP settings can be changed under Tools»Options, clicking VI Server and then by modifying items in Configuration and TCP/IP Access. Make sure that the TCP/IP protocol is enabled and that 'localhost' is in the TCP/IP access list.
To communicate with a LabVIEW development environment running on a different machine, allow TCP/IP access for the remote machine's IP address on the development machine, instead of 'localhost'. The default port can be used by both environments since they are running on different machines.