Conversion of a binary data stream to decimal numbers

Hi
I am having great difficult working out how to convert my binary data stream to decimal numbers.
The data I am reading back is in the format of a binary string, starting with the Most Significant Bit (MSB) of the first word, then the corresponding Least Significant Bit (LSB), where a word is two bytes long. A carriage return indicates message termination.  The return message starts with ‘bin,’ followed by the number of bytes requested. No delimiters are used to separate the data, but a carriage return is appended onto the end of the data.
bin,<first word msb><first word lsb>...<last word lsb><CR>
e.g. bin,$ro¬z1;@*...etc
Does anybody know of any examaple vi that can help me convert this data from binary to decimal numbers?
Many Thanks
Ash

Hi Ashley,
after getting the string you can strip the first 4 characters. After this try a typecasting to array of U16. If the numbers are not correct, you can add a swap bytes operation to the resulting array.
Message Edited by GerdW on 09-13-2006 02:46 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
Convert.png ‏2 KB

Similar Messages

  • PbyFwData - Pointer to the firmware binary data stream.

    Hello,
    I used labview to call a dll, but it have one parameter "pbyFwData" which Pointer to the firmware binary data stream.i don't understand what mean is "Pointer to the firmware binary data stream".I try to make this parameter point to the firmware path, but the program can't be run.the below is the .dll source code. who can tell you how to pass the value to the parameter "pbyFwData" by labview?
    // Purpose:      Public function to download the Flash Preloader.
    // Parameter:
    //   hZvDev    - Handle of the Zeevo Device.
    //   pbyFwData - Pointer to the firmware binary data stream.
    //   uFwLen    - The length of the preloader.
    // Return value: SUCCESS if successful; Otherwise, the error code.
    ZEEVOPTU_API int ZV4301_SendPreLoader(HANDLE hZvDev,
                                          unsigned char *pbyFwData,
                                          unsigned long uFwLen)
       ZV4301 *pZvDev;
       COMM_DESC *pPort;
       int nResult, nTmOut;
       const unsigned long uBlkSize = 0x400;
       unsigned long uDummy, uCRC;
       unsigned char byDataBuf[32];
       unsigned char byData;
       if (!Validate(hZvDev))
          return ERR_BAD_HANDLE;
       pZvDev = (ZV4301 *)hZvDev;
       pPort = pZvDev->PortDesc;
       // Setup the Address and Length
       memset(byDataBuf, 0, sizeof(byDataBuf));
       LD_LoaderProgramAddr(byDataBuf) = LD_ZV4301_LOADER_ADDR;
       LD_LoaderProgramLengh(byDataBuf) = uFwLen;
       // Calculate the Header CRC
       uCRC= UT_CRCBuffer(byDataBuf+4, 8);
       LD_LoaderProgramHdrCRC(byDataBuf) = uCRC;
       // Calculate the Data CRC
       uCRC = CalculateCRC(pbyFwData, uFwLen);
       LD_LoaderProgramDataCRC(byDataBuf) = uCRC;
       // Detect target reset
       nResult = IsChipPwrOnReset(pZvDev, 10000);
       if (nResult != SUCCESS)
          return nResult;
       // send out header first
       nResult = WriteSerial(pZvDev, byDataBuf, LD_LOADER_PRGM_HDR_LEN);
       if (nResult != SUCCESS)
          return nResult;
       while (uFwLen > 0)
       {  // sending the preloader file
          if (uFwLen >= uBlkSize)
             nResult = WriteSerial(pZvDev, pbyFwData, uBlkSize);
             pbyFwData += uBlkSize;
             uFwLen -= uBlkSize;
          else
             nResult = WriteSerial(pZvDev, pbyFwData, uFwLen);
             uFwLen = 0;
          if (nResult != SUCCESS)
             return nResult;
       nTmOut = 100;
       while (nTmOut > 0)
       {  // getting the respond 0xAA
          if (GetByte(pZvDev, &byData))
             if (byData == 0xAA)
                break;
          Sleep(10);
          nTmOut -= 10;
       if (nTmOut == 0)
          return ERR_DOWNLD_PRELDR;
       nResult = SetCommBaud(pZvDev, FLOWCTRL_DIS, pPort->uBaud, &uDummy);
       return nResult;

    Hi,
    The pointer is a U32 that points to a memory location where the data is. It is not clear from the prototype whether the pointer points to data that is feeded to the dll, or returned from the dll.
    If data is feeded, wire an array to this parameter, and set uFwLen to it's length.
    If data is returned, you need to use some other api calls to get the data from memory...
    Regards,
    Wiebe.
    "Jimmy168" <[email protected]> wrote in message news:[email protected]...
    Hello,I used labview to call a dll, but it have one parameter "pbyFwData" which Pointer to the firmware binary data stream.i don't understand what mean is "Pointer to the firmware binary data stream".I try to make this parameter point to the firmware path, but the program can't be run.the below is the .dll source code. who can tell you how to pass the value to the parameter "pbyFwData" by labview?
    &nbsp;
    //------------------------------------------------------------------------------// Purpose:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Public function to download the Flash Preloader.// Parameter://&nbsp;&nbsp; hZvDev&nbsp;&nbsp;&nbsp; - Handle of the Zeevo Device.//&nbsp;&nbsp; pbyFwData - Pointer to the firmware binary data stream.//&nbsp;&nbsp; uFwLen&nbsp;&nbsp;&nbsp; - The length of the preloader.// Return value: SUCCESS if successful; Otherwise, the error code.//------------------------------------------------------------------------------ZEEVOPTU_API int ZV4301_SendPreLoader(HANDLE hZvDev,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned char *pbyFwData,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned long uFwLen){ &nbsp;&nbsp; ZV4301 *pZvDev;&nbsp;&nbsp; COMM_DESC *pPort;&nbsp;&nbsp; int nResult, nTmOut;&nbsp;&nbsp; const unsigned long uBlkSize = 0x400;&nbsp;&nbsp; unsigned long uDummy, uCRC;&nbsp;&nbsp; unsigned char byDataBuf[32];&nbsp;&nbsp; unsigned char byData;
    &nbsp;&nbsp; if (!Validate(hZvDev))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ERR_BAD_HANDLE;&nbsp;&nbsp; pZvDev = (ZV4301 *)hZvDev;&nbsp;&nbsp; pPort = pZvDev-&gt;PortDesc;
    &nbsp;&nbsp; // Setup the Address and Length&nbsp;&nbsp; memset(byDataBuf, 0, sizeof(byDataBuf));&nbsp;&nbsp; LD_LoaderProgramAddr(byDataBuf) = LD_ZV4301_LOADER_ADDR;&nbsp;&nbsp; LD_LoaderProgramLengh(byDataBuf) = uFwLen;&nbsp;&nbsp; // Calculate the Header CRC&nbsp;&nbsp; uCRC= UT_CRCBuffer(byDataBuf+4, 8);&nbsp;&nbsp; LD_LoaderProgramHdrCRC(byDataBuf) = uCRC;&nbsp;&nbsp; // Calculate the Data CRC&nbsp;&nbsp; uCRC = CalculateCRC(pbyFwData, uFwLen);&nbsp;&nbsp; LD_LoaderProgramDataCRC(byDataBuf) = uCRC;&nbsp;&nbsp; // Detect target reset&nbsp;&nbsp; nResult = IsChipPwrOnReset(pZvDev, 10000);&nbsp;&nbsp; if (nResult != SUCCESS)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return nResult;&nbsp;&nbsp; // send out header first&nbsp;&nbsp; nResult = WriteSerial(pZvDev, byDataBuf, LD_LOADER_PRGM_HDR_LEN);&nbsp;&nbsp; if (nResult != SUCCESS)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return nResult;
    &nbsp;&nbsp; while (uFwLen &gt; 0)&nbsp;&nbsp; {&nbsp; // sending the preloader file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uFwLen &gt;= uBlkSize)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nResult = WriteSerial(pZvDev, pbyFwData, uBlkSize);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pbyFwData += uBlkSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uFwLen -= uBlkSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nResult = WriteSerial(pZvDev, pb

  • [svn:osmf:] 14486: Add stream metadata support by extracting the actual metadata object from the binary data stream .

    Revision: 14486
    Revision: 14486
    Author:   [email protected]
    Date:     2010-03-01 14:27:41 -0800 (Mon, 01 Mar 2010)
    Log Message:
    Add stream metadata support by extracting the actual metadata object from the binary data stream.
    Fix bug 466
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/ManifestParser.as
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/Media.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/HTTPStreamingUtils.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FIndexHandler.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FStreamInfo.as

    same problem, data not replicated.
    its captured,propagated from source,but not applied.
    also no apply errors in DBA_APPLY_ERROR. Looks like the problem is that LCRs propagated from source db do not reach target queue.can i get any help on this?
    queried results are as under:
    1.at source(capture process)
    Capture Session Total
    Process Session Serial Redo Entries LCRs
    Number ID Number State Scanned Enqueued
    CP01 16 7 CAPTURING CHANGES 1010143 72
    2. data propagated from source
    Total Time Executing
    in Seconds Total Events Propagated Total Bytes Propagated
    7 13 6731
    3. Apply at target(nothing is applied)
    Coordinator Session Total Total Total
    Process Session Serial Trans Trans Apply
    Name ID Number State Received Applied Errors
    A001 154 33 APPLYING 0 0 0
    4. At target:(nothing in buffer)
    Total Captured LCRs
    Queue Owner Queue Name LCRs in Memory Spilled LCRs in Buffered Queue
    STRMADMIN STREAMS_QUEUE 0 0 0

  • Convert between binary and signed/unsigned decimal numbers

    Hi all,
    Has anyone written a code to convert:
    binary number --> signed decimal
    binary number --> unsiged decimal
    signed decimal --> binary
    unsigned decimal --> binary
    Please help! I'm confusing.

    http://java.sun.com/j2se/1.4/docs/api/java/lang/Integer.html
    See the methods parseInt and toBinaryString.
    Please help! I'm confusing. You are, aren't you?
    (Sorry, couldn't resist...)

  • Conversion of Packed Decimal Numbers to Java Data Types

    Hi all,
    I'm working with a mainframe file which contains datas in Packed Decimal Numbers.My requirement is to convert these datas to Java datatypes and also to convert the Java datatypes to Packed Decimal Numbers before storing them in the mainframe.
    Can anyone help me out with any code for converting Java data types to/from other data formats such as: EBCDIC, IBM370 COMP (binary numbers up to 9 digits), and COMP-16 (packed decimal numbers)?
    I would hugely appreciate any response to my query.
    Thanking you all,
    Kaushik.

    Rather than go that route, I'd instead look into providing a "service" on your mainframe to:
    1) provide a textual representation of the numbers (from native to text)
    2) read text, converting to native numeric storage
    And use that service to retrieve that information by your Java app (1)Similarly, instead of trying to write natively-formatted numbers from your Java app, I'd write it as text and make that same "service" read the text (2)
    This is the kind of thing XML is for.

  • ABAP XSL mapping - Binary data of attached file

    I have a webservice which is converting attachment and putting it into XSLT Node. when I mapped this node to Attachment payload of my partner (using ABAP xsl mapping), I got an error.
    I was able to send the same file via SOAP UI...
    On further investigation of the http log files, I noticed that Binary data for both streams looked same, but when I did a word count, I noticed that SOAP UI was a single line file while my PI data was more than 400 lines.. so I coded a fn:transfer of this data to convert end of line character to empty value. it did seem to work...
    My question, is this approach correct? or is there any way to ensure binary data stream in XML node does not contain those additional characters?

    can you provide input xml
    Edited by: RajuGA on Dec 7, 2011 2:09 PM

  • HP3561A:Conversion Binary data in Decimal data

    Hello,
    I try to transform, with Visual BASIC 6, a variable in binary data acquired by order "DSTB" of Dynamic Analyzer HP3561A,
    in decimal data to then use it in Excel.
    Could you help me to carry out this transformation, because for the moment I pain a little. 
    Thank you in advance. 
    Cordially Xavier VACHERET

    Hello with all
    I thank you for your messages.
    After some research, here the method which I found to obtain measurements of analyzer HP3561A.
    to see the file joint 
    Perhaps that is not very academic, but that functions.
    Thank you has all. 
    Cordially
    Xavier
    Attachments:
    NI forum HP3561A_1.doc ‏36 KB

  • How can I read a binary file stream with many data type, as with AcqKnowledge physio binary data file?

    I would like to read in and write physiological data files which were saved by BioPac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/ app156Fi
    leFormat/FileFormat.htm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/ app155macffmt/macff.htm).
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, I was a little unsure which LabView data types correspond to int, char , short, long, double, byte, RGB and Rect. And, since it is for PC I am also assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    Two samples *.acq binary files are attach to this post to the list. Demo.acq is for version 3.7-3.7.2, while SCR_EKGtest1b.acq was recorded and saved with AcqKnowledge 3.8.1, which version number is 41.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to i
    llustrate it.
    Many thanks in advance for your help.
    Donat-Pierre
    Attachments:
    Demo.acq ‏248 KB
    SCR_EKG_test1b.acq ‏97 KB

    The reading of double is also straight forward : just use a dble float wired to the type cast node, after inverting the string (indian conversion).
    See the attached example.
    The measure of skin thickness is based on OCT (optical coherent tomography = interferometry) : an optical fiber system send and received light emitted to/back from the skin at a few centimeter distance. A profile of skin structure is then computed from the optical signal.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Read_AK_time_info.vi.zip ‏9 KB

  • How can I read a binary file stream with many data type, as with AcqKnowled​ge physio binary data file?

    I would like to read in and write physiological data which was saved by Biopac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/app156FileFormat/FileFo​rmat.h
    tm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/app155macffmt/macff.ht​m) .
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, because it is for PC I am assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to illustrate it.
    Many thanks in advance for your help.
    Donat-Pierre

    One more step...
    short are U16 integer
    double are double precision float
    bool seem to be 2 bytes (= U16)
    char are string (variable length)
    rgb are U16 integer, with high order byte = 0
    rect should be 4 x U16 (top, left, bottom, right)
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Exception writing binary data to the output stream to client -Broken pipe

    Hi,
    I am trying to use the drag & drop feature using Contributor mode of Webcenter sites. Single Image Page Attribute is working properly where as Multiple Image Page Attribute throws the following error:
    [ERROR] [.kernel.Default (self-tuning)'] [logging.cs.satellite.request] Exception writing binary data to the output stream to client 10.191.117.106
    java.net.SocketException: Broken pipe
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:568)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:539)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:427)
         at weblogic.servlet.internal.ChunkOutput$2.checkForFlush(ChunkOutput.java:648)
         at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:333)
         at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:148)
         at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:148)
         at COM.FutureTense.Servlet.ServletRequest$OutputOutputStream.write(ServletRequest.java:80)
         at COM.FutureTense.Servlet.ServletRequest.write(ServletRequest.java:1633)
         at com.openmarket.Satellite.RequestContext.write(RequestContext.java:1123)
         at com.openmarket.Satellite.BytePiece.stream(DataPiece.java:253)
         at com.openmarket.Satellite.CacheObjectImpl.stream(CacheObjectImpl.java:651)
         at com.openmarket.Satellite.Http11Responder.respondForWrapper(Http11Responder.java:142)
         at com.openmarket.Satellite.WrapperAwareResponder.respond(WrapperAwareResponder.java:36)
         at com.openmarket.Satellite.SatelliteServer.execute(SatelliteServer.java:85)
         at com.openmarket.Satellite.servlet.BaseServlet.doGet(BaseServlet.java:118)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at com.fatwire.wem.sso.cas.filter.CASFilter.doFilter(CASFilter.java:557)
         at com.fatwire.wem.sso.SSOFilter.doFilter(SSOFilter.java:51)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Thanks
    KarthiK

    Thank u very much,
         FileOutputStream opGif = new FileOutputStream(destFile, false);
    I have changed above line with the following line:
         PrintWriter opGif = new PrintWriter ( new FileWriter(destFile, false));
    and now this code is working very fine.
    Thanks once again...

  • Data plug-in for binary data with byte streams of variable length

    Hi there,
    I would like to write a data plug-in to read binary data from file and I'm using DIAdem 10.1.
    Each data set in my file consists of binary data with a fixed structure (readable by using direct access channels) and of a byte stream of variable length. The variable length of each byte stream is coded in the fixed data part.
    Can anyone tell me how my data plug-in must look like to read such kind of data files?
    Many thanks in advance!
    Kind regards,
    Stefan

    Hi Brad,
    thank you for the very quick response!
    I forgot to mention, that the data in the byte stream can actually be ignored, it is no data to be evaluated in DIAdem (it is picture data and the picture size varies from data set to data set).
    So basically, of each data set I would like to read the fixed-structure data (which is the first part of the data set) and discard the variable byte stream (last part of the data set).
    Here is a logical (example) layout of my binary data file:
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXXXXXXXXX (byte stream)
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXX (byte stream)
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXXXXXXXXXXXXXXXX (byte stream)
    What I would like to show in DIAdem is only fixedSize-Value1 and fixedSize-Value2.
    ´
    If I understood right, would it be possible to set the BlockLength of each data set by assigning Block.BlockLength = fixedSize-Value3 and to use Direct Access Channels for reading fixedSize-Value1 and fixedSize-Value2 ?
    Thank you!
    Kind regards,
    Stefan

  • STREAMING 을 이용해서 BLOB 에 BINARY DATA 를 저장하는 SAMPLE

    제품 : JDBC
    작성날짜 : 2003-08-07
    STREAMING 을 이용해서 BLOB 에 BINARY DATA 를 저장하는 SAMPLE
    ============================================================
    PURPOSE
    STREAMING 을 이용해서 BLOB COLUMN 에 BINARY DATA 를 저장하는
    방법을 SAMPLE 을 통해 알아 봅니다.
    Explanation
    다음 예제는 먼저 blob column 이 들어 있는
    MEDIA_STORE 라는 table 을 만들고 그 table 안에
    e:\temp\mytest.avi 파일을 insert 하는 내용입니다.
    Example
    다음을 실행하기 전에 다음명령으로 예제 TABLE 을 생성해야
    합니다.
    CREATE TABLE MEDIA_STORE ( MNAME VARCHAR2(25),
    MTYPE VARCHAR2(15),
    MDATA BLOB );
    OracleBLOB.java 소스
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    public class OracleBLOB extends Object
    Connection conn;
    public OracleBLOB()
    private void openSession() throws SQLException, Exception
    try {
    //Register the Oracle JDBC Driver.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    //Open a session.
    conn = DriverManager.getConnection("jdbc:oracle:thin:@krint-5.kr.oracle.com:1525:ora920","scott","tiger");
    } catch(SQLException e) {
    e.printStackTrace();
    private void insertBLOB() throws SQLException, Exception
    BLOB blob;
    File binFile;
    FileInputStream instream;
    OutputStream outstream;
    try {
    //Set AutoCommit to OFF - required by BLOB locking mechanism.
    conn.setAutoCommit(false);
    //Create a statement.
    Statement stmt = conn.createStatement ();
    //Insert an empty BLOB locator.
    stmt.execute("INSERT INTO MEDIA_STORE VALUES('THX','DVD-VOB',empty_blob())");
    //Execute the query and lock the BLOB row.
    ResultSet rset = stmt.executeQuery ("SELECT MDATA FROM MEDIA_STORE WHERE MNAME='THX' FOR UPDATE");
    rset.next();
    //Get the BLOB locator.
    blob = ((OracleResultSet)rset).getBLOB(1);
    //Get the large binary media file.
    binFile = new File("e:\\temp\\mytest.avi");
    instream = new FileInputStream(binFile);
    //Insert to the BLOB from an output stream.
    outstream = blob.getBinaryOutputStream();
    //Read the input stream and write the output stream by chunks.
    byte[] chunk = new byte[blob.getChunkSize()];
    int i=-1;
    System.out.println("Loading");
    while((i = instream.read(chunk))!=-1)
    { outstream.write(chunk,0,i); System.out.print('.'); }
    //Close the input and output stream.
    instream.close();
    outstream.close();
    //Close the statement.
    stmt.close();
    } catch(SQLException e) {
    e.printStackTrace();
    private void closeSession() throws SQLException, Exception
    try {
    //Close the session.
    conn.close();
    } catch(SQLException e) {
    e.printStackTrace();
    public static void main(String[] args) throws SQLException, Exception
    OracleBLOB app = new OracleBLOB();
    app.openSession();
    app.insertBLOB();
    app.closeSession();
    실행결과 :
    E:\temp>java OracleBLOB
    Loading
    E:\temp>
    Reference Documents
    Note:95816.1

  • Sending binary data over RS232 without conversion to ascii

    I need to send binary data to a PIC without the data being converted to ascii. With the VISA vi's, when I want to send 11111111, it gets converted to a string "255", and is sent as "2","5","5" in ascii.
    How can I send it as one byte?

    r_keller wrote:
    @tbob: I probably shouldnt tell my customer that he's an idiot, and obviously 9 bit addressing/signalling modes seem to be not so uncommon in industry, so ur post does not really contribute to solve the problem.
    Well I wouldn't call my customer an idiot either.  I didn't know he was your customer.  Sorry.  Not every comment posted here is intended to directly solve a problem.  We are a fun loving group, and occasional ribbings take place here.  I still think that trying to use 9 bits over an 8-bit protocol is not a good way to go.  But if it is the only way, then so be it.
    r_keller wrote:
     Does the Mark or Space parity bit add another 10th bit to the command or can i only use either ODD parity/Mark/Space?
    According to the link you attached, the parity bit adds only one more bit.  If the number of bits is set to 8, then the parity is the 9th bit, and you can only use Mark or Space to force that 9th bit to either 1 or 0 respectively.  If you try to use odd or even parity, the protocol will determine the parity and change the bit accordingly, and it may not be the one you intended to send.  The start and stop bits are fixed by the protocol and cannot be used for extra data bits.
    Actually, until I read that article about using Mark and Space, I had no idea at all that sending 9 bits at a time was possible.
    - tbob
    Inventor of the WORM Global

  • Conversion from scaled ton unscaled data using Graph Acquired Binary Data

    Hello !
    I want to acquire temperature with a pyrometer using a PCI 6220 (analog input (0-5V)). I'd like to use the VI
    Cont Acq&Graph Voltage-To File(Binary) to write the data into a file and the VI Graph Acquired Binary Data to read it and analyze it. But in this VI, I didn't understand well the functionnement of "Convert unscaled to scaled data", I know it takes informations in the header to scale the data but how ?
    My card will give me back a voltage, but how can I transform it into temperature ? Can I configure this somewhere, and then the "Convert unscaled to scaled data" will do it, or should I do this myself with a formula ?
    Thanks.

    Nanie, I've used these example extensively and I think I can help. Incidently, there is actually a bug in the examples, but I will start a new thread to discuss this (I haven't written the post yet, but it will be under "Bug in Graph Acquired Binary Data.vi:create header.vi Example" when I do get around to posting it). Anyway, to address your questions about the scaling. I've included an image of the block diagram of Convert Unscaled to Scaled.vi for reference.
    To start, the PCI-6220 has a 16bit resolution. That means that the range (±10V for example) is broken down into 2^16 (65536) steps, or steps of ~0.3mV (20V/65536) in this example. When the data is acquired, it is read as the number of steps (an integer) and that is how you are saving it. In general it takes less space to store integers than real numbers. In this case you are storing the results in I16's (2 bytes/value) instead of SGL's or DBL's (4 or 8 bytes/value respectively).
    To convert the integer to a scaled value (either volts, or some other engineering unit) you need to scale it. In the situation where you have a linear transfer function (scaled = offset + multiplier * unscaled) which is a 1st order polynomial it's pretty straight forward. The Convert Unscaled to Scaled.vi handles the more general case of scaling by an nth order polynomial (a0*x^0+a1*x^1+a2*x^2+...+an*x^n). A linear transfer function has two coefficients: a0 is the offset, and a1 is the multiplier, the rest of the a's are zero.
    When you use the Cont Acq&Graph Voltage-To File(Binary).vi to save your data, a header is created which contains the scaling coefficients stored in an array. When you read the file with Graph Acquired Binary Data.vi those scaling coefficients are read in and converted to a two dimensional array called Header Information that looks like this:
    ch0 sample rate, ch0 a0, ch0 a1, ch0 a2,..., ch0 an
    ch1 sample rate, ch1 a0, ch1 a1, ch1 a2,..., ch1 an
    ch2 sample rate, ch2 a0, ch2 a1, ch2 a2,..., ch2 an
    The array then gets transposed before continuing.
    This transposed array, and the unscaled data are passed into Convert Unscaled to Scaled.vi. I am probably just now getting to your question, but hopefully the background makes the rest of this simple. The Header Information array gets split up with the sample rates (the first row in the transposed array), the offsets (the second row), and all the rest of the gains entering the for loops separately. The sample rate sets the dt for the channel, the offset is used to intialize the scaled data array, and the gains are used to multiply the unscaled data. With a linear transfer function, there will only by one gain for each channel. The clever part of this design is that nothing has to be changed to handle non-linear polynomial transfer functions.
    I normally just convert everything to volts and then manually scale from there if I want to convert to engineering units. I suspect that if you use the express vi's (or configure the task using Create DAQmx Task in the Data Neighborhood of MAX) to configure a channel for temperature measurement, the required scaling coefficients will be incorporated into the Header Information array automatically when the data is saved and you won't have to do anything manually other than selecting the appropriate task when configuring your acquisition.
    Hope this answers your questions.
    ChrisMessage Edited by C. Minnella on 04-15-2005 02:42 PM
    Attachments:
    Convert Unscaled to Scaled.jpg ‏81 KB

  • Streaming Binary Data

    Hi,
    I would like to send plain old binary data using RTP. How can I use the JMF to send binary data without binding it to a codec or media type?
    Thanks,

    sam8680 wrote:
    I would like to send plain old binary data using RTP. How can I use the JMF to send binary data without binding it to a codec or media type?Is there a particular reason you don't want to use a normal UDP or IP socket for plain old binary data?

Maybe you are looking for

  • My Mac can´t open "Desktop and screensaver" prefrences without crashing

    So this just suddenly happend, i have tried to boot in safe mode, tried checking the system with some kinda test. I also made a new user and tried open desktop and screesavers there, and it works fine. So i think it has something with applications to

  • Clickable buttons in jtable

    Hi All, I'm trying to add a JButton to a JTable. There are a few scripts out there that show how to transfer a mouse event from jtable to a button that is placed in its cell. I've added to it a response to mousemoved method to highlight a button when

  • Unknown error when renting a movie

    I've never had an issue with renting from iTunes before, but I'm getting the following message tonight: "An unknown error occurred (- 50)."  What is this?  How do I fix it?  I'm not seeing any support links or "report problems" from within iTunes. (I

  • How to maintain table.

    Hi Experts, I want to know  basics of table maintainance, pl. guide me

  • Jump to slide not working on slide before quiz (Captivate 4)

    I have a Captivate 4 file that contains a two-part quiz (multiple choice, followed by interactive practice). The first screen of this file is an introduction; it has three buttons ((RETURN, which opens a separate URL), CONTINUE (goes to next slide wh