Developer Center Resources

cancel
Showing results for 
Search instead for 
Did you mean: 

Inter-Application Communication: File I/O

» Inter-Application Communication » File I/O

Description

LabVIEW can share data with 3rd Party tools using File I/O. Communication using File I/O involves one program creating and saving the file, and the other program opening and accessing the file.

FileIO 01.png

 

 

File I/O is an easy way of transferring data between applications. There is a minimal amount of programming to be done in LabVIEW to open and process the data in a file, and likewise to save data to a file. One benefit inherent to this type of communication is that all data is saved before being used, so a backup copy is available if needed. LabVIEW natively supports the following file types for saving and opening data:

 

  1. Text File – A text file contains data in plain text format, which can be parsed and read by either LabVIEW or another application. One of the advantages of a text file is that it is readable universally by many types of software packages.
  2. Binary File - A binary file in LabVIEW contains data in raw binary format. A binary file has a very low memory footprint but the data is not universally readable.  If the file is to be shared, the reader must understand the format of the file.
  3. Spreadsheet File - A spreadsheet file is a text file formatted as a spreadsheet. Spreadsheet files are easy to parse and analyze because the data in spreadsheet files are organized into rows and columns. This type of file format is generally associated with spreadsheet software, but can be read from any software that can open a text file.
  4. TDM/TDMS – A TDM/TDMS file is a binary file specially optimized for storing large amounts of data. A major benefit of the TDM/TDMS file format is that the data is easily indexed and searchable with the LabVIEW DataFinder Toolkit and the DataFinder in DIAdem. Because the data is in binary format, 3rd party software cannot directly read TDM/TDMS files but can use the TDM C DLL or the TDMS .NET class library to read and write TDM/TDMS files.

Example Use-Case

The TDMS file format can be used to log data in LabVIEW and then perform post acquisition analysis of the data in DIAdem.

 

The following screenshot shows how to store simulated data in the TDMS file format from LabVIEW. The subsequent screenshot shows the data loaded in DIAdem for advanced analysis and reporting.

FileIO 02.png

 

 

Figure 1: Storing measurement data in LabVIEW to TDMS file format

FileIO 03.png

 

 

Figure 2: Reading measurement data in DIAdem

Code Example

The following examples can be found from the NI Example Finder in LabVIEW, by navigating to Help»Find Examples...

  • Write to Text File.vi, Read from Text File.vi
  • Write Binary File.vi, Read Binary File.vi
  • Export Waveforms to Spreadsheet File Example.vi
  • Write TDM/TDMS File.vi, Read TDM/TDMS File.vi

Additional Resources

Developer Zone Tutorial: NI TDM/TDMS Data Model
KnowledgeBase 10U39NAQ: Writing Binary Files with LabVIEW That Can Be Read by Other Applications
KnowledgeBase 42AANPH0: Reading and Writing TDM/TDMS Files

Jervin Justin
NI TestStand Product Manager
Comments
Ajay_MV
Active Participant
Active Participant
on

Is File I/O good for streaming the data between two processes? 

I think, if we continually read & write (stream) the data in same file, it may burn the segment on disk (bad sector it).  Isn't it?

--
Ajay MV


crossrulz
Knight of NI Knight of NI
Knight of NI
on

Ajayvignesh_MV wrote:


                       

Is File I/O good for streaming the data between two processes? 


                   

For steaming?  Definately NOT.  If different executables, then TCP would be the proper way to stream data.  Inside the same application, there are a lot more options (queues, user events, etc).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Active Participant
Active Participant
on

If you're on Linux (i.e. LVRT), just open a pipe. You can on Windows too, but the native API is clunky and requires a lot of finesse to avoid boundary-condition errors.

Ajay_MV
Active Participant
Active Participant
on

David,

Pipe communication looks interesting.  Does pipe communication works with LabVIEW?  Would you be able to give me some example?

--

Thanks,

Ajay.

--
Ajay MV