LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In labview,how to read binary file which be writed through arraytofile function in cvi

I get some binary file which be writed by the function of arraytofile in cvi and data type is double , now these file need read in labview. I use read.vi in labview, but i can't get correct data!
0 Kudos
Message 1 of 9
(3,572 Views)
Hi yft:

You get a string with READ.VI function. You now should convert it to DBL array.

I would try with Functions->Advanced->Data Manipulation -> Unflatten from string.

wire the read.vi string output to BinaryString input and
wire an empty array of DBL to Type input.

This could do the job.

Hope it helps,
Aitortxo.
0 Kudos
Message 2 of 9
(3,566 Views)

thanks first!

According to your advice, i write a program in labview, but it cann't work correctly!

I attached a zip file including two file, one is lv file to read binary file that was saved by cvi,and another is cvi file that can generate binary file using arraytofile function.

I don't know where is wrong in lv file?

 

0 Kudos
Message 3 of 9
(3,558 Views)

It has been a long while since I've used the file I/O operations in CVI but I'm confused about what you are doing there. You have the option to save as binary or ASCII and you are also setting the data type to double precision but in your VI you are attempting to read a U8 data type. Try changing your VI to match the data you are writing and attaching a sample of your file and a description of what it sould contain would be helpful.

And no, you do not need to do any casting of numbers to strings unless you want to display strings in your VI.

0 Kudos
Message 4 of 9
(3,555 Views)
thanks your responsing!
 
 now,i attach a lv file and a binary data that is saved by arraytofile in cvi.
in lv7.1,i can't get correct data,but in lv8.0 evaluation i get it.
 
i think in cvi binary data is stored by little-endian, otherwise in lv7.1 the read.vi read data by big-endian,so i can't get correct data!
 
i only buy lv7.1 pds version,so what can i do to get correct binary data that is saved by arraytofile?
 
0 Kudos
Message 5 of 9
(3,549 Views)
LabVIEW 8 added the ability to select the endian type when doing a read but in older versions you can get it to work by doing a byte swap. There have been numerous discussions on this. One with some example code can be found at http://forums.ni.com/ni/board/message?board.id=170&message.id=153565&requireLogin=False.
0 Kudos
Message 6 of 9
(3,542 Views)

Hi Dennis Knutson:

do you mind giving me a example?!

I don't know how to do it about double type.

0 Kudos
Message 7 of 9
(3,537 Views)
Searching the forum can often turn up the answer you are looking for.Smiley Wink A search with dbl endian swap turned up the post at http://forums.ni.com/ni/board/message?board.id=170&message.id=89759&query.id=0#M89759 as the first hit and it has an example program.
0 Kudos
Message 8 of 9
(3,534 Views)
thank you!
0 Kudos
Message 9 of 9
(3,527 Views)