The DataSocket Read function reads incoming live data as variant data by default.

Using variant data for live data communication allows you process data without needing to know the exact data type. This is useful for programmatically reading complicated data and reading data from an unfamiliar source, such as a different application.

You can cast this variant data to a specific type while reading it or after reading it using the Variant to Data function. If your variant data contains attributes, cast the data to a specific type after reading it so you can extract the attributes.

Adding and Reading Attributes in Live Variant Data

You can use the To Variant function to convert the data you write to a data connection to variant data programmatically.

The following block diagram continuously acquires a temperature reading, converts the data to variant data, and adds a time stamp as an attribute to the data.

LabVIEW block diagram showing temperature data conversion to variant with a timestamp attribute.

When another VI reads the live data, the VI must convert the variant data to a data type it can manipulate. The following block diagram continually reads temperature data, converts the variant data into a temperature reading, retrieves the time stamp attribute associated with each reading, and displays the temperature and the time stamp on the front panel.

LabVIEW block diagram for reading and converting variant temperature data with timestamp.