LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read binary file 10 bytes at a time

Solved!
Go to solution

I want to read binary file in a specific format. There is a number at the starting of the file. That tells us where the data is starting. Suppose it says 3975, then it mean data starts at 3975. Then once I read that location I want to read data at 10bytes at a time and then convert it to numeric and display it on graph. I am attaching the file format and the current vi which I am using. please help.

0 Kudos
Message 1 of 15
(4,962 Views)

To read in 10 bytes, you need to read it as U8 data type and set the count to 10.  You would then need to convert the byte array as needed.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 15
(4,947 Views)

Hi rohan,

 


I want to read data at 10bytes at a time and then convert it to numeric


 

Well, you want to read 10 bytes. But you have programmed to read 4 DBL values with each read operation (which are 32 bytes instead). Why have you done that?

 

Then your PDF says "Convert char to 'unsigned long int' ". You don't do that in your VI. Instead you read DBLs and then you convert those DBLs to ASCII values (which is nonsense!)...

 

Please read your own specs and program only that, what is told by the specs!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 15
(4,946 Views)

Unfortunately I am not very well versed with Labview else I would have done that. Just started to learn. I appreciate your efforts to look in to my problem and reply but your reply was a bit confusing for me. 😞

0 Kudos
Message 4 of 15
(4,940 Views)

Read the help for the Binary Read VI.  You will see that there is a data type input in the top.  Wire a U8 constant there.  You should also see a Count input.  Right click here, create constant, change constant to 10.  The output will turn into an array of U8.  The array should contain 10 elements after reading.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 15
(4,937 Views)

Also if you refer to the jpg image I have sent, It shows there is data from 20 channels. I want to display coupling channel 1 and flaw channel 1 on one graph, coupling channel 2 and flaw channel 2 on second graph and so on up to 10..

0 Kudos
Message 6 of 15
(4,936 Views)

the file I am reading is created and written by a windows CVI program

0 Kudos
Message 7 of 15
(4,933 Views)

That spec doesn't make much sense.  It says to read 10 bytes and convert that array of bytes into a U32.  A U32 is 4 bytes.  So 6 bytes are being thrown away.  And then why would you waste even more disk space with nothingness?

 

Do you happen to have some of the source code of how this file is made?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 15
(4,928 Views)

here is the c code

0 Kudos
Message 9 of 15
(4,911 Views)

Ah, the first 10 characters are a string!

 

After opening the file, use the Read From Text File with count set to 10.  Then use the Decimal String to Number to convert this string into your "record size".

NOTE:  The text indicator was just for debug purposes.  You don't really need it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 15
(4,905 Views)