Text strings from VISA read don't match identical looking text constants - could it be double byte characters"

Our RS232-enabled instrument sends ASCII strings to COM 1 and I read strings in. For example I get the string "TPM", or at least it looks like "TPM" if I display it. However, if I send that to the selector input of a Case structure, and create a case for "TPM", whether the two appear to match varies. Sometimes it matches, and measuring its length returns 3. Sometimes it measures 7 or 11 or 12 characters long, and it doesn't match. I can reproduce a match or a mismatch by my choice of the command that went to the instrument prior to the command that causes the TPM response, but have made no sense of this clue. I have run it through Trim Whitespace, with Both Ends (the default) explicitly selected. I have also turned the string into a byte array, autoindexed a For loop on that, and only passed the bytes if they don't equal 32, or if they don't equal 0, thinking spaces or nulls might be in there, but no better.
The Trim Whitespace function's Help remarks that it does not remove "double byte characters". But I can't find anything else about "double byte characters". Could this be the problem? Are there functions that can tell whether there are "double byte characters", or convert into or out of them? By "double byte characters", do they just mean Unicode?
Solved!
Go to Solution.

Cebailey,
The double byte characters are generally used for characters specific to languages other than English.  If you display your message in  " '\' Codes Display"  in a string indicator do you see any other characters?   You could also use Hex Display to see count the number of bytes in the message.  You are probably getting messages with non-printable characters that might need to be trimmed before using your application.  If you want more information the '\' Codes Display, there's a detailed description found in the LabVIEW Help.  You can also find the same information on our website in the LabVIEW Help.  Backslash ('\') Codes Display
Caleb WNational Instruments

Similar Messages

  • How to search/split a string from visa read

    hello all, i have a string coming from the serial port... the pattern is:
    \00\s\s\s\s0,\s\s\s\s12,\s\s\s\s\s0,\s\s\s\s\s0\r\n
    where the data is read as 0, 12, 0 , 0. i would like to save this data into a Write to Measurement File, for which i have to convert this text data into decimal format. can anyone please suggest me how to reduce the data from the string? I know I can save the data in a text file, but i am limited to use the Write to Measurement FIle.vi
    please help.
    Now on LabVIEW 10.0 on Win7

    Hello LV_Enthu,
    Have you played around with the functions in the Functions palette>>String at all? There are a few helpful functions like search/split strings and match string pattern that can be helpful, but here is an example from our website as well that does just this. Please let me know if you have any further questions.
    Thank you,
    Deborah Y.
    LabVIEW Real-Time Product Marketing Manager
    Certified LabVIEW Architect
    National Instruments

  • Display FFT of input signal which receive from VISA read ?

    Hi.
    I receive data from MCU whcih sampling frequency is constant and we assumed it is S. now I get data from MCU with using VISA read block. I can display data, perform some functios like filtering, multiply and save them in txt files. all thing is OK.
    but when I want to see FFT of incomig data on chart , it doesn't work !! I use this VI for calculate and display FFT of input signal (from VISA read) and display it which in Y-Axis is magnitude and X-Axis is frequency. 
    in your mind why this is not work and what I must done for show input signal FFT and frequency components ?
    Thanks.

    If I understood this correctly, you are getting the correct results when outputting to a text file but you are not able to see the results when trying to output to a chart?
    This discussion may be of some help to you.
    Rob S
    Applications Engineer
    National Instruments

  • Double byte characters in a String - Help needed

    Hi All,
    Can anyone tell me how to find the presence of a double byte ( Japanese ) character in a String. I need to check whether the String contains a Japanese character or not. Thanx in advance.
    Ramya

    /** returns true if the String s contains any "double-byte" characters */
    public boolean containsDoubleByte(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isDoubleByte(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a double-byte character */
    public boolean isJapanese(char c) {
      if (c >= '\u0100' && c<='\uffff') return true;
      return false;
    // simpler:  return c>'\u00ff';
    /** returns true if the String s contains any Japanese characters */
    public boolean containsJapanese(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isJapanese(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a Japanese character. */
    public boolean isJapanese(char c) {
      // katakana:
      if (c >= '\u30a0' && c<='\u30ff') return true;
      // hiragana
      if (c >= '\u3040' && c<='\u309f') return true;
      // CJK Unified Ideographs
      if (c >= '\u4e00' && c<='\u9fff') return true;
      // CJK symbols & punctuation
      if (c >= '\u3000' && c<='\u303f') return true;
      // KangXi (kanji)
      if (c >= '\u2f00' && c<='\u2fdf') return true;
      // KanBun
      if (c >= '\u3190' && c <='\u319f') return true;
      // CJK Unified Ideographs Extension A
      if (c >= '\u3400' && c <='\u4db5') return true;
      // CJK Compatibility Forms
      if (c >= '\ufe30' && c <='\ufe4f') return true;
      // CJK Compatibility
      if (c >= '\u3300' && c <='\u33ff') return true;
      // CJK Radicals Supplement
      if (c >= '\u2e80' && c <='\u2eff') return true;
      // other character..
      return false;
    /* NB CJK Unified Ideographs Extension B not supported with 16-bit unicode. Source: http://www.alanwood.net/unicode */
    }

  • How do I know that there are double-byte characters in s String?

    Hi!
    If I have a String that contain English and Chinese words,
    How do I know that the String contain double-byte characters(Chinese words)?
    Following is my method and the problem I suffered...
    String A = "test(double-byte chinese)test";
    byte B[] = A.getBytes();
    if(A.length() != B.length)
    System.out.print("String contains double-byte words");
    else
    System.out.print("String does not contain double-byte words");
    If the String contains Chinese words,then A.length() will be smaller than B.length...
    I run the program on Window NT workstation(Tradtional Chinese version) and it works...
    Then I run the same program on Redhat 6.0(English version),
    but the result was not the same as running on NT...
    because A.length() always equal to B.length...
    I guess that's because of Charset of OS...
    But I don't know how to set the Charset of Linux...
    Does anybody have other solution to my problem?
    Any suggestion will be very appreciate!

    A String is always in Unicode. You cannot see what kind of character is in the string unless you compare with the Unicode range of charcters. E.g. 3400-4DB5 is CJKUnified Ideographs extension A. Then you at least know that is is not Latin-1 or other.
    Klint

  • How do I avoid Error 85 in Scan From String scanning VISA read buffer?

    I have encountered an Error 85 with my Scan From String VI. I have a timed
    loop to read data from a device (flowmeter) using a serial port. This device takes
    periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
    between measurements may vary, so I decided a timed loop would be better than a while loop.
    The VI begins with VISA Configure Serial Port and then
    goes to a VISA Write which sends the message to the device to begin
    taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
    am taking the read buffer two places.
    First, I am taking it to an Array to Spreadsheet String with the
    Format String %.3f, as was in the Write to Text File example. Then I am
    using Concatenate Strings with this string and also a string containing
    the System Time. This string goes to Write to Text File, which I have
    configured using Open/Create/Replace File outside of the loop.
    Second, I am taking the read buffer to a waveform chart. I thought
    it would be a good idea to use Scan From String to convert the string
    into a DBL which I am then sending to the waveform
    chart.
    I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
    Also the format string for my Scan From String is %.3f
    I am getting the Error 85 at the Scan From String only sometimes.
    When this happens, there is no data being written to the text file. But
    other times, I get data and it writes to the text file just fine (but
    rounds to nearest whole number).
    Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.

    Is this what you mean? Did I wire the shift registers correctly?
    I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
    Message Edited by YeungJohn on 11-20-2008 03:48 PM
    Message Edited by YeungJohn on 11-20-2008 03:49 PM
    Attachments:
    SerialShiftVI.JPG ‏87 KB

  • Encoded double byte characters string conversion

    I have double byte encoded strings stored in a properties file. A sample of such string below (I think it is japanese):
    \u30fc\u30af\u306e\u30a2
    I am supposed to read it from file, convert it to actual string and use them on UI. I am not able to figure how to do the conversion -- the string contains text as is, char backslash, char u, and so on. How to convert it to correct text (either using ai::UnicodeString or otherwise)?
    Thanks.

    Where did this file come from? Some kind of Java or Ruby export? I don't think AI has anything in its SDK that would natively read that. You could just parse the string, looking for \u[4 characters]. I believe if you created a QChar and initialized it with the integer value of the four-character hex string, it would properly create the character.

  • What does the number returned from VISA Read STB represent?

    The value seems to correspond to ibsta, but I thought Read STB returned the status of the instrument, not the bus. If the former is the case, how can the instrument have a status value of 64 (REN/40 + CIC/20 + LACS/4) since it is a counter and is not capable of being the CIC. Any thoughts?
    Thanks,
    Chris

    Read STB issues a *STB? command which retrieves the contents of the instrument's status byte register. Decimal 64 corresponds to bit 6 (RQS/MSS set). The device is sending SRQ. It is not the same thing as ibsta at all. Your instrument manual should have a section on it's status byte register.
    And if it was ibsta, decimal 64 is still bit 6 only (2**6 = 64) and not bits 2, 5, and 6. REM, CIC, and LACS all being set would be decimal 100 (REM=64, CIC =32, LACS=4).

  • 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

  • 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

  • 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.

  • Characters from VISA not in ascii

    I am using ARM Cortex Microcontroller. I am sending the numbers into lab view through usb port.
    In such case, the strings obtained from VISA Read are not ascii but i can convert them into unsigned int with the help of string to uint premitive.
    The numbers to be sent are continuous and they consist of u8, u16 and also float values.
    So the problem here is the conversion. only those value which are defined as u8 are displayed correctly.
    How do i convert into appropriate values.
    E.g. if the value is integer but greater than 255 i should be able to read and display.
    If the value is float i should be able to display the proper float number.
    I also tried with scan string premitive, also string to number premitive. They can only read ascii and convert, but the characters i am converting are not ascii.
    The characters i am receiving look like boxes and for a value of 0 they are empty space.
    To convert a number into ASCII in my microcontroller could also be possible but the requirement here is with lab view. Microcontroller currently has huge load of programs.
    I would be happy if someone whould help me in this.
    Thanks in advance.
    Solved!
    Go to Solution.

    Sorry for the mistake to write it is string to byte.
    The necessary clippings are as below. The second clipping 'read buffer' is from a series of transformation where, first data is 300, second is 1 and third is 1.23. The output for these as seen in the third picture is 44, 1 and 1. Yes, 300-256 = 44, previously i wrote 45.
    According to you, do you mean that the first two byte should correspond to 300 ? and also similar for the float (not only one byte value but with several values in consecutive elements of the array)?
    I would be happy if similar clips would be avialable.

  • VISA Read Timeout and VISA Write not working

    I'm writing a program that sets a triangle wave pattern voltage (using Triangle Wave VI) to a DC power source (GWInstek PST-3202) through a RS-232 connection.  I know my instrument parameters are set up correctly because I've been able to control this power source using a different VI with the same parameters.  I also know I am connected to the power source because I can talk to it using MAX.  I have a string indicator before my VISA Write statement that shows me the command being sent to VISA Write.  It shows the correct syntax for setting a voltage on this instrument.  However, when I run the VI, the voltage is not changed on my instrument, even though the correct command is sent to the instrument.  After the VISA Write operation I have inserted a VISA Read function in order to read the newly set voltage from both a numeric and a waveform indicator.  Using the Error Out cluster I am able to see that there is a timeout error from VISA Read.  I thought perhaps I needed to clear or flush the buffer after each Read statement, but that didn't work either.  I'm stumped as to why VISA Write isn't writing to the device.  I have included my VI below, as well as the initialization subVI for the power supply.  
    Attachments:
    Triangle Volt Mod.vi ‏27 KB
    GW Instek initialization.vi ‏18 KB

    Yep, you need to append the End of Line character to the end of your command.  And for your read to work properly, you need to request the data.  That requires a querry command to be sent.  Look closely at the differences in command and communication structures between your working VI and your mod.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to store the data coming from visa into file

    Hi ,
    I want to store the data into text file,which is coming from visa-read.
    I tried visa read to file ,but it's not working.
     Am new to labview plz help me out.
    Thanks in advance. 

    CSFGF wrote:
    Hi ,
    I want to store the data into text file,which is coming from visa-read.
    I tried visa read to file ,but it's not working.
     Am new to labview plz help me out.
    Thanks in advance. 
     Share the code you have so far with us so that we can check what's going wrong.

  • About VISA read

    If I wrote different values to different registers by using VISA write. Then I connected a VISA read after the last VISA write. How can I know the read buffer returned is from which register?

    Hi,
    this is the capture:
    the instrument is Emcore TTX 1994, and the application note is attached. I only want to read the value from a certain register, but there are many VISA writes concatenated before VISA read, so I don't know which value is returned from VISA read.
    Attachments:
    11FM1046B - TTX1994 application note.pdf ‏4150 KB

Maybe you are looking for

  • When converting a Word doc to a PDF the pictures are surrounded by a blue shadowed boxes

    I started off with a PDF, then converted to a Word doc, made necessary changes, and converted back to a new PDF.  However, the new PDF has put blue colored boxes around all the pictures.  Anyone know how to fix?

  • [8i] Query with lots of subqueries: a simpler way to do this query?

    Ok, so generally, my problem is that I can't figure out how to write this query without including a bunch of copies of the same subquery (similar to having to join multiple copies of a table). Basically, I have to get information that's in rows in on

  • Problem in statistical run

    Hi, can any body clarify my doubt, while i am running the statistical setup i have given termination time less than actually it want.for this reason only half of the records are extracted.Now tell me wht about the remaining records? How can we get th

  • WDPortalNavigation with portal not running on WD server

    Hello, I am trying to get my application to close itself and replace itself with a non-WebDynpro iView. I have been attempting to use: WDPortalNavigation.navigateAbsolute("ROLES://portal_content/contentlib/corporate/mss/iviews/test_iview",           

  • Export docx track changes and comments

    Mavericks latest and Pages latest Export .docx file and the recipient reports that: comments do not transfer over tracked changes do not appear in text only as an indication of change box at start of each line colour assigned to author (green) in Pag