Reading 10 bits at the time?

Hey!
I'm currently working on a program reading files where the word-size varies from 4 to 16 bits and for instace 10 or 12 bits/word are common. Tried to search around the forum for a solution on how to read these files properly, but couldn't really seem to find anything that concerned this particular issue. So I'm wondering if any of you guys out there have a reasonable solution to the problem. The files are rather large (20+mb), so I'm hoping for something that doesn't need to do too much math on the file..
Cheers
Slafs

What's the purpose of your reading? If you just copied the data, you wouldn't have to care.
Do you know beforehand how long the next word will be? - In case you have fixed data structures in the file. Reserve an int as shifting space and another that counts the number of unconsumed bits within it. Read a byte at a time whenever the number of valid bits gets low and shift it in from the right or the left according to the endian of the file coding. Well, the whole math is shifting and counting. But make sure you use some buffered way to read the file unless you hate performance.
If your file contains some code where the lengths of the words are encoded within the words themselves (Huffman and the like), the math is is little more complicated. You will need to build some type of state machine, which sequentially looks at chunks of bits. From the current state and the next chunk read you determine how many bits of the chunk you consume and if the next word has been completed by these bits.

Similar Messages

  • How to read bits from the file?

    Hello everybody,
    I'm beginner in LabVIEW. I need to get bits from the file, but I don't know how I can do it. I use the example "Read Binary File VI" from LabVIEW Help, but it returns DBL array. And for a long time I can't find a solution to convert this array to array of bits.   Can somebody help me? Thanks in advance. 
    Solved!
    Go to Solution.

    tranonim wrote:
    Hello everybody,
    I'm beginner in LabVIEW. I need to get bits from the file, but I don't know how I can do it. I use the example "Read Binary File VI" from LabVIEW Help, but it returns DBL array. And for a long time I can't find a solution to convert this array to array of bits.   Can somebody help me? Thanks in advance. 
    You can pass in the type into the Read Binary File VI to get the data in whatever form you want.  Just remember that a boolean is really 8 bits.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Screen stuck zoomed in a little bit all the time.

    There seems to be no catalyst for this situation as far as an update or anything, but my iPhone 3GS just started zooming in a little bit on the screen bringing the apps to the very edge of the screen and blocking off the options in apps like iPod and iTunes that have menu options displayed across the bottom. I have reset it, restored it, turned it off and on (repetitive, I know) and tried to find anything related in the settings, but so far am unable to get it to stop cutting off the frame of the screen.
    Any ideas?

    Probably the zoom feature.
    You can learn about it in the manual:
    http://manuals.info.apple.com/enUS/iPhone_iOS4_UserGuide.pdf

  • Why have my yahoo emails suddenly started to fail to open yet the timer icon keeps spinning?

    Why have my yahoo emails suddenly started to fail to open? Up until last week, no problems, now they appearing the inbox, but, I can't open to read them, yet the timer icon continues to spin!

    Hi jeanmcdiarmid,
    Thanks for visiting Apple Support Communities.
    See this article for some troubleshooting steps that you can try on an iOS device or Mac:
    iOS: Unable to send or receive email
    http://support.apple.com/kb/ts3899
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/TS3276
    All the best,
    Jeremy

  • Running a mid 2009 iMac on 10.7.5, 3 gb memory, 320 gb hd.    Suddenly the computer stoped reading DVDs and the only time I can read a CD is if I restart.  Quite often when I insert a CD it gets stuck and I cannot get it out until I restart and it shows u

    Running a mid 2009 iMac on 10.7.5, 3 gb memory, 320 gb hd. 
    Suddenly the computer stoped reading DVDs and the only time I can read a CD is if I restart.  Quite often when I insert a CD it gets stuck and I cannot get it out until I restart and it shows up on the desktop where I can then eject it.
    I have checked and double checked the finder prefs and all looks normal showing a check mark on CDs,DVDs etc. (the ones I want to show up on the desktop)
    I have reset the PEAM, repaired permissions with both the disk utility on the computer and the disk utility when I start up in the Recovery Disk.  I did notice that sometimes the permission repeat the same correction several times before it moves on, and sometimes it doesn’t. I have Windows installed on a partition but I keep it unmounted until it is needed for my wife’s work.  The dock seems to be just fine and all the apps seems to run just fine.  When I insert a photo CD iPhoto does not open but when I insert a music CD iTunes does open. 
    Also, most every time I open iPhoto it takes a long time(sometimes as long as 2 minutes) for it to load.
    Sometimes my Mail (Mail 5.3) does not post new mail but most of the time it does. 
    Once and a while it seems like the computer slows way down but then it seems ok ten minutes later.
    All  of these ‘things’ seemed to have happen suddenly and I have not downloaded anything from the internet in some time.
    Of course the warranty and extended warranty are both no longer in effect having had this computer for more than three years.
    I am running Java and Adobe Player because some of the sites I go to a lot require both.

    I believe that insufficient RAM may be the source of some of your problems. If you have a RAM of somewhere 4 to 8GB, you will experience smoother computing. 3GB doesn't seem right, so you might want to learn more by going to this site:
    http://www.crucial.com/store/drammemory.aspx
    I don't know what know what's happening with your optical drive, but it seems you use your drive quite a bit. In that case, look into a lens cleaner for your machine. It's inexpensive, works quite well.
    I hope you'll post here with your results!

  • I am using Windows 7 Home Premium 64-bit OS.  I've never had this problem before... today I opened iTunes and it prompted me to download the newest version.  I use iTunes all the time and have updated it multiple times with no issues.  During the installa

    I am using Windows 7 Home Premium 64-bit OS.I've never had this problem before... today I opened iTunes and it prompted me to download the newest version.  I use iTunes all the time and have updated it multiple times with no issues.  During the installation process it gave me an error message that said: 
    Runtime error! 
    Program C:\Program Files\iTunes.exe
    R0634
    An application has made an attempt to load the C runtime library incorrectly.
    Please contact the application's support team for more information.
    I quit the installation, uninstalled iTunes and rebooted my computer.  I now receive a similar message with a slight difference:
    Runtime error! 
    Program C:\Program Files (x86)...
    R0634
    An application has made an attempt to load the C runtime library incorrectly.
    Please contact the application's support team for more information.
    I did not leave anything out from the error message.  It doesn't point to a specific file, it just ends with "(x86)..."  Every time I boot up my computer, this error message pops up on my desktop.
    How do I repair this issue?  I have found multiple suggested solutions but am unsure which one is the best, and I don't want to try a bunch of different things for fear I may make the problem worse.  I would like to try and fix this myself if possible but I need to know if that is really possible or if I need to take my computer to someone for repairs.  Any suggestions will be greatly appreciated!!

    Hi lustyln,
    I'm having a little trouble understanding all of what you are trying to explain. From what I can tell, it sounds like your PC has a lot of software problems and you want to know what is supposed to be there and what isn't.
    For reference, here are your product specifications:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c01893242&lc=en&product=4043282
    To get your PC software back to how it was when it was first purchased, run a system recovery:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c01867418&lc=en&product=4043282
    I hope this helps.
    ...an HP employee just trying to help where I can, but not speaking on behalf of HP.

  • How to read 16 bits at a time from a file.

    Hi everyone:
    I have a homework problem that requires me to read from a file 16 bits at a time, which is a signed value. I have tried using the code below:
    try     {
         FileInputStream fis = new FileInputStream(fileName);
         DataInputStream dis = new DataInputStream(fis);
         System.out.println("Reading "+fileName+"...");
         int x,y;
         bytes = new int [];
         for(y=0;y<height;y++)      {
              bytes[y] = dis.readByte();
              dis.close();
              fis.close();
              System.out.println("Read "+fileName+" Successfully.");
         } // try
         catch(Exception e)      {
              System.err.println(e.getMessage());
              System.exit(1);
    But this code only reads a byte at a time, I need to read 16 bits at a time. Does anyone have any ideas?
    Any help is greatly appreciated.
    Celia

    DataInputStream has another method that does what you want.

  • Send 102 bit data through the LPT port??I have to send 102 bit to my interface board using the LPT port, through one of the data line and be able to read data from the input line, I don't know how to realize such a task.Thanks

    Let me describe you the program I have to write:
    I have to send 102 bit serialy using one of the data line of the LPT port to a device and be able to read back data sent from a device register throug one one of the input port pin for instance pin 10 of a DB25, and synchronize the transmission by the PC clock(for write and read). If fact I am using 5 output control(D0...D4) signal from the LPT port, RST, TXD, CLK, CE,TEST, one input data RXD (pin10)
    So the program should work in normal mode (write data, read data), and test mode (use the write p
    rocedure). Since I am quite new in Labview I am little lost and I need some support or exemple that use a way to send more than 32 bit via one data line(in my case 102bit= 8 bit COMMAD(MSB)+88 bit SPI DATA+6 bits CRC(LSB)) and be able to read them back, place them in the register and be able either to monitor or modify them.
    I know that there are plenty of exemple but if I can gain time by being helped it would be great.
    Can you please advise?

    Hi Beni,
    find attached a SPI.vi - minor changed from one of
    my typical SPI's (LabVIEW 7.1). With some simple changes it will fit to your application.
    The only thing you need to do - prepare
    the bits for the input-array.
    If you need some more comments - find one of my email
    adresses in documentation of this vi.
    Regards
    Werner
    Attachments:
    102bit_SPI.zip ‏90 KB

  • Urgent: Please help. how to solve the time delay during buffer read and write using vc++

    I need to continuously acquire data from daqmx card, write into a file and at the same time corelate (in terms of time) the data with signals from other instruments. The current problem is that there is time delay during read and write data into buffer,thus causing misalignment of the data from multiple instruments. Is there a way to solve  the delay? or Is there a way to mark the time of the data acquisition in the buffer?  If I know the starting time (e.g. 0) of data acquisition and sampling rate (e.g. 1kHz), can I simply add 1ms to each data sample in the buffer? The current code is shown below.
    void DataCollectionWin::ConnectDAQ()
    DAQmxErrChk(DAQmxCreateTask ("", &taskHandle));
        DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
      DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));
      DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,50,0,EveryNCallback,NULL));// Every 50 samples the EveryNSamplesEvent will be trigured, to reduce time delay.
      DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
      DAQmxErrChk (DAQmxStartTask(taskHandle));
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
     DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,NULL));
       //memcpy(l_data,data,6000);
      SetEvent(hEvent);
    l_usstatus_e[0]=g_usstatus[0];// signals from other instruments that need to be corelated with the data from daq cards.
     l_optstatus_e[0]=g_optstatus[0];
     if( read>0 ) // write data into file
       //indicator=1;
     for (i=0;i<read;i++)
     {  //fprintf(datafile,"%d\t",i);
      fprintf(datafile,"%c\t",l_usstatus_s[0]);
      fprintf(datafile,"%c\t",l_usstatus_e[0]);
            fprintf(datafile,"%c\t",l_optstatus_s[0]);
      fprintf(datafile,"%c\t",l_optstatus_e[0]);
              fprintf(datafile,"%.2f\t",data[15*i]);
     //   sprintf( pszTemp, "%f", data[6*i]);
     // pListCtrl->SetItemText(0, 2, pszTemp);
        //pWnd->m_trackinglist.SetItemText(0, 2, pszTemp);
         fprintf(datafile,"%.2f\t",data[15*i+1]);
         fprintf(datafile,"%.2f\t",data[15*i+2]);

    Hello kgy,
    It is a bit of a judgment call. You should just choose the board that you think has the most to do with your issue. For example, this issue was much more focused on setting up your data acquisition task than the Measurement Studio environment/tools, so the MultifunctionDAQ board would have been the best place for it. As for moving your post to another board, I do not believe that is possible.
    Regards,
    Dan King

  • Have a question to ask ... I bought, at the time, the update of Adobe Audition CS6, being already in possession of the CS5.5 version. Since I had to redo the operating system (windows 7 professional 64-bit), reistallando program CS6, with the correspondi

    have a question to ask ... I bought, at the time, the update of Adobe Audition CS6, being already in possession of the CS5.5 version. Since I had to redo the operating system (windows 7 professional 64-bit), reistallando program CS6, with the corresponding serial number in my possession, I noticed a malfunction that is:
    importing a musical motif and starting the program, clicking on play, I do not play any pattern or song despite being in operation.
    I reinstalled the program, but without any result. What do I do? Thanks.

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • My notification center (windows 7 64 bit) disappear from time to time, any idea? (When it disappears, I cannot use the special keyboard functions like sound...

    My notification center (windows 7 64 bit) disappear from time to time, any idea?
    When it disappears, I cannot use the special keyboard functions like sound,brightness...
    Thanks!

    How is Acrobat 8 not fully Windows 7 compatible?  I see discussions on this Adobe Community saying how Acrobat 8 does work on Windows 7 and with 64-bit.  It appears that if Acrobat 8 is updated to the latest version, then this should fix AA8-Win7 issues.  And I am at the latest AA8 version, 8.3.1. 
    And how are Acrobat 8 and Reader XI are not compatible?  I have always had Acrobat and Reader installed on the same PC, without ever having any issues.  And Adobe allows the installation of one after the other.  So apparently Adobe allows them both to exist together.  If they are incompatible, then why would Adobe allow them to exist together? 
    Anyway, I did uninstall the FileOpen Plug-in and the Reader XI, then reinstalled the FileOpen Plug-in.  So now Reader is not installed and only Acrobat 8 is installed.  I then tried to load the PDF file, but I still get the Acrobat 8 error described above. 

  • Some times when I press the home button to read my finger the screen becomes black and it shows the Apple logo, this take a few seconds to get back the screen and this has been happening even 3 or 4 times in a row!   What should I do?

    Some times when I press the home button to read my finger the screen becomes black and it shows the Apple logo, this take a few seconds to get back the screen and this has been happening even 3 or 4 times in a row!
    What should I do?

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Try each of these in order until the issue is resolved.

  • The built-in dictionary on my iPad only works with certain sites.  What do I need to do so that I can it all the time. (For example, it does not work when I read e-newspaper.)

    What do I need to do so that I can use the built-in dictionary all the time? My iPad 2's dictionary functions on Japanese e-newspapers but not on the Arizona Republic or other e-newspapers.

    Rikirannu wrote:
    My iPad 2's dictionary functions on Japanese e-newspapers but not on the Arizona Republic or other e-newspapers.
    Are you talking about the English dictionary?  Mine seems to work ok on the AZ republic web page.  Does yours not work on all webpages?  Does it not work when you type an English word in Notes and then do select and define?

  • My windows(8.1 64bit) partition is read only from the mac(yosemite) side of things. Anybody have a clue on how to fix this? Also, slightly frustrating as well, windows crashes every time I attempt to open a file from the mac partition.

    my windows(8.1 64bit) partition is read only from the mac(yosemite) side of things. Anybody have a clue on how to fix this? Also, slightly frustrating as well, windows crashes every time I attempt to open a file from the mac partition.

    All Office applications will also try to open a temporary work file in the same location as the source file. This implies the source file directory also needs to be writable for this temporary file. Since the default HFS+ driver provides only read-only access, such temporary files will fail to open, and will cause the application to fail.
    As a test copy the file you want to edit, say an Excel spreadsheet from the OSX file system to the C: drive on the Windows side and try to open it. If you look in this directory, you should see two files, the source and a temporary file. You may have to force the temporary file to be opened on a read-write file system, by manipulating the folder for temporary files.

  • Is there a way to enter an event time in Calendar as a reminder for me and NOT have Calendar erase it in the info as it reads it into the event start and end times?

    Calendar can recognize and derive event start and end times from the text description entered.  However, when it seizes on a time (start and/or end) and automatically enters it as the start and/or end time, it also (sigh) deletes the time from the text.  I enter the times as reminders for me, how can one prevent them from being deleted by Calendar??

    I am having the same darn problem. I really dislike this auto feature in Calendar.
    Can anyone help us please?

Maybe you are looking for

  • Error running utility "Maintain database triggers to circumvent mut tab"

    Hi, I succesfully runned the utility to create the table package, but when running the database triggers utility I receive: Message Activity aborted with ORACLE internal errors. -6502 ORA-06502: PL/SQL: numeric or value error: number precision too la

  • Close popup window

    Hi experts, There is a popup window, with two button: SAVE CANCEL. i create the popup in this way: lr_popup = lr_window_manager->create_window(     modal               = abap_true     window_name         = 'WND_POPUP'     title               = lv_tex

  • How to know the DB objects using the particular tablespace

    Hi All I have tablespace which is used by different database objects. I want to know which objects are using that tablespace. How can I know this?? Thanks

  • Apple Remote with iPod Touch or Nano

    My father has an iPod Nano right now and is going to be getting an iPod Touch in the next few months. So, one of the items we got him was the Apple Remote (aluminum with black buttons) I CAN NOT get it to work. Does it work with the Nano??? If not, d

  • Busco solución para RTL8187 Wireless LAN Adapter de Realtek

    Tengo una antena realtek externa (RTL8187) y desde que he actualizado a mountain Lion no abre la aplicación, al parecer parece que el programa no soporta un software de 64 bits, solo necesito saber si alguien conoce algún otro driver de realtek (aunq