VISA Read gets incorrect data from serial connection

I am having difficulty using the VISA functions in LabVIEW to read data from a virtual COM port. Data is being sent from a serial to USB chip via a USB connection using OpenSDA drivers. I have a python program written to read from this chip as well, and it never has an issue. However, when trying to achieve the same read in LabVIEW I am running into the problem of getting incorrect data in the read buffer using the VISA Read function.
I have a VISA Configure Serial Port function set up with a control to select the COM port that the device is plugged into. Baud rate is default at 9600. Termination char of my data is a newline, which is also default. Enable termination char is set to true. A VISA Open function follows this configuration, and then feeds the VISA Resource Name Out into a while loop where a VISA Read function displays the data in read buffer. Byte count for the VISA Read is set to 20 so I can read more of the erroneous datat, however actual data will only be 6-12 bytes. The while loop has a wait function, and no matter how much I slow down the readings I still get incorrect data (I have tried 20ms thru 1000ms). 
The data I expect to receive in the read buffer from VISA Read is in the form of "0-255,0-255,0-255\n", like the following:
51,93,31\n
or
51,193,128\n
And occasionally I receive this data correctly, however I intermittently (sometimes every couple reads, sometimes a couple times in a row) get incorrect readings like this:
51,1\n
51,193739\n
\n
51,1933,191\n
51,,193,196\n
51,1933,252 
51,203,116203,186\n
Where it seems like the read data is truncated, missing characters, or has additional characters. Looking at these values, however, it seems like the read was done incorrectly because the bytes seem partially correct (51 is the first number even in incorrect reads).
I have search but haven't found a similar issue and I am not sure what to try from here on. Any help is appreciated. Thanks!
Attachments:
Serial_Read_debugging.vi ‏13 KB

