LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Erro 116 while reading binary file.

HI All,

 

I am trying to read binary file and I am receiving error code 116 while doing so for few files.

I can read data from few files but for few files I am not able to read it. But if I write some random number in count input of Read Binary.vi, which is '-1', it reads data without error.

Now I am writing cluster in Big Endian format with Prepend size set as 'False'. I have copied same cluster and have connected it to Read Binary vi(to avoid data type mismatch) as data type with format as big edian only.

I don't know why it is reading few files and why it is giving error 116 for few, and reads them if I give input number other than '-1' to count.

Have anyone of you faced this type of issue?

Also, is there any method by which I can read COUNT so that I can input it to Read Binary.vi(similar method which we apply for reading number of Bytes at port in VISA communication-  its just an example).

 

Any solution is highly anticipated.

Thanks

0 Kudos
Message 1 of 3
(3,113 Views)

Can you post your VI which saves and loads the binary file?

 

My best guess would be that because prepend size is set to false when saving the binary file, LabVIEW doesn't know how big the data is when loading it, so is throwing an error. So try setting it to true and see how it goes.

 

In terms of getting a 'read count', I'm guessing all want there is the file size. This can be obtained with Get File Size VI in the Advanced File Functions pallette under the File I/O pallette.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 2 of 3
(3,083 Views)

For binary reads to work properly, you must know (in advance) exactly the format of the data that has been written, and then read it in with a compatible format.  Error 116 suggests that you are not doing that, and the error comes when your reads get "misaligned" with the byte stream in the file.

 

One form of read that is almost guaranteed to work is to read your file as an array of unsigned bytes.  Then, of course, you have to figure out what the byte stream represents (e.g. a 14-byte string, a 4-byte signed integer (I32), an unsigned 8-byte integer (U64), a 64-bit Float (Dbl), etc.).

 

To help you find and fix this error, you would need to post the code that does the writing (with the data to be written) as well as the code to do the reading.  I suggest putting Write Code, Read Code, and data sample in a folder, compressing the folder, and attaching the ZIP file so we can examine things.

 

Bob Schor

0 Kudos
Message 3 of 3
(3,055 Views)