Binary file with linefeed

Hello
Today, I need to import data from a mixed binary/text file. Structure is
Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf
Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf
Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf
My first attempt was a modified DataPluginExample3.VBS
Sub ReadStore(File)
Dim Block : SetBlock = File.GetBinaryBlock()
Dim Channel1 : Set Channel1 = Block.Channels.Add("Low-Timer",eU16)
Dim Channel2 : Set Channel2 = Block.Channels.Add("High-Timer", eU16)
Dim Channel3 : Set Channel3 = Block.Channels.Add("CrLf", eU16)
Dim ChannelGroup : Set ChannelGroup = Root.Channelgroups.Add("ESR_Timing")
ChannelGroup.Channels.AddDirectAccessChannel(Channel1)
ChannelGroup.Channels.AddDirectAccessChannel(Channel2)
ChannelGroup.Channels.AddDirectAccessChannel(Channel3)
'Kanal 3 ist nur $OD$OA CrLf)
End Sub
Unfortunately, every odd sample, the data are corrupted and then become misaligned. And the beginning of datalogging may not start exactly at a new line.
So I'd like to use the CrLF to re-synch.
How can I mix the ASCII-readline approach with the binary data?
The following does not work: I try to tell the Formatter to use vbNewLine (=CrLf = $0d$0a) to separate lines and use direct access channels with U16 data type. But when using linefeed, apparently the import filter also expects delimiters instead of raw binary values.
Sub ReadStore(File)
File.Formatter.LineFeeds = vbNewLine
File.SkipLine()'Sicherstellen, dass unvollständige erste Zeile ignoriert wird
Dim Block : SetBlock = File.GetStringBlock()
Dim Channel1 : Set Channel1 = Block.Channels.Add("Low-Timer",eU16)
Dim Channel2 : Set Channel2 = Block.Channels.Add("High-Timer", eU16)
'Dim Channel3 : Set Channel3 = Block.Channels.Add("CrLf", eU16)
Dim ChannelGroup : Set ChannelGroup = Root.Channelgroups.Add("ESR_Timing")
ChannelGroup.Channels.AddDirectAccessChannel(Channel1)
ChannelGroup.Channels.AddDirectAccessChannel(Channel2)
End Sub
Thank you for your input.
Michael
Solved!
Go to Solution.

Hi Michael,
I think this DataPlugin does the trick.  I had to ignore any partial first line values in order to preserve the line correspondence of the low and high timer values.  Also note that by default the U16s are read with LittleEndian byte order-- you can change that with File.Formatter.ByteOrder=eBigEndian.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
Attachments:
nimic_LOG.uri ‏5 KB
nimic_LOG.TDV ‏6 KB

