Serial Port Read Issues

I have an application that needs to read in a set-length string of 13 data readings seperated by a commas. I have a vi set up that will take the incoming string and seperate it out to its different data points. BUT, when I'm reading in the data over the serial port, I don't know how to wait until I have a complete set of 13 data points before displaying my data. I'm using a vi that extracts doubles from the string to display all 13 data points, and as each point is recieved from my test item, it scrolls through the 13 seperate data displays. All this is placed inside a while loop, so all of my data is coming in, but i'm having trouble seperating it out for display purposes. My test item will be generating the string of 13 floating point numbers seperated by commas at a rate of about 1 set every 1-2 seconds.
Basically, I need advice on how to read in a full string of 13 data points and after the full string is read in, then display them using an extract_from_string vi.
Thanks in advance
jimmyMessage Edited by JMorgan on 03-02-2005 10:50 AM

Jimmy,
Is the last data point separated by a comma or by some other character from the beginning of the next data set? If it is a different character, like a carriage return, then all you need to do is to search for that character in the received data. If the stream is continuous and no framing character occurs, then you have to count and hope it never gets out of sync.
Lynn

Similar Messages

  • Problem --serial port reading one character at a time

    Hi Friend,
    I reading the serial port  one character at a time ,  i specified it in the "serial bytes to read" option in serial port read examples.
    The problem is ----------i can able to read  the data.
    but only the first character is reading again and again...and "reading string indicator" in the serial port example shows only the first character sent ..only for a single time.since i am reading continously ----aleast the first character should display as many times i running the program
    (i am running the vi by run continous option..........)..
    please help me ....how to read the character one by one.....
    regards
    rajasekar

    Hi jason...
    I can able to read the serial port by 1 byte or 2 byte or 4 byte as i can specify it in the serial port read bytes option..(in visa serial read)..
    I need to acquire 4 bytes of data and pass it to the Math-script node..and save these 4bytes of data in array (1 row and 4 column)..
    And split this array(just like array-indexing.vi) and processing it each each column separately....
    or suggest some method to achieve my task.....please.
    one more thing the math-script node is placed in a while loop.....in order to read sequence of bytes continously.......
    regards
    rajasekar

  • How do I use serial port read and show text, but not have it scroll off screen?

    I am new-ish/returning amateur user of Labview and I am trying to edit the example VI "Advanced serial write and read VI" that is part of dev suite 2012.  I need to use the string box to show ALL text received from serial port, always appending and only rolls off screen when more real data arrives at serial port. 
    What is actually happening is as more bytes (or no bytes AT ALL!) arrive during read time, current text rolls off the string box.  Even when 0 bytes are received, screen is blanked out.  I am not very familiar with functions locations and even worse at understanding obscure references to functions, so please keep replies very basic so I can follow.
    Just to be clear, I need the string window to behave like hyperterm does-always shows data and it is not pushed out of window arbitrarily.
    Thanks,
    Steve  
    Solved!
    Go to Solution.

    OK- lets start back at the beginning.  I have a few questions...
    WHy does incoming txt get placed at top of txt box and then scroll up?  why would it make more sense to input at the bottom and scroll toward the top.  I have created this huge txt box that appears to be impossible to use.
    I have attached example of txt boxes I have tried, and pic of VI I have edited.  Bad marks for uglyness....
    Attachments:
    Capture_VI.JPG ‏117 KB
    Capture_VI2.JPG ‏133 KB

  • Multiple serial ports reading from a shared USB port

    I have a program that reads from 4 flow controllers, which send data through RS232 serial ports. Because the computer is located pretty far away, the vendor suggested to use an Edgeport box to convert RS232 to USB, then convert to ethernet port using a SuperBooster converter. The signal travels long distance in ethernet cable to the computer and get converted back to USB, then to the computer. In MAX, I was able to see 8 com ports from the Edgeport box, and I was able to communicate with my flow controllers.
    The problem is, it will give me some error message occasionally. Sometime it's a VISA Read error, sometime it's a VISA framing error. Could this be caused by the way the signal is transmitted?
    In the program I have four parallel WHILE loops that constantly do READ and WRITE to the 4 flow controllers. Could this be causing the errors? If so, what is the best strategy to design this program?
    Thanks

    I agree with Mike, you will need an error handling strategy that accounts for these errors.  And retries the communications.  This can be a little tricky, but very doable.  I believe some sort of statemachine approach will work best for this. 
    As for your heated probe.  I would make some sort of hardware interlock that will shut it down in case of a coolant failure.  NEVER, EVER trust the computer to be running where safety is concerned, either for personal or hardware.  There are plenty of ICs that can monitor temperature, and have warning, and alarm outputs!  Another option is some sort of watchdog on the communications bus for the coolant control, but I think this is a bit more tricky. 
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?

  • Serial port reads unconventional characters

    Hi,
         I'm using the serial port to read 32 8bit numbers and have been getting some strange characters read back.
        I've tested the hardware with Matlab which works fine but with Labview I get the following string
        À Ð à Ð àÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐ À
       Since these are not standard characters I can't seem to convert them to any other format. I've also used an ActiveX control (AComPort) in Matlab to do the same thing and I get the identical string above, so its something to do with the format rather than an error in the reading I think.  However if I use AComPort to read one byte at a time (rather than a string) I get the correct numbers, so could I do the same thing in Labview?
    Thanks for any help
    Emrys  

    hi there
    i bet there's something wrong with the serial port settings
    - Enable Termination Char (T)
    - Termination Char
    - data rate
    - data bits
    - polarity
    - stop bits
    you can adjust these settings with the "VISA Configure Serial Port.vi". please check if the settings are correct.
    you wrote "However if I use AComPort to read one byte at a time (rather than a string) I get the correct numbers", so try 8 databits, 1 stopbit, no parity and disabled termination character or see the documentation of AComPort .
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • Serial-port read

    Hello,
    I´m using a digital multimeter to serial port (COM1) connection to get
    0-100 mV´s from a photomultiplier, but it doesn´t work. I used the
    LabView-Serial Port VI in the read-mode. The VI proceed´s but it doesn´t
    put out any data.
    Did I use the right VI?
    Can anybody help me?
    Thanks
    Oliver

    I found some info about the Multimeter:
    I´ve got two possible modes to get data from the DMM
    1. by using send-code:
    M: DMM sends stored data
    C: DMM resets stored data
    D: DMM sends display-data
    2. without send-code
    if the COMM-button off DMM is pressed, DTR has to be set to Lo by PC. DMM will
    send display every second
    transferrate is 1200 baud
    charakter code 7-bit ASCII
    no parity
    stop-bits 2
    length of string 14 byte
    I also found a short MS-Quickbasic-file:
    CLS
    OPEN "COM1:1200,N,7,2,RS,CD,DS,CD" for INPUT A$
    INPUT #2,A$
    PRINT A$
    CLOSE #2
    END
    I used the serial-communication VI this time in order to give the DMM
    commands ( M,C,D) but the DMM didn´t answer. I set the
    data-communication-parameters in the sub VI´s, maybe that was the fault. Have
    you got any idea
    what´s wrong??
    To what, in your opinion do the characters RS,CD,DS,CD in the "OPEN COM1
    command-line stand for ??
    Thanks, for your help,
    Oliver

  • Serial Port Interface

    Please excuse me, as I am a EE student and all this Java is new to me. I am obtaining information via a TI MSP430F449 board and wish to transfer this data to my PC via the serial port. I have been told that Java is the way to go to to do this. I would like to get the data, and then a further Java program will use it to represent the data graphically. Where do I begin? I was told that there are some pre-written software that encompass a variety of avenues. Is there a pre-written program addressing this serial port read issue? If so, is it documented well so that I can make the changes to customize it to my situation? Any information you can provide will be most appreciated.

    You don't need sockets for this, socket is for network cimmunications, but there is another API for sending/receiving dara through the ports, which is the Java Comm. API, it should be your starting-point...
    download available from
    http://java.sun.com/products/javacomm/downloads/index.html
    and the user's guide is here
    http://java.sun.com/products/javacomm/javadocs/API_users_guide.html
    Good luck
    Regards,
    Mohammed Sleem

  • Problem in reading data from serial port continuously- application hangs after sometimes

    I need to read data from two COM port and order of data appearance from COM port is not fixed. 
    I have used small timeout and reading data in while loop continously . If my application is steady for sometime it gets hangs and afterwards it doesnt receive any data again. 
    Then I need to restart my application again to make it work.
    I am attaching VI. Let me know any issue.
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet
    Attachments:
    Scanning.vi ‏39 KB

    billko wrote:
    Ranjeet_Singh wrote:
    I need to read data from two COM port and order of data appearance from COM port is not fixed. 
    I have used small timeout and reading data in while loop continously . If my application is steady for sometime it gets hangs and afterwards it doesnt receive any data again. 
    Then I need to restart my application again to make it work.
    I am attaching VI. Let me know any issue.
    What do you mean, "not fixed?"  If there is no termination character, no start/stop character(s) or even a consistent data length, then how can you really be sure when the data starts and stops?
    I probably misunderstood you though.  Assuming the last case is not ture - there is a certain length to the data - then you should use the bytes at port, like in the otherwise disastrous serial port read example.  In this case, it's NOT disastrous.  You have to make sure that you read all the data that came through.  Right now you have no idea how much data you just read.  Also, if this is streaming data, you might want to break it out into a producer/consumer design pattern.
    Not fixed means order is not fixed, data from any com port can come anytime. lenght is fixed, one com port have 14 byte and other 8 byte fixed..
    Reading data is not an issue for me as it works nice but I have a query that why my application hangs after sometime and stops reading data from COM PORT.
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet

  • A problem about reading from serial port

    Hi,
       I just sent '0x03' from MCU to PC continuously, and then sent  '/n' as a stop character after every '0x03'. I use labview to read the data. The problem is when it get two '03' it get a '0', another two '03' and another a '0'. I don't know where is the '0' from?
      PS: Hyper terminal can display natrually.
       Thank you! 
    帖子被hengfo在08-08-2007 10:14 PM时编辑过了
    Attachments:
    serial read.vi ‏36 KB

    I think the problem may be the loop reading the serial port is running too fast.  There is no timing delay in the loop, so you are reading it as fast as you can, and probably faster than the device is sending data.  So sometimes the buffer is empty, and then the empty string gets converted to a numeric zero.  The way to know for sure is to put an indicator on the error wire coming out of the serial port read.  I bet you will see errors about the read buffer being empty.
    Put a wait timer in the loop to slow down the execution just slightly.  This is a good idea so that LV doesn't eat up all the CPU resources.  Look at the example for Basic Serial Write and Read.  You may want to have a loop ahead of the read that waits until there are a certain number of bytes at the port before it reads the serial port.  You may want to put a loop around the serial port that waits until a valid number is read in before it exits the loop and goes to the numeric conversion.
    Message Edited by Ravens Fan on 08-09-2007 08:50 AM

  • How do I process serial port strings as bits

    In response to my commands, my instrument is sending bytes to my serial
    port. In one instance, 2 bytes are received. I want to treat these 2 bytes
    as a group of 16 bits.
    The VISA and Compatibility Serial functions return these bytes from the
    serial port to Labview clearly labelled a "string".
    Everything I can find in the way of Labview functions and .vis don't want to
    do bit twiddling, bit swapping, and bit dropping, with "string" data.
    I thought "hex string to number" could be used here, but I can't find a way.
    The 2 Bytes in question can be represented as hex, but the data are not the
    ASCII codes for the hex representation of a binary number, they are the
    binary number. This "hex string to number" seems to want ASCII c
    odes.
    You can feed a hex number typed into a "control" box wired into "hex string
    to number" and you get a meaningful number. You can feed the 2 bytes from
    the serial port into an "indicator" set to read in hex and you get a hex
    number that is a correct representation. But that is Labview handing them
    around to itself. I need to get my "hands" on them.
    I can't feed those same bytes that show up as a correct hex representation
    in an indicator into the "hex string to number" or anything else, so far,
    and get a number that is useful for further processing.
    I thought "variant to data", but I can't find enough reference material to
    understand how to use it. A boolean array seems like a bit of a weird
    approach, so I thought I'd ask before I looked into that.
    I'm used to dealing directly with binary numbers on the processor stack, I
    call them whatever I want, and turn them into anything I feel like.
    I'm sure I'm staring the solution in the face, but I can't find any way to
    persuade
    Labview to treat this "string" data as 16 bits.
    I've got the 16 bits, which is better than not having them, but I don't have
    much hair left.

    duh, well I finally discovered the "Unflatten from String" function. A guy
    just feeds in the bytes he's collected from his serial port that Labview
    thinks are a "string", and out come lovely little unsigned 16 bit numbers,
    or whatever other type of number he wants to turn the bytes into. And there
    are great little bit twiddlers available after that, like "swap bytes", and
    you can mask out bits with the logic operators, why this is fun. There's
    nothing like being a moron...... fly me to the moon...................
    "David Lewis" wrote in message
    news:[email protected]..
    > The two bytes would come from a serial port read.vi in Labview, classed as
    a
    > string. For instance, D3 and 02. The output wou
    ld swap the two bytes,
    i.e.
    > to 02 and D3, consider the two swapped bytes as 16 bits, drop the six most
    > significant bits, and output the ten bits that are left as an integer
    > classed by Labview as some kind of number, not a string.
    >
    > Your example StringToBits_Converter.vi I found on the ni.com site
    > unfortunately gives an error message and refuses to open on my system
    saying
    > it comes from a newer version of Labview 6 than I am running. Mine says
    > 6.0.1b3. Thank you very much anyway.
    >
    > "FightOnSCTrojan" wrote in message
    > news:[email protected]..
    > > In another words, you want to create a VI in which the input is 2
    > > strings (i.e. AB) and the output is the converted array bits (e.g.
    > > 1010101010101010)?
    >
    >

  • Writing to serial port

    I currently send ASCII characters to a serial port. I have not errors reported back. Everything appears to be error free, except that the device that I am trying to control does nothing. The device being controlled does not send anything back to the pc. The connection is strictly a one way connection. Do you have to send a carriage return or something to get the ASCII characters to "push" out of the buffer? - Sorry I don't have access to my code at the moment.

    A portion of my code is below. What does the 'flush'
    do? I thought it just emptied out the buffer.
    while (portList.hasMoreElements()) {
    portId = (CommPortIdentifier)
    tIdentifier) portList.nextElement();
    if (portId.getPortType() ==
    ortType() == CommPortIdentifier.PORT_SERIAL) {
    if (portId.getName().equals("COM1"))
    .equals("COM1")) {
    try {
    serialPort = (SerialPort)
    portId.open("SimpleWriteApp",
    d.open("SimpleWriteApp", 2000);
    } catch (PortInUseException e)
    ortInUseException e) {}People get life for this crime!
    try {
    outputStream =
    outputStream =
    tStream = serialPort.getOutputStream();
    } catch (IOException e) {}So you now have two life sentences to serve.
    try {
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch
    } catch
    } catch (UnsupportedCommOperationException e) {}Sorry, three life sentences to serve.
    try {
    outputStream.write(rightString.getBytes());
    } catch (IOException e) {}You get the prize! Four life sentences from a short bit of code.
    }P.S. You should really use the COMM api for writing to serial ports.

  • URGENT: Capturing data through serial port

    Hi,
    My problem is with the use of javax.comm API. I have an RFID tag reader connected to
    the serial port. It is a handheld reader and reads tags when its trigger is pulled. The
    data that is read is sent to the serial port. This is what I want to capture.
    I tried to test the reading operation by running the SimpleRead sample. What I see is
    that I pull the trigger once to read 1 tag, but that generates 3 DATA_AVAILABLE events.
    The tag ID that is read is 16 bytes, preceded by a 3 byte AIM Identifier (that declares
    the following data was read from an RFID tag, and not a barcode which has different
    AIM Identifiers for the different symbologies - but I digress.) By inserting some println's,
    I was able to see that the 19 bytes of data are read 8 bytes at a time. The first 8 bytes
    are read on the first DATA_AVAILABLE event, the next 8 are read on the second event
    and the last 3 bytes are read on the 3rd DATA_AVAILABLE event.
    This is strange & not good for me. How can my application know that the data read in
    these 3 separate DATA_AVAILABLE events is to be concatenated to form a single
    tag ID? Why is the single trigger-pull & tag read operation broken up into chunks of
    8 bytes? Is there some configuration setting that will give me the behavior I want?
    (I cannot rely on the length of the tag ID being 16 bytes always, because the same
    reader will also be reading barcodes where the data may have varying length)
    Thanks for any help. This is really urgent.
    - Ajoy

    please use the [ code ]and [code ] tags for code.
    I don't think you have a problem with the code, it's more like understanding how to make it work.
    to make the read method return.You do not have a read() method.
    The code is behaving as it should.
    You need to use the SimpleRead class as a thread, add and remove the Serial port listener as needed.
    You read all data available, then send it to a method to parse the buffer.
    You can count how much data was read so you know how much to parse.
    I never used receive threshhold.
    Here is example (sample)of my serial port reader
    //SerialIO
       public void serialEvent(SerialPortEvent event) {
            switch(event.getEventType()) {
                  case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                break;
            case SerialPortEvent.DATA_AVAILABLE:
                this.dataManager.readData();
    //DataManager
    public void readData() {
         String str;
         int     bytes = 0;
         long endTime, now;
         try {
              while (this.owner.isComPortOpen
                   && (SerialIO.inStream.available() > 0)) {
                   bytes = SerilIO.inStream.read(this.buffer);
                   if (bytes > 0) {
                   if (bytes > this.buffer.length) {
                        System.out.println( ": Input buffer overflow!");
         **Here is where you parse your buffer
                   sendDataToParser(bytes, buffer);
              } catch (IOException ex) {
                   System.out.println( ": Cannot read input stream");
          * Stops the serialEvent listener
         protected void stopSerialEvent() {
              SerialIO.serialPort.removeEventListener();
              try {
                   Thread.sleep(2000);
                   flushInputStream();
              } catch (InterruptedException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
          * Starts the Serial event listener
         protected void startSerialEvent() {
              // TODO Auto-generated method stub
              try {
                   SerialIO.serialPort.addEventListener(SerialIO);
              } catch (TooManyListenersException e) {
                   // TODO Auto-generated catch block
                   //System.out.println("startSerialEvent in dataManager");
                   e.printStackTrace();

  • How do I monitor serial port activity without first sending a command?

    In my application I am sending a command through the serial interface and I want to monitor the response. The response is not instant, in fact it is a timeout response indicating the requested action did not work. How do I monitor so I can parse what is coming in over the serial port without necessarily sending a command?

    You can always place a loop where you monitor the number of bytes at the serial port.
    After configuring your VISA serial port session, you can create a Property Node to get the number of bytes available at serial port.
    You can then process this information, for instance:
    1. Establish a timeout because you never get a response.
    2. Do serial port read if there is data available.
    You can exit the loop with a timeout condition or having processed the data.
    -JLV-

  • Empty serial port buffer?

    Is it possible to empty the buffer of the serial input port without reading from it?

    izze wrote in news:5065000000080000002B8B0000-
    [email protected]:
    > Is it possible to empty the buffer of the serial input port without
    > reading from it?
    You have several options.
    Old standard serial VI's
    Use "Bytes at Serial Port" to get number of byte present and wire it to
    "Serial Port Read" and don't use the data from the VI.
    VISA flush buffer
    The function "VISA Flush I/O Buffer".
    This did not work for me, it took to long time.
    VISA eqvivalent of number of bytes at serial port.
    There is a VISA property to read number of bytes on the receive buffer of
    the serial port. Use this to get number of bytes and wire this number to
    the VISAread function.
    The pro
    blem is that this only works for serial port.
    Use VISA read
    -1- Get VISA timeout value (VISA property node)
    -2- Set VISA timout to 0 (VISA property node)
    -3- make a while loop with
    VISA read function with e.g 1000 bytes to read.
    End the while loop when number of bytes read is 0
    -4- Set VISA timeout back to the value set in step 1
    Rolf

  • Xlet and serial port

    does anybody know if it is possible to make an active Xlet interact with an Input Stream through the serial port?
    Roughly speaking i would use the serial connection between the STB and a PC as a sort of return channel

    like Steve, Threre is no standard inputstream of serial port in DTV environment. That bounds hardware device.
    Most of case of using serial port, STB use to view log in PC. So, if STB manufactors support serial com port in low-level by c function, you shoul check it out on STB manufactors low-level API.
    Definitely, MHP does not support inputstream from serial port.

Maybe you are looking for

  • Abends - CLIB and GWIA - me too

    Running GW 8.0.2 on NW 6.5.6 (was recommended not to patch NW due to Backup Exec) Starting at 5:02 pm on January 19th we began to get Abends on our GW server. I have since determined that we only get them when one specific user's Sprint HTC EVO estab

  • My printer's IP address isn't showing up on my config report!

    I have quite an annoying problem: I've been trying to connect my printer wirelessly for a while now, but the same problem keeps coming up: I can't seem to find my printer's IP address! I've printed out many config reports through my printer, and I've

  • Ipad 2 wifi connection with Samsung Galaxy Y phone.

    Hi All, I have a Samsung Galaxy Y GT-S5360 model phone. I'm planning to have 3G internet through vodafone in my phone. Is it possible to connect internet from my samsung phone to ipad 2(without micro-sim) by enabiling hot spot feature in my samsung p

  • How do i find out when my old desktop was purchased or built?

    We have a HP desktop model a1512x and would like to find out approx when it was sold or built.  S/N is [edited] but when I key that in on HP's site it doesn't come back with anything. Just wondered if there is someplace else to look.

  • Samsung SSD 470 and Macbook Late 2007

    Hi all, today I wanted to replace the internal HDD of my white macbook 3,1 late 2007 with a Samsung SSD 470 series 64 GB. Unfortunately, disk utility doesn't "see" the device, so I can't use it. I tried both booting from the Snow Leopard DVD and the