The first thing is that none of the error clusters are connected so you could be getting errors that you are not seeing. Are you sure about the comm parameters? Finally, I have never had a lot of luck looking for termination characters. You might want to just capture data and append each read into one long string just to see if you are still seeing this strangeness.
What sort of device is returning the data? How often does it spit out the data? How much distance is there between it and your computer? Can you configure it append something like a checksum or crc to the data?
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Similar Messages

  • Adobe Reader is Cacheing Data From OLEDB Connection

    I am trying to pre-populate a form from an oledb connection to an access database. I have an html page where a user can search an id. This id then gets written to a table where the sql query defined in the PDF form can grab it, join it with a table where the user info is stored, then display it.
    My problem is that Adobe Reader seems to be caching data from the first SQL select query that is executed. When I change the id I am loading, I still get data from the first SQL query in Reader. If I open the PDF via Acrobat, the data loads up properly, and it doesn't seem to be cached. I have looked at the following forum for suggestions: http://www.adobeforums.com/webx/.3bc3549c, but their suggestions haven't worked.
    I have tried turning off caching anywhere I can find it (i.e. in LiveCycle, Adobe Reader), but nothing is working. Does anybody have any suggestions?

    It sounds like you need use the adobe schema in MII so the output of your transaction matches it.
    Regards,
    Jamie

  • Storing Data from Serial Connection

    Hello All,
    I am fairly new to LabView, I am trying to store and anaylze values from a non-Labview hardware via an rs-232 connection.
    I have two devices on COM1 and COM2 ports. COM2 sends a value which I would like to store in an array. COM 2 points will form a somewhat sine wave within a few seconds. I would like to compare these values live to generate: max and min peak values, peak to peak values, and mean (I know LabView has signal icons for this, I'm just not sure how to wire it up).
    I have attached the vi.
    Thank you for your time and help.
    Kelvin R.
    Solved!
    Go to Solution.
    Attachments:
    krreadwrite.vi ‏74 KB

    kore101 wrote:I believe I need to use a for loop along with shift registers, but I just don't know how to.
    LabVIEW Basics
    LabVIEW 101
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadshee​t. Any ideas?

    I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadsheet. Any ideas? Right now my data will collect one reading instead of continuously reading my IMU which displays data in a continuous stream.
    Thanks
    Attachments:
    Read_IMU_Drew.vi ‏21 KB

    Hi
    Your vi is in 2009 version, which i am unable to open in 8.6
    However, if you want your data to be saved in excel sheet, here is the VI
    Somil Gautam
    Think Weird
    Attachments:
    save to excel.vi ‏12 KB

  • I use LabVIEW 7.1 but I have some problem when, I use LabVEW to read the data from serial communication

    I use LabVIEW 7.1 but I have some problem when, I use LabVEW to read the data from serial communication.
    I use LabVIEW to read the data from serial communication then, i open the example (.vi) from Serial Communication - Advanced Serial Write and Read  from LabVIEW Example. BUT it have some error message that : Error - 1073807202 occured  at property node in visa configure serial port (instr).vi -> advance serial write and read .vi
    this error code is undefined. no one has provide a description for this code, or you might have wired a number that is not an error code to the error code input.
    I don't know why? please help me. thank you.

    When I copy that code into "Explain Error" I get: "VISA:  (Hex 0xBFFF009E) A code library required by VISA could not be located or loaded."
    You may have a bad install of VISA or the wrong version of VISA loaded. Try re-installing VISA. You can get the latest version from the NI support site: http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BBB002C0E91?opendocument&node=1....
    Also ensure that you are not pointing the example towards a serial port that does not exist.
    Please let us know what you find and what gets this working for you.
         Rob

  • Read data from serial port or TCP port of frontend PC

    Hello Friends,
    I have requirement to read data from device connected to frontend PC which will provide meter reading data.
    Vendor has given me two option.
    1. Device can be connected to seiral port and data transfer will be done through MODBUS RTU protocol.In that case data need to capture from serial port.
    2. Device can be connected to TCP port and Socket program can be provided for data transfer. In that case SAP will act as client and communicate with TCP port.
    There will be multiple workstation with individual meters connected to them.
    I am aware of text file interfacing through front end tools using custom code using VB,JAVA or others.
    Is there any solution availble  to achieve above things using  ABAP other than text file , like direct communication?
    I am using ECC 6.0.

    Hello,
    Socket programming in not available on ABAP, but you may use RFC for the same.
    Use the below links for more details
    [Link 1|http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf]
    [Link 2|http://forums.sdn.sap.com/thread.jspa?threadID=1820233]
    Regards,
    Abhishek

  • Problem while reading data from Serial Port

    Hi All,
    I am facing some problem while reading data from Serial Port.
    As per the requirement I am writing the data on Serial Port and waiting for response of that data.
    Notification for data availabilty is checked with method public void serialEvent(SerialPortEvent event) of javax.comm.SerialPortEventListener.
    When we are writing data on the port one thread i.e. "main" thread is generated and when data availability event occures another thread "Win32SerialPort Notification thread" is generated. This creates problem for me as we can't control thread processing.
    So can anybody pls explain me how to overcome this problem?
    Regards,
    Neha

    My Problem is:-
    I am simoultaneouly wrting data on port & reading data from port.
    First I write data on port using outputStream.write() method. Now when target side sends me response back for the request on serial port DATA_AVAILABLE of SerialPortEventListner event occured,we are reading data from serial port.Now till the time we didn't get the response from target next command can't be written on the serial port. When we are writing data on port main thread is executed.Now my problem starts when DATA_AVAILABLE event occured.At this point another thread is created.Due to this my program writes data of next command without reading response of previous command.To solve this prob. I have used wait() & notify() methods as follows.But again due to this my pc hangs after execution of 2 commands. (PC hang in while loop in a code provided below.)
    From SOPs I could figure it out that after 2 commands we are not able to write data on serial port so DATA_AVAILABLE event doesn't occure n pro. goes in wait state.
    Can anybody help me to solve this issue.
    Neha.
    Code:
    public void serialEvent(SerialPortEvent event)
              switch (event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                                 break;
                   case SerialPortEvent.DATA_AVAILABLE:
                        try
                             dataThread = Thread.currentThread();
                             dataThread.setPriority(10);
                             dataAvailable = true;
                                                                                    byte[] tempArray=new byte[availableBytes];
                                        inputStream.read(tempArray);
                                                                       catch (IOException io)
                             SOP(io, "Error in serialEvent callback call for event DATA_AVAILABLE");
    public void  writetoPort(byte[] data) throws IOException
                             outputStream.write(data);
                              while(finalTimeOut >= actualTime)
                            if( ! dataAvailable)
                                    actualTime = System.currentTimeMillis();
                           else
              synchronized (mainThread)
                   mainThread = Thread.currentThread();
                   mainThread.wait();
    public  void sendDatatoUser(byte[] b) throws Exception, HWCCSystemFailure
              obj.returnData(b);
              synchronized(mainThread)
                   mainThread.notify();
                                                           

  • How to get and maintain Http persistent connection to get pushed data from

    At MangoSpring ,www.mangospring.com we are working on application which uses IMPS protocol where we always required to receive data pushed by server.
    To achive this we'll have to maintain one persistent Http connection on client side, so that we can be notified whenever some data is pushed by server.
    Reply With Quote

    our problem is :: " How to get and maintain Http persistent connection to get pushed data from Server "

  • How to read data from a connected modem

    any one can help me? how to read data from a connected modem. The modem received real-time data from other server. The data is in text format. I can see this text when I used hyperterminal for dial up and the data is accumulated such as:
    @aa1235678
    @bb2135647
    @cc5214367
    since it is real-time data, I want to read one line each time instantly when it arrives.

    You need to use the Java Communications API. (http://java.sun.com/products/javacomm/index.html)

  • I'm trying to read some XML data from temperature logger over my network. I'm using LabView version 2009 sp1. I'm using the URL Get Document Vi. It works fine when using Internet sites like google or foxnews etc...

    I'm trying to read some XML data from temperature logger over my network.  I'm using LabView version 2009 sp1.  I'm using the URL Get Document Vi.  It works fine when using Internet sites like google or foxnews etc...
    When I use it with my temperature logger most of the time I get an Error 66...but some times it does work and actually retrieves the document. 
    I can use the same address "http://172.22.21.68/XMLfeed.rb" (Internet Explorer or Google Chrome) in my browser and get a response every time.  When accessing from my browser the server in the temperature logger does take around 6 seconds to respond, but it does respond every time. 
    Is the URL Get Document Vi exceeding a timeout?  If so, where can I set it to wait longer?
    Attachments:
    Error 66.jpg ‏183 KB

    It looks like the TCP Buffered Read has a 2.5 sec timeout, I believe that is where I had trouble as well.  Try creating your own URL Get HTTP Doc vi in which you call URL Get Document in normal mode, with an appropriate number of characters to fetch (enough characters so that you capture all the important data in the XML file).
    Attachments:
    ex1.PNG ‏33 KB

  • My iphone 4s will not turn on or connect to itunes.... is there any way i can get the data from the phone?

    is there any way i can get the data from the phone?

    Hi webby84,
    Welcome to Apple Support Communities.
    It sounds like you're experiencing a hardware issue with your iPhone.
    These links are a good starting point for troubleshooting:
    iPhone Assistant
    http://www.apple.com/support/iphone/troubleshooting/
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Best,
    Jeremy

  • How do I get live data from a subvi while it is running ?

    Hi.
    I'm finishing up my little application, and one of the things I cant figure out to get to work is getting live data from a subvi and displaying it on my main vi's front panel.
    In my subvi I am sending about 10 commands to the serial port, each time updating a local variable that writes value to a progress indicator. I would like to get that indicator displayed on my main vi so I can see the progress of my subvi.
    Currently I have just linked the progress indicator on the sub to a terminal, and connected that to my main vi, but, that only updates when the sub finishes its mission. Is there a way to update the main while the sub is active ?
    Any ideas appreciated !
    /Brian

    In your VI Prg_all_sub, you are actually only writing out the progress bar once to the contol reference.  Once the code to the top has executed, it will never execute again although you continue to write values to the local variable PP throughout the program.
    The quickest fix would be to put that code at the top in a loop with a small time delay function.  That way it continues to execute every time a new value gets written to the local variable.  You would have to use a local variable stop button to stop hat loop wonce your string of VISA reads and writes executes.  Also make sure to reset that stop boolean to false once the loop ends so that the loop will execute properly the next time this sub VI is called.
    Other recommendations for cleaning up the programming is to use arrays or bundle values into clusters that you pass into and out of subVI's.  Prg_all_sub and MPS setup loader have numerous wires going into and out of the sub-VI's.  Bundling these together would simplify the wiring quite a bit.
    Note also that in a lot of places you send in a wire to an indicator and branch it off to a local variable of the same indicator.  That is redundant.  Sending the wire to the local variable does the same thing as sending the wire to the indicator.  Try to use wires instead of local variables as much as possible.  For instance, near the top you send the output of the VISA resource name control back into a local variable of itself, (not necessary) then use a local variable numerous times in the case structure below.  Just wire the name into the case structure border, and maintain the value through all of the loops using a shift register.  This will eliminate dozens of copies of the VISA resource name variable.
    In several places you concatenate a carriage return character to a string constant.  Just put a "\r" at the end of the string constant when it is shown in \ display.  Then you can eliminate the concatenation.
    I hope this helps you get your progress bar working and help simplify the code for you.
    Message Edited by Ravens Fan on 08-13-2007 09:34 AM

  • How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    If the data is on a remote server (for example, PHP running on a web server, talking to a MySQL server) then you do this in an AIR application the same way you would do it with any Flex application (or ajax application, if you're building your AIR app in HTML/JS).
    That's a broad answer, but in fact there are lots of ways to communicate between Flex and PHP. The most common and best in most cases is to use AMFPHP (http://amfphp.org/) or the new ZEND AMF support in the Zend Framework.
    This page is a good starting point for learning about Flex and PHP communication:
    http://www.adobe.com/devnet/flex/flex_php.html
    Also, in Flash Builder 4 they've added a lot of remote-data-connection functionality, including a lot that's designed for PHP. Take a look at the Flash Builder 4 public beta for more on that: http://labs.adobe.com/technologies/flashbuilder4/

  • How to save a datas from serial port?

    How to save a datas from serial port?

    Hi
    I need some help about rs-232 communication. I want to make a vi witch can do this things:
    -read a txt file (to simulate a serial port like when the datas are coming)
    i will get 3 different data in serial port (like this: 121 213 135)
    i want to save in a txt file what datas get my vi
    so
    -write in a txt file or draw in a diagram (or both)
    so my problem is: read in serial port and save in a file and draw a diagram.
    if anybody can help pls HELP ME because im a beginner in this problem.
    I already do something but Im not sure that good.
    Thx for all.

  • How can i get the data from database & add them as a link

    Hi,
    how can i get a data from a database(DB2) and that data will be having a file so i should make them as a link.i tried it in jsp .
    <%
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");     
    response.setContentType("text/html");
    Connection conn = null;
    conn = DriverManager.getConnection("jdbc:db2:spintran");
    Statement stmt = conn.createStatement();
    stmt.executeQuery("set current schema tut");
    ResultSet rs = stmt.executeQuery("select * from tutorial");     
    %>
    Type Of the Category : &nbsp&nbsp&nbsp
    <%
         while (rs.next())
         String desc = rs.getString(1);     
         out.println(desc);
    %>
         <A HREF = "<%=desc%>"><%=desc%> </A>
         <%
         %>
    but it is not working.how can i link.
    thank you.

    what is desc? is it the file name ? whats the data type of desc in db? INFILE?
    if desc is just the name of the file, then make sure that such a file exists in the proper folder.only then the link works..
    that is, if desc is 'a.jpg' then a.jpg should be existing in the same folder as your html is.

Maybe you are looking for