12-11-2015 01:07 PM
I need to search binary files for specific data messages. These messages begin with "11111111" then follow with some more 8 bit words, one of which defines the length of the following data bits. I am experienced with LabView but not with using binary files. There may be several of these complete "messages" within a single data file. How would I create a simple reading VI for this?
Appreciate the help!
12-11-2015 01:33 PM - edited 12-11-2015 01:34 PM
This 11111111 is a sequence that looks like an integer number of bytes (1 to 8), depending on data format you have written them.
Convert 11111111 to string (1 to 8 elements), read binary data from file into string, search this pattern in read data, format data after pattern as needed. If the file is too large, you can read portions of file.
If this file is a bit sequence and pattern has non-integer byte offset, it is more complicated.
LabVIEW stores boolean arrays 1 byte per element so it does not make sence to work with true bit patterns. I would say - read data as u8, convert each one into 8 bits thenconvert bits into strings (1 string byte per original bit) and search string as previously.
12-11-2015 01:45 PM
That sounds promising. Could you send a picture of how I would create that in Labview? Or the VI?
Thanks!
12-11-2015 02:08 PM
What part is not clear?
Work with file:
Open file -> [Set File position ->] Read from binary file -> Close file
Make pattern string from bit array:
Boolean array to number -> build array -> byte array to string
Work with string:
Search string, string subset (or match pattern)
12-11-2015 04:21 PM
@Gumborg wrote:
I need to search binary files for specific data messages. These messages begin with "11111111" then follow with some more 8 bit words, one of which defines the length of the following data bits. I am experienced with LabView but not with using binary files. There may be several of these complete "messages" within a single data file. How would I create a simple reading VI for this?
You need to be significantly more clear.
"What is "11111111"?
Is it a sequence of 8 bytes, each containing a decimal U8 value of 49 (ASCII for "1") or is it a single byte corresponging to a value of 255?
Can you attach a simple file for testing?
12-14-2015 03:25 PM
I don't have an example file with me from this pc. The value of all ones is the bits (0 or 1) which are set to 8 "1"s in a row to signify new data follows.
12-14-2015 03:32 PM