From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Using Events with NI-Serial

Code and Documents

Attachment

Overview

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

Description

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.

Contributors