LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary file corruption in LabVIEW

Hi Everyone,

 

I have faced one problem in handling  binary file. One part of my program is flatten a cluster into a string and write that string into a binary file. In some other part of the code is open the file and read the data as a string then unflatten into cluster. Writing into a binary file execute only once. But frequently program reads the file depending upon the condition. During this read operation i got a error Data Structure Corrupted in unflatten function, Error Code 74. And the file size is reduced from 34kb to 100 bytes. Herewith i have attached one good binary file, one corrupted binary file and the VI snippet.

 

Please help me on this.

 

Thanks in advance Smiley Wink

Happy to Wire
0 Kudos
Message 1 of 8
(4,037 Views)

I'm not sure why there may be corruption of the file, can't download your snippet to see the read side of the vi, but can you do a single read into a storage element (an uninitialized shift register, a.k.a LabVIEW 2 global) and then read that data? In the read portion are you reading in the whole file, or are you only reading parts? I try, for many reasons, to avoid lots of reading/writing of files, if only for speed reasons.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 8
(4,031 Views)

Hi,

 

why don't you get rid of that cluster-to-string (and back) conversion?

 

See attachment…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(4,018 Views)

Hi Gerd,

are you suspect flatten and unflatten function?. it was running fine in my other software's.

Happy to Wire
0 Kudos
Message 4 of 8
(3,967 Views)

Read and Write wont comes very frequently. Read takes place when user change file to operate. they will change the file maximum once per a day.

Happy to Wire
0 Kudos
Message 5 of 8
(3,964 Views)

Hi sankar,

 

are you suspect flatten and unflatten function?

No, but the file function can handle clusters on its own. No need for (Un)Flatten and string length handling…

(Most often VIs with less functions are easier to handle/debug!)

 

Can you make sure you never write an undefined (aka "empty") cluster to your file?

Can you make sure you never get any file access errors?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(3,960 Views)

There's no need to set the file pointer to Start, if the file is just opened, that's the default.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 8
(3,953 Views)

Can you make sure you never write an undefined (aka "empty") cluster to your file? - Actually there is no way to write empty data. Because When user create new file i have passed default values in that empty cluster. User change the default values and then save it to hard disk. For my knowledge never empty values passed to the cluster.

Can you make sure you never get any file access errors? - No. Nothing like that.

Happy to Wire
0 Kudos
Message 8 of 8
(3,952 Views)