LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView - LabWindows binary file format compatibility

Hi!
 
I wrote a program in LabWindows/CVI to analyze data. This program can read simple binary data file with this structure:
 the file must ONLY contain float (4 byte) numbers (no header, only the numbers).  I use fread, fseek, and so on -normal ANSI C functions-  to read and pozition these  kind of files in my program.   
          There is another program, written in LabView, this program uses the measuring card, and makes the result binary data files.
Is there a way to make binary data file in LabView, what compatible with ANSI C?
 I mean, how can I create a binary data
file (with the structure I wrote upper)  in LabView so I can read this file with ANSI C functions?
 We tried different things, but we just couldn't read data file created by LabView.  
Or is there a special function what i can use instead of fread, to read LabView binary data file?
 
Thank you for the help,
best regards,
 
                                 András Bükki-Deme
0 Kudos
Message 1 of 6
(3,657 Views)

Supposing in LabVIEW you are using Write to SGL file.vi, you can read back your data into CVI float arrays provided you swap bytes since LV stores data on files in big-endian format (most significant byte first) while normally CVI expects data in little-endian format.

Conversion from one format to the other can be performed either in LV or in CVI. Supposing you want to operate on the CVI side you can look at the sample I am attaching, in which a simple VI writes a binary data file and a CVI application reads it back. The CVI project dynamically determines and allocates memory for the file to read.

Message Edited by Roberto Bozzolo on 02-20-2006 06:17 PM



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(3,643 Views)
Thank you! I am totally satisfiedSmiley Happy
0 Kudos
Message 3 of 6
(3,627 Views)

Hi!

I put your code in main one, and it works. The code you sent me, uses memory allocation, so what if I

have to deal with a data file about several gigabytes? I think then the RAM would be overloaded?

How can I change the LVBinFile.c code you sent me? I just need the LabView file to be converted a file what has a LabWindows

file-format, but every operation without full memory allocation.

(I know this question is an ANSI C question, but i am still quite a biginner even in C 🙂     )

Thank you very much for your help,

best regards,

                     András Bükki-Deme 

0 Kudos
Message 4 of 6
(3,614 Views)

You can read and process the data file in chunks so that you don't have memory allocation problems. Simply insert the read in a loop until end of file: read a fixed amount of data (say 1000 floats per read) so you don't have to deal with dynamic memory allocation. Take care of the bytes read every time: on the last iteration, immediately before end of file, you may read less than the expected bytes from the file.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(3,603 Views)

Thank you! I finished may code, and it works. And I changed it as you said, so it can deal with huge data files now.

And I have no more LabWin - LabView file compatiblity problem, I can convert files between the 2 formats Smiley Happy.

Best regards,

 

                 András Bükki-Deme

 

0 Kudos
Message 6 of 6
(3,594 Views)