Similar Messages

  • I have written a binary file with a specific header format in LABVIEW 8.6 and tried to Read the same Data File, Using LABVIEW 7.1.Here i Found some difficulty.Is there any way to Read the Data File(of LABVIEW 8.6), Using LABVIEW 7.1?

    I have written a binary file with a specific header format in LABVIEW 8.6 and tried  to Read the same Data File, Using LABVIEW 7.1.Here i Found some difficulty.Is there any way to Read the Data File(of LABVIEW 8.6), Using LABVIEW 7.1?

    I can think of two possible stumbling blocks:
    What are your 8.6 options for "byte order" and "prepend array or string size"?
    Overall, many file IO functions have changed with LabVIEW 8.0, so there might not be an exact 1:1 code conversion. You might need to make some modifications. For example, in 7.1, you should use "write file", the "binary file VIs" are special purpose (I16 or SGL). What is your data type?
    LabVIEW Champion . Do more with less code and in less time .

  • Issue in reading a binary file, with 'Flatten to String' data.

    I'm facing issue while reading a binary file (created using LabVIEW).
    I've mentioned everything (issue and method to reproduce it) within the attached VI.
    Same vi is attached in 2012 and 8.0 versions.
    Regards
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.
    Solved!
    Go to Solution.
    Attachments:
    Issue in VI.vi ‏26 KB
    Issue in VI (Version 8.0).vi ‏43 KB

    moderator1983 wrote:
    crossrulz wrote:
    The reading of a string from a binary file stops at a NULL character (0x00).  When the first character is 0x00, you are just reading the one character.  I would suggest writing to a byte array since you are doing the inverting.  And then you can read as a byte array.
    crossrulz:
    U rocks..!!
    you have hit bull's eye...!!
    After playing around a little more, I think I might have misinformed you a little.  If you explicitly tell it a string, it looks for the string length at the very beginning and reads that length of bytes as a string.  It appears that if you implicitly tell it to read a string (not wire the data type) it reads all of the bytes directly, including the length of string you wrote.
    Regardless, my advice is the same.  You should just write and read using byte array.  It is less conversions if you are performing your "encryption".
    EDIT:  Here's a snippet of the VI I was playing with to figure this out.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    String Binary File.png ‏12 KB

  • Can't decrypt binary file with PBE

    Hi,
    I'm writing an simple file transfer application using UDP that encrypts the data
    before sending it with PBEWithMD5AndDES. Text files are encrypted and
    decrypted fine, but binary files such as a JPG/EXE/DOC... are messed up
    and an application can't open them on the other side. Has anyone experienced
    such a problem?
    Thanks

    Below are my encrypt and decrypt functions.
    Thanks in advance.
            public  byte[] encrypt(byte[] data)
                 PBEKeySpec pbeKeySpec;
                 PBEParameterSpec pbeParamSpec;
                 SecretKeyFactory keyFac;
                 ByteArrayOutputStream b=null;
                 DataOutputStream d =null;
                 //      Salt
                 byte[] salt = {
                           (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
                        (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
                 //      Iteration count
                 int count = 1000;
                 // Create PBE parameter set
                 pbeParamSpec = new PBEParameterSpec(salt, count);
                 try{
                      pbeKeySpec = new PBEKeySpec(sessionPassword.toCharArray());
                      keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES","SunJCE");
                      SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
                      // Create PBE Cipher
                      Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES","SunJCE");
                      // Initialize PBE Cipher with key and parameters
                      pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
                      b = new ByteArrayOutputStream();
                      d = new DataOutputStream(b);
                      // create CipherOutputStream
                      CipherOutputStream out = new CipherOutputStream( b, pbeCipher );
                      // write contents to file and close
                      try {
                           for ( int i = 0; i < data.length; i++ )
                                out.write(data);
                             out.flush();
                        out.close();
                   // handle IOException
                   catch ( IOException exception ) {
                        exception.printStackTrace();
              catch(Exception e){}
              return(b.toByteArray());
         public byte[] decrypt(byte[] data)
              PBEKeySpec pbeKeySpec;
              PBEParameterSpec pbeParamSpec;
              SecretKeyFactory keyFac;
              byte[] decryptedData=null;
              //      Salt
              byte[] salt = {
                        (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
                        (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
              //      Iteration count
              int count = 1000;
              // Create PBE parameter set
              pbeParamSpec = new PBEParameterSpec(salt, count);
              try{
                   pbeKeySpec = new PBEKeySpec(sessionPassword.toCharArray());
                   keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES","SunJCE");
                   SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
                   // Create PBE Cipher
                   Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES","SunJCE");
                   // Initialize PBE Cipher with key and parameters
                   pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);
                   Vector fileBytes = new Vector();
                   ByteArrayInputStream b = new ByteArrayInputStream(data);
                   CipherInputStream in = new CipherInputStream( b, pbeCipher );
                   byte contents = ( byte ) in.read();
                   while ( contents != -1 )
                        fileBytes.add( new Byte( contents ) );
                        contents = ( byte ) in.read();
                   in.close();
                   decryptedData = new byte[ fileBytes.size() ];
                   for ( int i = 0; i < fileBytes.size(); i++ )
                        decryptedData[ i ] = (( Byte )fileBytes.elementAt( i )).byteValue();
              catch(Exception e){Gui.chatArea.append("exception:"+e+"\n");}
              return(decryptedData);

  • Binary file with File adapter

    Hi gurus,
    I am getting binary file as base64binary (not a text/xml file) in a request XML tag. I need to write this file to a file directory with the file adapter after retrieving it from the request message by a message/java mapping and use another field in XML as the file name.
    I followed the blog `how to send binary data through PI` but in that case, the request message is also the same. Mine requires a mapping to be executed and in this case I cannot use dummy names for message types/interfaces as Enterprise Repository development is required.
    How can I achieve this?
    Thanks
    Gokhan

    Just solved the problem actually
    As I was trying to write a binary file directly with the receiver file adapter, I wasn't sure how to define a data type / message type for it. I developed a java mapping that decodes the base64 to binary data and writes it to the output stream, and used a dummy message type / data type for the service interface as the target in Operation Mapping
    And it worked!
    Regards,
    Gökhan

  • How to get rid of a binary file with firefox that pop up allthe time?

    each time that i open moxilla firefox a box asking if I want to save or cancel the binary file. I have tried to ignore ti however it has become a bother. How do I stop the box from popping up ?

    Hi
    if you mean http://db.tidbits.com/ - I didn't get any popups in a few minutes of browsing there, this without any blocking software. If you're seeing the very same ad popup window from differing sites, then it'd sure be worth looking at whether or not your mac or router or isp is using some rogue dns server.
    DNS - Domain Name System
    it translates domain names meaningful to humans into the numerical (binary) identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. An often-used analogy to explain the Domain Name System is that it serves as the "phone book" for the Internet by translating human-friendly computer hostnames into IP addresses. For example, www.example.com translates to 192.0.32.10.
    to borrow from wiki.
    DNS servers can be chosen in your router or in your mac at System Preferences-Network-Advanced-DNS tab, If no special dns servers are selected, your router will usually accept the isp's suggestion, so you'll be using theirs, for better or for worse.
    The most common place for any 'rogue' dns to be set, is in System Preferences-Network-Advanced-DNS tab... look there on your mac, and see if any numbers are visible. Copy them & paste here, then we'll know what's going on.

  • Binary file with header

    hi,
    i want to read a binary file in Diadem, which i saved it with Labview. But i didnot get it.
    Could you please help me?
    my header files looks like:
    1 bit double,
    128 bit U8,
    1 bit unsigned word,
    1 bit dbl
    16 bit U8
    64 bit U8
    1 bit u32
    1 bit i32
    and 100 bit Data.(i16)
    Thanks.
    Attachments:
    CH1_07_09_2007_13-31-14.csv ‏1 KB

    Hi Hakan,
    There were several issues with your VI, and the VI bore very little resemblance to the list of binary header items you included in your first post.  I decided to follow the VI instead of the earlier binary header property list.  In the VI, I changed the data type of your channel name property zero-padding from I32 to U8.  I changed the byte order of your binary header to match the byte order of the bulk data (Big Endian).  I also changed the file creation function to "create or replace" so that I culd run the VI multiple times and overwrite the same data file.  The DBL that you are writing from the LabVIEW date/time wire is a geography-specific number of seconds since January 1st 1904 (in Greenwich England).  I added a routine to the DataPlugin to decode this into a DIAdem geography-independent date/time property based on my current location in the Central time zone.  You could instead save a geography-independent DBL in the VI, which would probably be a more robust approach.
    I assigned all the header properties to the Channel level, though you probably want to copy them to the Group and/or the File level as well.  I suspect that the 3 DBL properties have something to do with the I16 channel vertical scaling or else the time scaling (aquisition rate).  We could add that to the DataPlugin as well.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Hakan_S.zip ‏19 KB

  • When I try to download the newest version of Firefox, it pops up with a box saying do you want to save this binary file with something like daimaijin.mirror in the address. Is this a safe thing to do or is it spyware or something?

    If I cancel it and try it again, the same binary file box pops up with a different address.

    Mozilla has download mirror websites around the globe and uses them to "balance" the downloads of Firefox so users don't need to "wait in line" for their download.
    Here's a listing of those mirrors. <br />
    http://www.mozilla.org/community/mirrors.html

  • Upload binary files with Developer Forms

    Hi all,
    I'm newbie with Forms and I don't know if this question is already answered.
    I'm deploying an application involved with blob columns (binary files: pdf, doc, gif, etc) I want to let users to choose files from his PCs (typical "Browse files" button) but I don´t know if this is possible and if yes, how to implement it.
    Anybody can help me?
    My email is [email protected]
    Thanks in advance!
    Cristina

    If you want to upload direct into the database from the client then No you will need a 9i database or above.
    If you want to upload a file from the browser client to the middle tier (Application server) then that will be OK no matter what DB version you are using. Bug of course you'll then need to do the last bit yourself if you want the document / image put into the database.

  • Opening a binary file with the right extension

    Hi everyone,
    I developed a real simple VI that enables me to read the first five bytes of a binary file to get its signature (ASCII) and verify if its signature matches with the expected extensions. If yes, another VI is called, and if not a 2 button message error is displayed : if the User chooses OK, then a new dialog box opens up to pick another file ; and if the user chooses Cancel, the same dialog box opens up rather than escaping the VI.
    It is due to the while loop (VI below) but i don't see how I can handle this without it. Till the user hasn't chosen the right extension, it can't escape which is a problem! The true case consists in calling another VI, and the first step of the stacked sequence consists in displaying a two button error message.
    If you have any ideas, I'm a bit new! Thanks !!
    Solved!
    Go to Solution.

    Thanks for your replies!
    I have tried your solution CoqRouge, filtering the extensions. But it seems that you can choose between different filters when the dialog box opens up, and then choose any kind of extensions.
    @RavensFan : I cannot load the VIs attached in this thread because I am using an older version of Labview
    @MikeS81 : Which negative ouput?
    Attachments:
    ptw_show_do_while.vi ‏20 KB

  • How to upload a binary file with Firefox 7

    Don't know if this is the right forum to ask this - if not, please point me in the right direction.
    I am an embedded developer using Firefox as the user interface to an embedded web server. In the past I've been using file.getAsBinary() to read the local file which is then uploaded with an XMLHttpRequest. Firefox 7 removed the getAsBinary method. Looking through the documentation I came across FileReader and have been trying to use that but with no luck. When I use the readAsBinaryString method, the binary has many bytes which are in error. I have also tried the readAsDataURL but this gives me base64 encoding. Attempts to decode it so far have been unsuccessful. What's the best way to get a local file and upload it to a remote server?
    Thanks,
    Dave

    Well, actually, i have no perfect solution.
    I just used a temporary internal table in which all fields are characters. Then, I used FM GUI_UPLOAD to upload text file including header into this table as usual.
    You can see that it was done successfully. Next, use a loop to transfer this temporary table to the main table. SAP will automatically convert data into values that are compatible with data type in the main table, so don't worry about different types :D.
    In order to make this work more simple, field names of temporary table should be named exactly as same as those in the main one. So, u just use:
    loop at itab_tmp.
      move-corresponding itab_tmp to itab_main.
      append itab_main.
      clear itab_main.
    endloop.
    note: both tables have their own header line, so don't need use a working area here.
    Anyone has any better solution?

  • Processing Binary files with Mapping NOT (always) possible ??

    Hello All,
    I need your help solving this strange behaviour of XI.
    I am developing a (image)file to (image)file interface with a simple mapping but XI is giving unpredictable results.
    Processing the same inputfile e.g. 10 times after each other: results in 6 times OK and 4 times errormessage in SXMB_MONI. After restarting the 4 errormessages sometimes 1 or 2 msg are suddenly processed fine ??!!
    The given error is always: "Parsing an empty source. Root element expected!". But why are the
    other 6 messages are processed OK ? Why not all the 10 messages returns with error ??
    My scenario is :
    1) File FTP Sender: pick up image-files (.gif) from FTP-server (30.000 per day)
    2) XI mapping: A) via Java program convert file into Base64, otherwise no mapping is possible at all
    B) via UDF fill few outputfields only using the inputfilename. There is no need to go "inside" the
    inputfile; just get the filename using Dynamic Configuration.
    3) File FTP Sender: After message processing store the inputfile on the SAP filer in a particular
    directory derived from the filename. Creating the directory and moving the file is done by an OS script in the sender file adapter.
    4) XI Receiver HTTP: after succesfull processing the payload is filled with the correct fields.
    The cause of error is (sometimes) using the DynamicConfiguration in the UDF, but a few fields must be filled using the inputfilename.
    Has someone experienced this before or an other solution/idea to make this scenario stable and robust ??
    Regards,
    Jack

    Jack,
    I may not have understood your scenario in full, however, an alternate solution could be to write a custom XI module and attach it to the file adapter. You could access the file name inside the module as well(See SAP Note 819761).
    You should get a lot of articles/blogs in SDN on custom XI module creation and deployment to the server via NWDS. Give a thought on these lines as well.
    Are you using any third party APIs to base64 encode your files, If so i beleive you will have to include them in the librarries in NWDS and deploy them to the XI server.
    Thanks
    Saravana

  • Upload binary file with DSEEntry

    Hi ,
    I have created a Class for a upload pictures to the IDM Database .
    Now I have the problem with the upload.... and the mssql datatype.
    At the moment the type is binary(max)
    is there any option to add a byte[] to DSEntry.put ?
    It seems that DSEntry always try a cast to string , and when put a byte[] I receive an exception.
    Regards

    Usually binary values are B64 or HEX encoded during processing in IdM. I take it you're trying to write it to a column of datatype binary, not an actual IdM attribute. Perhaps you should use varbinary(max) if you want to exceed 8000 bytes. But, the internal datatypes and the JDBC datatypes are not the same, so for SQL Server you need to use LONGVARBINARY.
    see this MicroSoft reference: Using Advanced Data Types
    Anyway, here's a working example. The $includebin function is documented in the helpfile but its usage is pretty self explaining in my example here:
    My table looks like this:

  • Binary file read with bit offset..not byte offset.

    hi,
               i want to read a binary file with some offset ..not in bytes...  offset in bits..my data is a single bit data stream size of 1GB ,after skipping particular bit offset i want to read the data in byte order..
    Indrajit
    | [email protected] | [email protected] .

    hi , Gerd W 
                       i am not able to follow your answer.... here with i attached a file to describe my query more clearly.   Actually two channels of  1 bit data stream stored in two different files ,and the file size will be more than 10 GB. 
     i want to delay the channel B by 3 bits and i want to perform bitwise operation between channel A and shifted version of channel B..till the end of the data..
    now i am doing this without applying any delay by choosing a small block by block which corresponds to 1 sec of data .
    Indrajit
    | [email protected] | [email protected] .
    Attachments:
    bitwsie.png ‏16 KB
    bitwsie.jpg ‏52 KB

  • Writing binary to file with 24 or 32-bit numbers

    I am using an NI4472 DAQ to sample some analog data at 24-bits and I want to write the data to disk. However LabView only has a VI to write 16-bit data to disk. Is there a way to write 24 or 32 bit binary numbers to a file?

    The VI you are looking at is probably one of the "Easy VIs" that is setup for a specific application. You can create more general programs to write a binary file with any data type you desire. I would recommend taking a look at the Write Binary File example that ships with LabVIEW. It shows a more general approach to writing data to a binary file. In this example they write double precision numbers but you could easily replace the data with I32s.

Maybe you are looking for

  • New HP LaserJet 2600n has washed out colors?

    I just bought an HP Laserjet 2600n. I'm printing out photos and they're horrible because the colors are all washed out while my Samsung CLP-500 prints them perfect. I also noticed half the options are not available to me such as Paper, Color and Dupl

  • Document Printing - Delivery Note and Packaging

    Hi Experts, When I print my Delivery Notes through Document Printing my Packaging Document prints off automatically.  Please can you tell me if it's possible to switch this off so when I print my Delivery Notes through Document Printing only my Deliv

  • SETTING PROPERTIES FOR A MAPPING VIA OMBPLUS ISN'T WORKING (OWB10gR2)

    Hi, i have a problem with OMBPLUS: I have a script which creates a mapping and then is supposed to change properties for the mapping. The script worked in previous releases of OWB but after upgrading to 10gR2 I get an error that DEFAULT_OPERATING_MOD

  • Max no. Of mailboxes defined, delete an existing m...

    Hi there Upgraded firmware 071- and my mail kind of disappeared, when i tried to re-set it, made a mistake with server details, instead of m.google.com, i entered mail.google.com!!! Was unable to connect but seems like MFC recognized that as another

  • Create table as select statement.

    Hello Oracle Gurus, I am trying to create a table using select * from other table. The procedure that I am following is this:- I have a temp table whose signature is on commit delete rows. I insert records in this table. when I do select * from temp_