To download NI software, including the products shown below, visit ni.com/downloads.
Overview
Demonstrates how to use the .NET Serial Port Class to get a list of the serial ports in the system.
Description
Here is simple example description:
This example shows how to use the .NET Serial Port Class to get a list of the serial ports in the system. In order to access the method shown below, a constructor was first created. Constructors may be found in the .NET palette, which is a sub-palette of the Connections palette. Once the constructor is placed, a dialog pops up so you can select which object and constructor to use. First, expand the system object, then select the system IO ports object. Then, select the serialport() constructor. Then, you can right click on the constructor and select create and method, and in the list of methods is the [S}GetPortNames method.
Below, there is a VI using this example to get serial ports, and then showing a dialog to select the COM port. Additionally, below that is a version of the .NET Basic Serial Write and Read that uses the dialog VI to select the COM port to use. .NET is useful for using COM ports where VISA is not installed on a system or additional parameters need to be configured for the COM port, that VISA doesn't allow for. Note that the class used is found in version 2.0 or higher of the VI framework.
Requirements
Steps to Implement or Execute Code
Additional Information or References
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.