How to read binary files wrt specific BYTE size and length??

Hello Everyone,
                            I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
i have 30 bytes of sample 1.
followed by 2 bytes of sample 2.
followed by another 2 bytes of sample 3.
steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
How should I do it?? I don't have any VI build... all i have is the example VI...
can anyone pleasehelp me???
Now on LabVIEW 10.0 on Win7

smercurio_fc, sorry for the confusion, i will try my best to explain...
1. No, i don;t have to read the file again, once it has read, I used
while loop just to see the data updating (i press run, and before i can
visualize i have the waveforms; i can get rid of the while loop)
2. I have 30 different values of 1 sample. actually, the data is cmg
from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
30bytes)
3. I am repeating the steps 2-4 10 times because the data was written
into the binary file after 10 times sampling the sensors(if first 3
samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
4. I am using the graphs to interpret the values, that's it. The
values are already scaled when they were wrote to the binary file, I
have to simply interpret it.
I have made some changes in the VI, now i am reading only the first
30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
samples simultaneously on a waveform chart. (will approach 1
sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
Please let me know if it makes sense to you now.
P.S. each sample is a sensor data.
Now on LabVIEW 10.0 on Win7
Attachments:
data_read.vi ‏24 KB

Similar Messages

  • How to read binary file ?

    Hi All,
    I want to read a binary file which has double data. The first byte is an unsigned byte. I have tried using DataInputStream readUnsignedByte method. But then how to convert this value into double.
    int hdop = _data.readUnsignedByte();

    Hi,
    I have managed to read the first byte i.e hdop. I am getting the values of first 2 bytes properly. But the values where I have to read more than 1 byte is creating problem. Can anyone let me know whats wrong in the code?
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.util.Vector;
    public class SBPParser {
         //RandomAccessFile _file = null;
         FileInputStream _file = null;
         DataInputStream _data = null;
         int eofmark = 0;
         public SBPParser(FileInputStream f, DataInputStream d) {
              _file = f;
              _data = d;
         public void parseSBPFile() {
              try {
                        int hd = _data.readUnsignedByte();
                        double douhd = (hd & 0xff) * 0.2;
                        int svid = (_data.readUnsignedByte()) & 0xff;
                        int utcsec = _data.readUnsignedShort();
                        double utcs = (utcsec & 0xff) * 0.001;
                        int utc = Integer.parseInt(utcdatetime);
                        int sec = utc & 0xFC000000;
                        int min = utc & 0x3F00000;
                        int hour = utc & 0xF8000;
                        int day = utc & 0x7C00;
                        int months = utc & 0x3FF;*/
                        int utc = _data.readInt();
                        int sec = utc & 0xFC000000; //For fetching first 6 bits
                        int min = utc & 0x3F00000;  //For fetching next 6 bits
                        int hour = utc & 0xF8000;    //For fetching next 5 bits
                        int day = utc & 0x7C00;   //For fetching next 5 bits
                        int months = utc & 0x3FF; //For fetching next 10 bits
                        int svidlist = (_data.readInt()) & 0xff;
                        int lat = (_data.readInt()) & 0xff;
                        double latitude = lat * 0.0000001;
                        int lon =(_data.readInt()) & 0xff;
                        double longitude = lon * 0.0000001;
                        int alt = (_data.readInt()) & 0xff;
                        System.out.println("Value of Hdop ==> " + douhd);
                        System.out.println("Value of SVIDCnt ==> " + svid);
                        System.out.println("Value of UtcSec ==> " + utcs);
                        System.out.println("Value of seconds ==> " + sec);
                        System.out.println("Value of minutes ==> " + min);
                        System.out.println("Value of hours ==> " + hour);
                        System.out.println("Value of day ==> " + day);
                        System.out.println("Value of months ==> " + months);
                        System.out.println("Value of SVIDList ==> " + svidlist);
                        System.out.println("Value of Latiutude ==> " + latitude);
                        System.out.println("Value of Longitude ==> " + longitude);
                        System.out.println("Value of Altitude ==> " + alt);
                        //_data.skipBytes(31);
              } catch(Exception e) {
                   e.printStackTrace();
         public void print() {
              for(int i = 0; i < hdopVct.size(); i++) {
                   System.out.println("HDOP => " + hdopVct.elementAt(i));
              /*System.out.println("SVIDCNT => " + svidlistVct.elementAt(0));
              System.out.println("UTCSEC1 => " + utcsecVct.elementAt(0));
              System.out.println("UTCSEC2 => " + utcsecVct.elementAt(1));*/
         public static void main(String [] args) {
              try {
                   FileInputStream file_input = new FileInputStream("000000000_GPSLOG_20090605_122548.sbp");
                  DataInputStream data_in    = new DataInputStream (file_input);
                   SBPParser sbp = new SBPParser(file_input, data_in);
                   sbp.parseSBPFile();
                   //sbp.print();
              } catch(Exception e) {
                   e.printStackTrace();
    }Thanks & Regards
    Sunil

  • How to read a file on specific  Directory

    How to read a specific file on specific folder ,
    For ex , in D: contain lot of directory ,
    Let as assume �program �- Directory.
    �xxx.txt�-file,
    How to read �xxx.txt� file from program Directory,
    Give me simple pgm ,

    pradeep.rajadurai wrote:
    How to read a specific file on specific folder ,
    For ex , in D: contain lot of directory ,
    Let as assume �program �- Directory.
    �xxx.txt�-file,
    How to read �xxx.txt� file from program Directory,
    Give me simple pgm ,
    Scanner scan = new Scanner(new File("D:/program/xxx.txt"));
    // your code here[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html]

  • How to read binary file into a 2D float array??

    Hi All,
    I really need help to get this one as I am stuck and can't seem to find any way out of it. I am given a '.dat' file that has float values in it. I want to read this file in java and put it in a 2D float array. The file has basically a matrix of float values. What I want to do is to read this binary file and put all its data into 2D float array (float [] []) so that I can use it in my program. Is there a way to read file like this? I did find a similar matlab code (below) but cant seem to find anything in java and i really want to do this in java only.. I will appreciate ur help in this one.
    thanks very much
    Nitya
    fid = fopen('datafile.dat');
    A = fread(fid,[50 50],'float32');
    fclose(fid);

    I shud have shown the two ways that i Already tried. here they are..
    first one using DataInputStream and then trying to readFloat()
    DataInputStream dis = ....
    Float f = dis.readFloat();This code gives code gives me some random values like this.. (i had a loop)
    5.8758974E-14
    -0.41055492
    1.5724557E-30
    1.06822824E14
    -1.91934371E15
    3.43829601E13
    Other way i tried was this.. which seems right but here i have to convert byte to float and i thnk that code is giving some different results (slightly different float values) not sure why....may be my indexing of the array is wrong to make it a matrix.. or something else...
    is.read(bytes, offset....);
    int cnt = 0;
    int j = 0;
    for (int start = 0; start < offset; start = start + 4) {
      if(j<50){
           myarray[cnt][j] = this.arr2float(bytes, start);
             System.out.println(cnt + "-" + j + " = " + myarray[cnt][j]);
           j++;
    }else{
      if(cnt < 50){
           cnt++;
           j = 0;
      }else{
           break;
    public float arr2float (byte[] arr, int start) {
              int i = 0;
              int len = 4;
              int cnt = 0;
              byte[] tmp = new byte[len];
              for (i = start; i < (start + len); i++) {
                   tmp[cnt] = arr;
                   cnt++;
              int accum = 0;
              i = 0;
              for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
                   accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
                   i++;
              return Float.intBitsToFloat(accum);
    Not sure if i am missing some other way to do this...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to read binary file in developer 2000

    Hi,
    Is there any method through which i can read a binary file(pdf)
    in developer 2000
    Thanks in advance

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to Read a File into a Byte Array??

    I want to make an array of data objects that works as a byffer to write from a file to another file
    do you have any sygestions?

    The way I would do it (if I dont misunderstand your question) is to use FileInputStream to pass in the streaming data source.
    then read the file source to a list object. For example, LikedList.
    then tell the LikedList to transcribe itself to an array of any type, in this case, byte.

  • Scripting: how to read all files in specific subfolders?

    Hello,
    via a Fireworks script (.jsf) I want to get all files in specific subfolders e.g. of "d:\images" to do something with these files (exporting as JPEGs).
    What are these commands?
    Thanks!
    carlos

    You would use Files.enumFiles:
    http://help.adobe.com/en_US/fireworks/cs/extend/WS5b3ccc516d4fbf351e63e3d1183c94988d-7ee8. html
    Aaron
    http://fireworks.abeall.com

  • How to read all files' name in a directory and store in a string array?

    as title

    One possibility is to use the listFiles() method, using recursion if you want the files in the sub-directory also. Check API documentation for java.io.File.

  • How to open and read binary files?

    How do I open and read Binary files?

    Did you  look on The Unarchiver's web site where it has a link to older versions? http://theunarchiver.googlecode.com/files/TheUnarchiver3.2_legacy.zip
    The best thing to do is ask your friends what programs they used to produce these files, or at least what format files they are producing.  Otherwise it's like being shown a car and given a bundle of 200 keys with no idea to which one to use, or even if any of them work with that car.
    Using The Unarchiver will likely not do anything because it too will not know what format files are involved, and they may not even been in an archived format.  If they sent you a Word file without telling you (a favorite of Windows users to do  -- it drives me crazy when they could have just sent them in plain text), The Unarchiver won't open them.  If it's a picture file then using Hexedit will just show you a bunch of unintelligible stuff as shown in an earlier post, though you may see a line of text providing a hint.
    As I said earlier, often .bin may be an executable program which needs another program to actually interpret it.  That's what Java is trying to do.  Still, it may think it can execute the file, but it is highly unlikely somebody would send you an executable program (and if they did I would not trust it).  For all you know it may be a Windows virus.

  • Read binary file 10 bytes at a time

    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.
    Solved!
    Go to Solution.
    Attachments:
    topo.zip ‏89 KB

    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.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Read record size.png ‏12 KB

  • Reading binary files

    Hi
    I need some help in reading binary files. This is the code I have so far.
    import java.io.InputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    public class patternmatch {
         public static void main (String[] args) {   
              final byte[] bytes = new byte[1];
              try {     
                   final InputStream  instream = new FileInputStream  (args[0]);
                   while (true) {
                        final int count = instream.read (bytes);
                        if (count==-1) break;
                        System.out.println(bytes);
                   instream.close();       
              } catch (IOException e) {
                   System.err.println(e);         
    }Instead of a list of hexadecimal numbers that I want I get a long line of
    [B@eee36c
    [B@eee36c
    [B@eee36c
    [B@eee36c
    Which represents some address I think.
    Does anyone know how to extract the hexidecimal numbers?
    Thanks
    Charles

    double post http://forum.java.sun.com/thread.jsp?forum=31&thread=558802

  • How to read xml file as shown below.

    Hello,
    I am using flash builder 4 and currently working on implementing AIR application.
    I need to read xml file data.
    Normal xml files are easy to read and i am much more aware of it.
    But can any one have idea how to read XML file which is given below.
    <node>
    <key>ID</key>
    <integer>1</integer>
    <key>Name</key>
    <string>Dhwani</string>
    <key>Postno</key>
    <integer>20</integer>
    <key>deskname</key>
    <string>flex</string>
    <key>empid</key>
    <integer>25</integer>
    <key>projectname</key>
    <string>abc</string>
    </node>
    Here i have xml file in form of key value pair. <key> node shows name of the key and after that <integer> or <string> node are the value for that specific key.
    if i select node.key then it shows me all the keys. and from that i cant make out what is the value for key ID.
    Is there any way to take first node and then second. i mean first i ll take value of key and store it into some arraycollection. and then value will be stored.
    Any help is appreciated.. Looking for positive reply.
    Thanks
    Dhwani

    There are different methods to access XML data which have pro's and cons. Let us know more about what you want to do and we can help you.

  • Labview 8.2 Read Binary File, no pos offset option anymore?!

    I have a VI that worked perfectly well in 7.1 and now I've opened it in 8.2 it doesn't work and I can't revert back to 7.1 because I accidently pressed save.
    In 7.1 I used the combination of open, read and close file functions to read parts of a large binary data file - I cannot read the whole file into Labview 8.2 as it fills the memory. There isn't a terminal in the 'read binary file' function in 8.2 for 'pos offset' which is what I used to use in 7.1. How am I supposed to open the file now? Surely they have not removed such a useful facility entirely - is there another way to do it that I am not aware of?
    Many thanks in advance for help,
    Sarah

    smercurio_fc wrote:
    André, at first I could not understand your response, ...
    Must be my Dutch way of writing English
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • How to read Raw files with PS CC

    I installed ps and bridge cc - the programs cannot read raw files (canon 5d mk III and Sony Nex 6). How to fix?

    http://forums.adobe.com/community/bridge
    http://forums.adobe.com/community/photoshop
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

Maybe you are looking for

  • Good old IE 6!!!

    Good old IE 6, still a solid 25% of people using it and still doing my head in! Could you take a look here in IE6: Website Here Problem is #sidebar1 is not floating correctly and pushing my #mainContent down the page. Can you help. Thanks, Richard

  • Error in c project accounting

    Dear plm consultant, I am facing problem in c project costing . when i go for calulate the cost, i get following error. <b>Error occurred in accounting - see controlling cockpit (cProjects) Message no. DPR_FIN_GECCO024</b> Diagnosis Errors occurred w

  • Rotating components and text

    Is there a way to rotate components and pieces of text in the AWT? In other words: is it possible to turn a button or label on it's side or to paint a string onto screen so that the base line is vertical? thanks very much

  • Need to save the query under the correct role

    Hi Experts, I need to save the query under the specific role. So is there anyway to find the query location by role?? Thanks Regards, Arpan

  • Select records with in a given range

    Hi Team, I've very urgent requirement. I urge please help as soon as possible I've two table like below Subscriber Table SID Sub_StDate Sub_Enddate 101 05-jan-2014 28-mar-2014---SET S1 101 01-apr-2014 29-june-2014---- S2 101 01-Aug-2014 14-dec-2014--