LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Reading Binary File generated with LabVIEW in MatLAB

Solved!
Go to solution

@Sez wrote:

Do you know how path type being flattened into binary string format?


The short answer is "No, I do not", but that's not very satisfying.  I have three choices -- shrug and "give up" (not very satisfying), "go looking" and maybe find a description that someone has written (which might work, and might even be "definitive"), or "do it myself", which can be fun and informative.  Guess which one I chose ...

 

So here is a little VI that has been saved on my E: drive in my Forum folder under the name Binary Path.vi:

Binary Path.png

What it does is create a Binary File in the same directory holding its Path as both a Path and a String.  I then open the file, look at its contents, and make some guesses.  Here's what I found:

0 .. 3      "PTH0", which I'm guessing is a "flag" for "Path follows"

4 .. 7      00 00 00 1B, or 27 interpreted as a U32, probably a length, not yet sure

8 .. 11    00 00 00  03, or 3 (U32), possibly "number of parts" (Drive, Folder, File)

12          01, or 1 (U8)

13          "E" (the character), the Drive Letter (1 character)

14          05, or 5 (U8) (character count)

15 .. 19  "Forum", first Folder in Path (5 characters)

20          0E, or 14 (U8) (character count)

21 .. 34  "Binary Path.vi", file name.  Note 8 .. 34 is 27 characters, see 4 .. 7

35 .. 38  00 00 00 17, or 23 (U32)

39 .. 62  "E:\Forum\Binary Path.vi" (23 characters)

 

So from this, I'm willing to deduce that Paths are stored (in binary) in the following format:  a Flag ("PTH0"), a 4-byte U32 "storage length", a second 4-byte U32 "path section count" (probably OS-dependent, but in Windows, Drive, optional Folders, and File), then the path sections saved as 1-byte U8 character count followed by a string.  Strings, as we already know, are stored as a 4-byte U32 character count and then the String, itself.

 

There are several ways to confirm this "guess".  The simplest is to write another Binary, but write the String first, then the Path.  I did this, got the same as the above, but with the String first (of course).  Still to be tested are more-than-one folder, no folders, and bare Drive letter.  I'm guessing the "rules" will remain the same.

 

Bob Schor

 

Message 11 of 11
(659 Views)