Example Code

Using Events with NI-Serial

Code and Documents



Demonstrates how to enable and wait on Serial events in LabVIEW NXG


This code creates a VISA session and enables Serial Events. This example uses the VISA Event Serial TermChar (0x3FFF2024) to detect when a termination character is received at the serial port. It sends a string with VISA Write and then waits for a response, with VISA Wait On Event, and reads a given number of characters. You can enable different events to trigger a read instead of using the simple timeout functionality, or to avoid reading every time there are characters available.

Hardware and Software Requirements

LabVIEW NXG 1.0 (or compatible)

NI-Serial 17.0 (or compatible)

Steps to Implement or Execute Code

1. Select an existing VISA Resource.
2. Run the VI.
3. You should see a response in the read buffer once the configured Serial event is triggered.

Additional Information or References

Austin H.
Applications Engineering
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.