Overview This example shows how to use the .NET Serial Port Class with a remake of a classic VI, the Serial Basic Write and Read.
Description This is useful if you don't have the VISA driver installed on the machine. Note that this class is found in version 2.0 or higher of the .NET Framework.
Steps to Implement or Execute Code
1.Select a port of serial device, configure serial setting.
2.Run the VI, and write to the string
Additional Information or References VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
Thanks much for this. This gave me what I needed to talk to an old spectrometer that needed some wierd delay settings for the serial port that normal VISA couldn't do.
Hi, I see this is an old thread. I have a new comment. First, thanks! This is a good example of .NET. Most appreciate. What I am trying to do is to discover what com ports are available. i.e. get a list of com's. programmically. I see in this example, the com name is a string and it is given. How would I discover what com's are available?
First, go to the connectivity palette and there to the .NET palette. Select Constructor. Once the constructor is placed, a dialog will pop up so you can select what creator to use. In the Objects section of the dialog box, select System, then System.io.ports then click on Serial Port. In the Constructor section, select the SerialPort() object and press OK. Now, right click on the constructor and select create, then the option that says Method for System... . Then, select GetPortNames(). An invoke method node will be created. In my test VI, I just connected the output of the invoke node to an indicator. You will be able to delete the constructor at that point. See the attached image for an example and the results on the front panel. You can also get the example at https://decibel.ni.com/content/docs/DOC-43774 along with a version of the example from this page, in which I used the example code. I created that page, since I couldn't attach the example here.