VISA Read Losing Characters off the end of the output string

Hi,
So I am writing a VI to take an output string of data from an ardunio Uno and parsing it. I am using the Read Visa vi to grab the string from output of the device. In the end I will be connecting a device that actually gives value in this type of string  format : (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*).
So after a large number of loops, the program starts to drop the last few characters of the string that it outputs. So the string output from Visa Read will read something like (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,). The only way to fix this problem after it has occured is to completely close labview (all the way). Once I open it again and start running the program, all is fine in the world.
Anyone ever have this issue? I have been trying to debug this in different ways and the only weird symptom that I have other than the Visa Read function losing a few characters of the string is the fact that looking at the Bytes at Port after I Visa Read, is that it starts showing five bytes instead of zero. 
attached is my most recent attempt at solving this issue. 
Note:  The Ardunio outputs a string of this format every 2 seconds with the values being incrimental over a specified range.(#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*) 
Solved!
Go to Solution.
Attachments:
Ardunio(StringOutput).vi ‏36 KB

So i did a long data collect and It looks like ever 43minutes and 24 seconds the system goes from cutting off the last 5 characters to not cutting off the last 4 characters.
As I cant see how Labview would be causing that, I am going to try and dig into the Ardunio and solve that issue... hopefully when thats done I can simplfy my code like you guys pointed out.
Thanks!
Attachments:
overnight_11_18.csv ‏3001 KB
Overnight.png ‏146 KB

Similar Messages

  • How do I program Instrument I/O Assistant to read a variable in the input string?

    How do I program the Instrument I/O Assistant to read a variable in the input string? I can manually type in the string using the Instrument I/O Assistant using the "Write" or "Query" tools but I do not know how to send a variable input to the Instrument I/O Assistant so that variable can be used inside the "Write" string. For example, I have a power supply whose current I want to set to X Amps. I can type the command "PC10" to program the current to 10 Amps, however I want to be able to program it at any arbitrary current. How do I feed the value X into the code for this purpose?

    You can't. The assistant was designed to be a quick and dirty way to do some basic communication with an instrument. You can turn it into a VI (right click and select Open Front Panel) and modify it so that your write string is an input to the VI or use it as a template and create your own code with VISA Read and Write primatives.

  • If i got incorrect characters in the output of sap script? HOW TO CORRECT I

    If i got incorrect characters in the output of sap script? HOW TO CORRECT IT?

    Hi Sunil,
    Debug the script and check where exactly those are getting populated. Definately you will get it. Check the conversion parts means character to numeric conversion.
    If your version is 4.7E then select unicode check box in the reports attributes. It will display the error message so that we can solve very easily.Hope this helps you, reply for queries, Shall post you the updates.
    Regards. 
    Kumar. .

  • Java - InputStream - Weird Characters in the Output!

    Hi,
    I have a software which outputs lines of numbers one by one. In another java program, I use BufferedReader as follows:
    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(),"US-ASCII"));
    where pr is the process which runs the software. For each line in the output stream, I try to check whether the first number in the line is greater than a certain value and if it is, I write to another file.
    The problem is, when I run the software repeatedly (in a linux cluster) like 10 simulations simultaneously, one of them have got @^@^.... characters followed by some huge numbers. So, I tried eliminating that line alone by using String.matches command but now, it seems even after that I get the error - so, I think it might mean that it is actually during the writing process that the problem occurs. I use BufferedWriter like the following to write it: (I do flush it after writing.)
    BufferedWriter out=new BufferedWriter(new FileWriter(tmp_file));
    I would greatly appreciate if someone can help. This thing really seems to be a huge bottleneck!
    Thanks,
    Senthil

    Hi ejp! Thanks - here is the code!
    import java.io.BufferedReader;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.io.*;
    import java.util.*;
    //call the class file with the input xml file to simulate
    public class RunSim {
    public static void main(String[] args) {
    String[] xmlFiles = new String[] { "/home/senthil/Simulator/Dessa1.4/" args[0]};
    Scanner input=null;
    FileWriter ofw=null;
    PrintWriter out=null;
    for(String file:xmlFiles) {
    try {
    String[] command = {"java","Test",file, "10000"};
    Process pr = Runtime.getRuntime().exec(command); // run the command
    input = new Scanner(new InputStreamReader(pr.getInputStream()));
    String line=null;
    ofw=new FileWriter(file"_out.txt");
    out=new PrintWriter(ofw);
    while(input.hasNextLine()) {
    line=input.nextLine();
    System.out.println(line);
    if(line.matches("[0-9.\\s]*")) { // I included this as I didn't want the '@^' character - but still, it is being produced.
    out.println(line);
    out.flush();
    String[] str = line.split(" ");
    if(!line.equals("Badly formatted XML file")){
    if((Float.parseFloat(str[0]) >= 196)) //this is the limit upto which the process has to be run
    pr.destroy();
    else
    continue;
    out.close();
    int exitVal = pr.waitFor();
    System.out.println("Exited with error code "+exitVal);
    } catch(Exception e) {
    System.out.println(e.toString());
    e.printStackTrace();
    }

  • Junk Characters in the Output of  Reports2.5

    I have created Report in Reports2.5 which is giving good output display
    But when I Register the Report in Oracle Apps & see output
    it shows Junk Characters in the place of Labels
    e.g. Revenue Report
    will come like sg0Revenue o7Report
    Can any-one give me the solution for this
    Regards / Shailesh ( [email protected] )

    This is probably due to the prt file that's being used to format the output. I'm willing to bet that the headings are in bold, and the prt file being used has includes some control characters to tell the printer to switch on and off bold - when you view the output file those are the characters you're seeing.
    To switch this off simply remove the control characters from the prt file being used.
    Hope this helps,
    Danny

  • Junk Characters in the output XML file after Parsing

    Hi
    I am using DOM parser to parse an XML file.
    After parsing the input XML file, i am fetching some contents
    from the same and also putting the same contents in the parsed output file which is also an XML file.
    The problem here is that the after putting the contents to the output XML file from the input XML file,
    some junk character appears at the end of each and every tag in the outputfile.
    The junk character is some thing like this : " ampersand hash thirteen and a semicolon "
    (*THE MESSAGE DID NOT ACCEPT THE SYMBOLS KINDLY TRANSLATE THE ABOVE WORDINGS*
    INTO SYMBOLS)
    This character gets appended at the end of each and every tag in the output file due to which the output file
    is not recognised as an XML file.
    Please let me know as to why is this character appearing and also please suggest some solution
    for the same.
    -Thanks in Advance.
    Edited by: itskarthik on Oct 10, 2008 7:16 AM
    Edited by: itskarthik on Oct 10, 2008 7:18 AM
    Edited by: itskarthik on Oct 10, 2008 7:19 AM
    Edited by: itskarthik on Oct 10, 2008 7:19 AM
    Edited by: itskarthik on Oct 10, 2008 7:23 AM
    Edited by: itskarthik on Oct 10, 2008 7:23 AM

    Wierd.
    Try this piece of code. (You can always change it to use input file and output file instead of string if you want)
    What is your output?
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    public class XMLTest {
         public static void main(String[] args) throws Exception {
              String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
                                  "<test>\r\n" +
                                  "</test>";
              System.out.println("Input:");
              lookForCR(input);
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              Document doc = factory.newDocumentBuilder().parse( new ByteArrayInputStream(input.getBytes()) );
              Source source = new DOMSource(doc);
              ByteArrayOutputStream bArrOut = new ByteArrayOutputStream();
              Result result = new StreamResult( new StripOutputStream( bArrOut ) );
              Transformer xformer = TransformerFactory.newInstance().newTransformer();
              xformer.transform(source, result);     
              System.out.println("\nResult:");
              lookForCR(bArrOut.toString());
              System.out.println("\nDone");
         public static void lookForCR(String input) throws Exception {
              char[] chars =input.toCharArray();
              for ( char chr : chars ) {
                   if (chr == 13 ) {
                        System.out.println("Has 0x0D character!!");
    class StripOutputStream extends OutputStream {
         OutputStream out = null;
         public StripOutputStream(OutputStream out) {
              this.out = out;
         @Override
         public void write(int b) throws IOException {
              if ( b != 13 )
                   out.write(b);
    }- Roy

  • Adobe Reader doesn't remember the output method user authentication

    Here's the setup:
    We use a network printer that is set up only using user inboxes with user authentication. There's no normal printing.
    The printers are set up on the mac computers using output method > user authentication > userid and password.
    This works fine for every application, but somehow it doesn't for Adobe Reader. It 'forgets' the password every now and then,
    even if when you look at the user authentication, the setting is still checked, and the password is still filled in.
    if I reinsert the password, and press OK, then press Print, the task is sent to the printer again, only this time, it actually prints.
    I can't think of a reason why Adobe Reader won't remember the settings.

    Merry Christmas!
    I currently only have Adobe Reader 9 installed.
    I did uninstalled Adobe and Acrobat, run a registry clean up....then installed Adobe Reader 9.
    but still not working.
    Very strange that everytime i open the program from Start-->Adobe-->Adobe Reader 9, then it starts install Reader.....it says please wait while Adobe install, it takes another 2 minutes then it opens.
    If I open by double click on the.pdf file, it then ask what program do you want to open this file.  I selected Adobe Reader 9, then it opens without any installation windows.

  • How to print the output string in inverted commas

    hi all,
    my question is
    like i have a string
    "welcome to java"
    using println statement
    i need to print the above statement in inverted commas
    like the output should appear as
    "welcome to java"

    This sounds like part of some homework but what the
    heck ...
    System.out.println("\\"welcome to java\\"");I was trying to anticipate bugs in this stupid forum sofftware, this should be
    System.out.println("\"welcome to java\"");

  • XSL-FO unable to read special characters from the XML file

    Team,
    please help on issue, when trying to read the text from XML file (Special characters like bullet). It is displaying as Question mark(?) in output in place of bullet..please proved any soultion.

    The "?" signals a character set mismatch issue - http://www.oracle.com/technetwork/database/globalization/nls-lang-099431.html - between client and database software

  • Receiver SFTP adapter giving spaces between characters in the Output file

    Hi PI Experts,
    My Scenario is: Paymul (EDI file ) ECC -> PI -> SFTP server.
    Source Sender File adapter able to pickup this Paymul D96A file and able to send messages to target SFTP server using SFTP receiver adapter.
    But, Generated Output file having single space between each character. I am not using any content conversion modules in Receiver SFTP adapter.
    Also not having any mappings to transform the messages. it is just pass through interface.
    I have attached example Output file. I have changed the .Dat file to .txt just to attach here.
    Could any one try to help me on this. Please let me know incase need any more details.
    Thanks,
    Govindu.

    Hi Govindu,
    Please see if the below Endcoding settings wont resolve your issue.
    File Type - Text
    File Encoding - ISO-8859-1
    Regards,
    Jannus Botha

  • VISA Read over USB Problem: After a while the xBFFF0015 Timeout Error occurred

    Hi,
    I have trouble using labview with my non-NI USB device:
    The device is an analog input DAQ board. I was able to setup communication with the board using a VISA driver specifically created for this board and direct FW calls using the product's firmware specification provided by the manufacturer.
    This method has been working pretty good so far, but when I try to get large amount of data (64k samples @100ksps), the VISA Read returns the 'VISA: (Hex 0xBFFF0015) Timeout expired before operation completed.' error.
    Please see the attached screenshot of the block diagram for details.
    First, an 'analog input scan start' command is sent to the DAQ device, and then the vi tries to read all collected data from the device, once the right amount of data retrieved, or no more data is available the data collecting process (the while loop) ends and an 'analog input scan stop' command is sent to the DAQ device.
    The data collection starts with no problem, but after a while, in loop# 400, the VISA Read hangs and then returns the error mentioned above.
    I tried to increase the time out value, but it didn't help, the error occurred after the same number of loops, the VISA Read got hosed and the error occurred after the longer timeout expired.
    I also tried to add some delays in the loop, but it didn't help either.
    I am not sure what do I miss here and I would highly appreciate if anyone could give me some guidance how to solve this issue.
    Thanks,
    John
    Attachments:
    usb-read.png ‏18 KB

    I just wanted to specify that this is not an NI board avoiding to make people think this is a hardware issue. And I think that the rest of the code is irrelevant in this case.
    I believe that I don't use the VISA functions correctly. I assumed that someone who used these functions before would be able to point out the obvious steps missing in the data collecting process using the VISA functions.

  • The value read by visa read VI is not correct!

    I design a labview program to control Agilent E5072C network analyzer. When I want to get value from this instrument, I use the "VISA read" VI which listed in the block plate. However, the value read by this VI is last time measurement value. For example, last time the read value is 1.0 db and this time the measurement value is 1.2 db. But when I use "VISA read" VI to fetch the value, it is 1.0 db.
    Agilent also provide a VI for this device to read measurement value, and it alway read correct value. so could someone tell me why? do I need do any action before read value from this instrument if I want to use "VISA read" VI instead of Agilent VI?
    Solved!
    Go to Solution.
    Attachments:
    Read.vi ‏23 KB

    You are probably reading it too quickly.  By reading it in NI-MAX, you are doing it by hand, so it takes longer.  When you do it programmatically, it is "instant".  Try using the *OPC? command to turn your command into a query.  It will then return a "1" in the read buffer.  Read the "1" and then do the fetch command.
    To Dennis:
    I've had bad experiences with manufacturer-supplied drivers to the point where I don't even try to use them any more.  But if Agilent is as anal about their drivers as they are about their manuals, they should be no problem. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Read in Binary form in VISA read function

    Dear All,
    I have connected my Device to the serial Port. and data read from the buffer is stored in text format. I want to view the data in binary format .
    Actually, i have performed the same function in Visual Basic. there also if i view the data in text format, it shows some junk values. but if i view the data in binary, it shows the actual data coming from the instrument .
    I dont know how to modify the VISA read function. can any one pls tell me how can i read the data in binary format?
    Thanks
    Ritesh

    Oops!  No it didn't.
    Lab VIEW 2012 (if that makes a dif)
    I'm using the VISA Read function to take ADC readings in from a microcontroller.  The VISA Read function outputs the data as a string.  Easy to convert the string to U8, either with the conversion function or type cast function, and works great except for a tiny corner case when the ADC reading is zero.  The VISA Read function treats the 8-bit zero reading as a null character and strips it out.
    Apparently, since this is done by the VISA Read function as it's building the string, type casting and or converting the output string from the VISA Read function doesn't "bring the zeros back".
    I've tried setting the VISA property "Discard NUL Characters" to false, and that didn't seem to help.
    My current work around is just to never have the micro send a zero ADC reading. 
    Anyway, I'm a Lab VIEW noob, so while this isn't essential to my project, I remain curious about how to send Lab VIEW serial data that isn't automatically considered characters, thrown into a string with all the zeros stripped out.
    Regards,
    Who

  • Visa read function question

    Hi, all:
    I use Visa to write/read data from hardware through COM port,  the protocol is interactive communication, labview send commnd frame first, then hardware send back required data frame.if labview don't send command frame, then hardware send 0x00 continuously.  frame length is 10 bytes.
    My idea is:  use Visa Write to send one frame down, then inside a While loop a Visa Read to get the data frame, when get the right data frame, stop while loop.
    But I found the while loop can't stop, with probe, I found the data frame sliped once, it seems that Visa Read get the data then very soon it get 0x00 so that the comparison function can't finish to handle the data, then 0x00 arrives to the probe which sticked the input terminal of comparison funciton.
    I solved this problem use a buffer string to store Visa Read's output read buffer, and make Visa Write and Visa Read a pair inside the while loop.
    I wonder why the comparison function can't catch the data frame from Visa Read exactly.
    Please refer to the attchment jpg file, it is not the real vi, just illustration
    Attachments:
    visaRead.jpg ‏23 KB

    Is it possible that your device is already sending 0x00 when you start running your VI?  If so, you may get that in the serial port buffer.  Then, when you do the VISA Read, you will read 0x00 as the first byte, then the first 9 bytes of your frame (cutting off the last byte) so the comparison won't work.
    EDIT: by the way, it's common to read the "Bytes at Port" VISA property, then feed that into VISA Read as the number of bytes to read, so that you read the entire buffer contents.  You can then scan that string for the expected data.

  • Visa Read Timeout Occurs with multiple Reentrant VI Calls

    I have written a test application in Labview (6.1) which will be used to test (burn-in) up to 15 serial instruments through a 16 Port USB->RS232 Hub. Here's how it works:
    When the App loads, I am transmitting a Connect command to each of 15 com ports (one-at-a-time) using VISA. If I receive the proper response from the unit on that port, I add the port to an array and continue on to the next system. Once I've found all systems on the hub, I wire my array of active Visa references to a for loop in which I open up to 15 reentrant VIs which will run in the background in parallel. Each of these reentrant VIs (all are idential with the exception of the Visa Resource they use) running in the background are sending commands to the the respective instrument and receiving a response. One Function in particular "Get Unit Status" is important and the response determines whether or not the instrument is functioning correctly. Here's the problem -- In my Main Loop, I am continuously acquiring indicator values from each of the reentrant VIs that are running in the background. After a period of time (not consistent) I will lose communication with a port (the symptom is no response from the unit). I've looked closely at the COMM engine I created and found that the Visa Write function is completing without error, then when I perform a Visa Read I immediately get the "Timeout occured before operation completed" error (please keep in mind that this occurs after 100-5000 successful attempts at writing/reading). Eventually another port will drop out, followed by another. This seems to stop occurring and the remaining systems run to completion without a problem.
    Some background on what how I'm setting up my Visa Sessions...
    When I originally scan for systems (before I load and run the Reentrant VIs)
    - Init Visa Port
    - 19200, 8, N, 1
    - Use Termination = True
    - Timeout = 400mS (I've tried larger values already) 400mS should be plenty
    - Termination Char=13 (/r)
    - Open Visa Session
    - Visa Write "CONN18/r" (the command required to connect to my instrument)
    - Visa Read with 1 for requrested byte count to read 1 byte at-a-time, concatenating the results until /r is received (or 1000mS timeout occurs -- this is not a VISA timeout) I've also tried 16 for requested byte count and just waiting for Visa to timeout -- both methods work.
    Once all 16 ports are scanned I Close ALL of the ports using the Visa Close Function.
    It is important to know at this time that I "AM" using proper wiring flow to ensure open occurs before write, write occurs before read, etc.
    I'm assuming at this time that all of my Visa sessions are closed.
    On to the Reentrant VIs:
    Inside each reentrant VI I first Initialize all of my variables and Init/Open a 'New'? Visa session using the same parameters mentioned above.
    Then I enter the "Run" case structure where all of the communication begins.
    I am using the same Communications Engine to operate the instrument as before (the only difference being that all of the VIs in the comm engine are now reentrant and operate at higher priorities) I have actually saved two different versions of the engine (one for the reentrant calls and one for when I first scan for systems from my Main GUI).
    When I init the reentrant VI, I am placing the Duplicate Visa Resource output of my Visa Open Function on a shift register. When I enter the Run case, it takes the Resource from the register on the left, wires through any Comm Engine Vis then back out to the shift register on the right and keeps going for a 12-hour period or until "Get Unit Status" has returned 60 naughty results.
    On my Main GUI I am continuously (every 500mS) I am Getting certain Indicator Values from each reentrant VI AND I am also setting some control Values on each reentrant VI. There is no VISA interaction between each Reentrant VI, and the Main GUI.
    As I said earlier, up to 15 systems will run for a time, then one will stop responding, followed by another, and another until a few remaining systems will run to completion.
    Any advice as to why I'm encountering the timeouts with the VISA read fucntion as I have metioned would be appreciated. I managed to find one suggestion which uses the Bytes at Port function to ensure there is data at the port before doing a Read otherwise, skip the read and retry the whole operation -- I haven't tried this yet.
    Sorry for the wordiness of my question. If anyone would like some screen shots of portions of my code (I can't submit the actual code because some of it is confidential) I'd be happy to post them.
    Doug.

    Hi Doug,
    The first thing I would recommend is the solution you have already found, to check and see if there is data at the port before attempting a read. I would be interested to see if this will solve the problem. Does there seem to be any trend to which ports have this timeout error? How many ports does it cut down to before operation seems to continue as expected? Does this number vary, or is it always the same number of ports? I think the best thing to do will be to identify constant attributes of how the error is occurring so that we can narrow it down and see what is going on.
    John M

Maybe you are looking for

  • IPad as a DVD player?

    I want to watch my DVDs on an iPad but don't want to rip them into the compatible format. Will the CameraAdapter Kit work as the USB input for the super drive?

  • How do I get an xterm window (from X11 running) to be non-VT100?

    I am trying to connect to a Sun Workstation machine via a wireless connection to start up an xterm session. I want to use some graphic-intensive programs on the Sun system, but for some reason, my doing an remote ssh into the machine reports that my

  • X-Fi and Crystalizer.. how set

    what is the best set option for the 24bit crystalyzer?(now i have it a 00%...)

  • The system requirements for Lightroom 6

    The system requirements for Lightroom 6 say "OpenGL 3.3 and DirectX 10-capable graphics card for GPU related functionality" I assume that means those or later versions, as my graphics card is Open GL4.0 and DirectX 11.1.

  • Buying an iMac (the 20-inch model with 2.0Ghz Processor)

    Hello all, well, i need an iMac, because i like graphics design, so i can do better things on a Mac, but i'm a gamer, too, i play games like Call of Duty 2, Battlefield 2, etc, so that iMac must have a good video card for those 2 reasons: Graphics De