Communicating with Serial Port

Hi,
Hi I have an application that i have to communicate with serial port...
Its working perfectly if am giving all the com settings as constants(pls hav a look @ codea).
But i want to read the port number and baud reate from text file.When i changed the coding,in the serial
setting i was not even able to find the port number and baud rate.it was displaying as buffer size.I think the way i connected the port number and baudrate to the clusture may be wrong(pls refer codeb).How do i fix this problem?
Thanks in Advance....
Solved!
Go to Solution.
Attachments:
modemsetting.JPG ‏88 KB

The problem I think is that you don't have a cluster tied to the center terminal of the bundler so most of the values don't have a name. Wire the cluster from above to the center terminal on the lower bundler. BTW, it doesn't matter what values are in the cluster you wire up because they will be overwritten.
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

  • Communicating jsp with serial port

    Hi, I'm developing an web application that needs to communicate with Serial port. I'm not getting how to communicate with Serial port. I'm building application using jsp. Any one help me Please...

    package serialio;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.OutputStream;
    import java.util.Enumeration;
    import java.util.TooManyListenersException;
    import javax.comm.CommPortIdentifier;
    import javax.comm.PortInUseException;
    import javax.comm.SerialPort;
    import javax.comm.SerialPortEventListener;
    import javax.comm.SerialPortEvent;
    import javax.comm.UnsupportedCommOperationException;
    * @author SASH
    public class SimpleWrite
    implements Runnable, SerialPortEventListener {
    public String line = "";
    public String line1 = "";
    public String text1 = "";
    public String text2 = "";
    public void run() {
    static Enumeration portList;
    static CommPortIdentifier portId;
    // static String dest = "0517111930";
    static String messageString = "Hello";
    InputStream inputStream;
    static SerialPort serialPort;
    static OutputStream outputStream;
    public void serialEvent(SerialPortEvent event) {
    switch (event.getEventType()) {
    case SerialPortEvent.DATA_AVAILABLE: {
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    try {
    while ((line = reader.readLine()) != null) {
    arata(line);
    // System.out.println(line);
    } catch (IOException e) {
    System.err.println("Error while reading Port " + e);
    break;
    } //switch
    public int getWrite(SerialPort serial) {
    try {
    inputStream = serial.getInputStream();
    outputStream = serial.getOutputStream();
    try {
    serial.addEventListener(this);
    } catch (TooManyListenersException e) {
    System.out.println("Exception in Adding Listener" + e);
    serial.notifyOnDataAvailable(true);
    } catch (Exception ex) {
    System.out.println("Exception in getting InputStream" + ex);
    return 0;
    public static void main(String[] args) {
    portList = CommPortIdentifier.getPortIdentifiers();
    while (portList.hasMoreElements()) {
    portId = (CommPortIdentifier) portList.nextElement();
    if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
    if (portId.getName().equals("COM3")) {
    try {
    serialPort = (SerialPort) portId.open("SimpleWriteApp", 9600);
    SimpleWrite wr = new SimpleWrite();
    System.out.println(wr.getWrite(serialPort));
    } catch (PortInUseException e) {
    System.out.println("Port In Use " + e);
    try {
    outputStream = serialPort.getOutputStream();
    return;
    } catch (IOException e) {
    System.out.println("Error writing to output stream " + e);
    try {
    serialPort.setSerialPortParams(
    9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {
    public String arata(String line) {
    System.out.println(line);
    if (line == null ? "250075C54CD9" == null : line.equals("250075C54CD9")) {
    System.out.println(text1);
    return "250075C54CD9";
    } else if (line == null ? "1D00451A3270" == null : line.equals("1D00451A3270")) {
    System.out.println(text2);
    return "1D00451A3270";
    return line;
    this code is working correct getting output at system output terminal but i want use further in as input for my jsp how to get this ?.......
    arata method is also working correct in class but it is not returnig value in jsp?
    plz give me way how to take string as input ...........

  • Any way to communicate with Serial PORT using JavaScript

    is there any way to communicate with Serial PORT using JavaScript ??
    Dont tell me to do it in java because I need to this on client side not on server side.
    such as when client pressed the button, a javascript function will be called and in that function I need to communicate with the serial port of that client... That action will not go to server side.

    Is there any way to send a string of bytes to the serial port from the client side ?
    Just a button on the web page that sends out stuff to the comport.
    I was hoping to do this using java script also ..

  • Use a HP 34970a with serial port

    Hello,
    I have labview 7.0 and I have to use a HP 34970a with serial port.
    Can anyone say to me any advice to do it?
    Where can I find some material?
    Thanks
    Vincent

    Hi Vincent,
    > I have labview 7.0 and I have to use a HP 34970a with serial port.
    > Can anyone say to me any advice to do it?
    > Where can I find some material?
    Your first step should be visiting http://ni.com/idnet and search for an
    instrument driver for your device (in this case I can promise you will
    find one).
    The "Learn" link on the same page tells you more about instrument
    drivers in general which could be helpfull if this is the first time you
    are working with instrument drivers.
    Rico

  • Problems with serial port synchronization.

    Hello to all!
    I have an oxygen analyser, the equipment has a serial port for communication, being based the communication on the AK communication protocol.
    In order to request to the equipment that responds with the measured value, the following command in hexadecimal is sent:  (02 78474B4FE20 03), obtaining like hexadecimal answer the following: (02 58474B4FE203220323038353030 03), in which it is included the measured value.
    I need to have the measurement from equipment in a PC, using the AK protocol and the serial port. For this, I have made a (vi) that it writes the read measure command in the serial port, wait a time (150ms) and read the port, this way everything works correctly, but there is a problem and it is that the communication is very slow due to the delay between the writing and the reading.
    If I eliminate the delay, the synchronization between the writing and the reading is lost, appearing readings of value 0. I think that is because the PC read the port and the analyser not yet has responded to the request from PC, and this happens in spite of using the options of synchronization of visa read and visa write vi's, (Do I/O synchronously).
    I would need to design a (vi) that hoped that the equipment had sent the last data, and then it sends the reading request again, being able this way to make the communication more fast and to eliminate the erroneous readings.
    I have attached two examples, first is (vi) that works well, but has the problem of being slow due to the delay, and the second analyzes the received message to know when this complete and then it writes another message of read to analyser, but it appears to me an error (ocurred AT sights read... Time out) after minutes.
    I would thank any aid that somebody could offer to me.
    Greetings and thanks!
    Attachments:
    Test_AK.zip ‏32 KB

    I don't have a serial port connected on this machine at the moment (they are becoming rare on laptops!) but try this code as a starting place. I notice in your second example you are basing the read on receiving a specific string, in the one I've made you can set the bytes at port compare to a number equivalent in length. I haven't tried it, as I mentioned before, so I appologize for any errors in my code.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion
    Attachments:
    serial read.vi ‏67 KB

  • Is there a Labview Chroma6310 driver that works with serial port instead of GPIB?

    The driver that I have downloaded from NI site is based on GPIB, I need to run it via serial port. I don't have GPIB board. I am pretty new in NI world. How easily can I convert the GPIB driver to serial port (ASRL)? Has anybody already done this? Any help on this is highly appreciated.
    Best regards,
    Farsh

    I haven't looked at the driver and I'm not familiar with the instrument but the conversion should be pretty simple. If it uses VISA for the GPIB communication, the conversion is already done. VISA works with both GPIB and serial - just use the name of the serial port as the VISA reference name. This would be ASRL1 or Com1. If it's an older driver with the traditional GPIB calls, then replace every instance of GPIB Write and GPIB Read with VISA Write and VISA Read. You might also have to add some line terminator like CR/LF to every write. There are a lot of instrument drivers that are compatible with both serial and GPIB. The HP34970 is one that comes to mind. You might want to look at it to see how to do it yourself.

  • Error 37 with serial port / no with hyperterminal

    I have added to my Pc a card with two serial port, I can access to them by hyperteminal or by labview but only at port 0 and 1 at the same time or 2 and 3, if not I have an error 37. What can I do?

    Error 37 means that LabVIEW cannot find the appropriate serial device. This indicates that one of the following conditions exists:
    LabVIEW cannot open the specified serial port;
    LabVIEW cannot find the file serpdrv.
    Make sure that the serial driver was installed before the board, and that the com ports appear normally in the control panel. If you cannot get it working, contact NI through either phone or email support. Since there are several potential causes, this is difficult to diagnose without more information. You can contact NI using the following webpage.
    http://sine.ni.com/apps/we/niae_asc.main
    Kim L.
    Applications Engineer
    National Instruments

  • Thinkpad with serial port (RS232)

    For my job I need a laptop with a serial (RS232) port.
    I have the choice of the following laptops: Lenovo Thinkpad X230, X230T, T430, T530, W530.
    Neither of them have a serial port, right?
    I saw some mention of an adapter for the ultrabay slim bay, that would support an RS232 adapter.
    Does that work for all the above mentioned models?
    And if so, would the RS232 port work in the same way as the regular one? I need to program e.g. an Agilent datalogger with Labview to measure and recieve the measured data through the serial port.
    Kind regards,
    Rachel.

    thare are two ways :
    1. you can buy a usb to seial cable converter.
    2. if your laptop have a Docking Station. there is a serial port in the Docking station.  Put your laptop on the Docking station, the windows system will automatically recognizes the serial port.
    For example, my laptop is thinkpad x61t,  Itself does not have any serial port, But there is a serial port on the Docking station.
    I am a volunteer, don't work for Lenovo. I am a software engineer.
    thinkpad x61t, os:win7 Awavo Software com port monitor serial port monitor

  • Communicating with serial peripherals via cFP 2120

    Hi, I'm using a cFP 2120 for taking measurements from RTD's and I connected the cFP to my PC using an ethernet cable. Since I have to read data also from a temperature controller which communicates using a serial port RS232, I want to know if I can plug it to the cFP, and how can I configure it with MAX or read from LW.
    Thanks
    sandrino82

    I have several applications that do this very thing.
    You can use the RS232 port on the cFP to talk to your instrument.   There are a couple of issues to consider.   The cFP does not have a VISA Server in it.  That means that the cFP can't make the COM port available to the network.  The cFP COM port must be accessed by a vi running on the cFP and the data passed on to the remote PC.  The COM port should always be fully configured by your vi.  There is no need to use MAX.
    Can you describe your existing software?  Does it include a host and target?

  • Programmig with Serial ports

    Iam trying to send a message from my PC to a simulator through serial ports.Does anyone help me how can i proceed?

    check out the javax.comm package and documentation, it has some sample programs for sending and recieving on the serial ports. Be careful with the installation, there have been some threads about this lately, but some of the files need to be installed in c:\program files\jre or similar, you can search the forum. Hope this helps :)

  • Hp laptops with serial ports

    are there any laptops by hp that have a serial port along with usb?? I really need a true serial port.

    Hi 241R ,
    Here is a link to probook 6470b which has a serial port -http://www8.hp.com/h20195/v2/getpdf.aspx/c04296097​.pdf?ver=4
    Hope it helps
    Regards,
    PraTH_KR
    Although I am an HP employee, I am speaking for myself and not for HP.
    **Click on “Kudos” Star if you think this reply helped** Or Mark it as "Solved" if issue got fixed.

  • Fastest Thinkpad with serial port

    Hello!
     what is the fastest thinkpad with dock station or port replication that still have the serial port that has been produced?
    Is it the X60 ?
    I have my faithful T30 but it is a little slow now...
    Ciao

    Welcome to the forum!
    Although the integrated serial port died with T30 and A31p, it's still available on dock for most newer ThinkPads:
    http://www-307.ibm.com/pc/support/site.wss/MIGR-61297.html
    Good luck.
    Cheers,
    George
    In daily use: R60F, R500F, T61, T410
    Collecting dust: T60
    Enjoying retirement: A31p, T42p,
    Non-ThinkPads: Panasonic CF-31 & CF-52, HP 8760W
    Starting Thursday, 08/14/2014 I'll be away from the forums until further notice. Please do NOT send private messages since I won't be able to read them. Thank you.

  • Looking for 17 inch tecra with serial port

    do they exist?
    any current models with rs-232 serial port still on board?
    i know the 14 inch models have it, but i need a 17 inch model..
    grt

    Pretty sure there are no 17" Tecra models.

  • Problem communicating via serial port in Linux

    Hello,
    I am trying to transfer data via serial port, in Linux.
    But it is impossible till now!
    I get Runtime exception.
    Here is my code:
    public class Main {
        public Main() {
        int num=5;
        int[] array = new int[5];
        public static void main(String args[])  {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    array[0]=1;
                    array[1]=2;
                    array[2]=3;
                    array[3]=4;
                    array[4]=5;
                    new ParallelCommunication(num,array);
    import java.io.*;
    import java.util.*;
    import javax.comm.*; // for SUN's serial/parallel port libraries
    //import gnu.io.*; // for rxtxSerial library
    public class ParallelCommunication implements Runnable, SerialPortEventListener {
       static CommPortIdentifier portId;
       static CommPortIdentifier saveportId;
       static Enumeration portList;
       InputStream inputStream;
       SerialPort serialPort;
       Thread readThread;
       static OutputStream outputStream;
       static boolean outputBufferEmptyFlag = false;
       int num;
       int[] array;
       public ParallelCommunication(int this_num,int[] this_array) {
          boolean portFound = false;
          String defaultPort;
          num = this_num;
         array=new int[this_array.length];     
          array = this_array;     
          // determine the name of the serial port on several operating systems
          String osname = System.getProperty("os.name","").toLowerCase();
          if ( osname.startsWith("windows") ) {
             // windows
             defaultPort = "COM1";
          } else if (osname.startsWith("linux")) {
             // linux
            defaultPort = "/dev/ttyS0";
          } else {
             System.out.println("Sorry, your operating system is not supported");
             return;
    //      if (args.length > 0) {
    //         defaultPort = args[0];
          System.out.println("Set default port to "+defaultPort);
          // parse ports and if the default port is found, initialized the reader
          portList = CommPortIdentifier.getPortIdentifiers();
          while (portList.hasMoreElements()) {
             portId = (CommPortIdentifier) portList.nextElement();
             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (portId.getName().equals(defaultPort)) {
                   System.out.println("Found port: "+defaultPort);
                   portFound = true;
                   // init reader thread              
                   initialize();
                   break;
          if (!portFound) {
             System.out.println("port " + defaultPort + " not found.");
       public void initwritetoport() {
          // initwritetoport() assumes that the port has already been opened and
          //    initialized by "public void initialize()"
          try {
             // get the outputstream
             outputStream = serialPort.getOutputStream();
          } catch (IOException e) {}
          try {
             // activate the OUTPUT_BUFFER_EMPTY notifier
             serialPort.notifyOnOutputEmpty(true);
          } catch (Exception e) {
             System.out.println("Error setting event notification");
             System.out.println(e.toString());
             System.exit(-1);
       public void writetoport(int counter) {
          try {
             // write string to serial port
             outputStream.write(String.valueOf(array[counter]).getBytes());
          } catch (IOException e) {}
       public void initialize() {
          // initalize serial port
          try {
             serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
          } catch (PortInUseException e) {System.out.println("Port In Use.");}  //******Here is the Exception******
          try {
             inputStream = serialPort.getInputStream();
          } catch (IOException e) {}
          try {
             serialPort.addEventListener(this);
          } catch (TooManyListenersException e) {}
          // activate the DATA_AVAILABLE notifier
          serialPort.notifyOnDataAvailable(true);
          try {
             // set port parameters
             serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                         SerialPort.STOPBITS_1,
                         SerialPort.PARITY_NONE);
          } catch (UnsupportedCommOperationException e) {}
          // start the read thread
          readThread = new Thread(this);
          readThread.start();
       public void run() {
          // first thing in the thread, we initialize the write operation
         initwritetoport();     
         for(int i=0; i<=num_of_inputs; i++) {
            // write string to port, the serialEvent will read it
            writetoport(i);
         serialPort.close();     
       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:
             // we get here if data has been received
             byte[] readBuffer = new byte[20];
             try {
                // read data
                while (inputStream.available() > 0) {
                   int numBytes = inputStream.read(readBuffer);
                // print data
                String result  = new String(readBuffer);
                System.out.println("Read: "+result);
             } catch (IOException e) {}
             break;
    }...and the outcome is :
    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
    Error opening "/dev/ttyS0"
    tcgetattr(): Input/output error
    at com.sun.comm.LinuxDriver.getCommPort(LinuxDriver.java:66)
    at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:369)
    at ParallelCommunication.initialize(ParallelCommunication.java:128)
    I have searched a lot and I couldn't find a solution.
    Thank you.

    I'm having the same problem this helped somewhat debug the problem
    http://bloggerdigest.blogspot.com/2006/11/linux-serial-com-port-diagnostic-test.html
    I'm running Suse 10.3 and apparently it does not recognize my serial ports. So before
    you can test your Java code you have to figure out how to make linux see the ports.
    If I find a solution I'll let you know but if you find one first let me know. Thanks.

  • P35 Neo Combo won't boot with Serial Port disabled

    Need to disable onboard serial to free up Com1 for new PCI Serial card. Older DNC program needs to use COM1. As soon as the onboard Serial Port is disabled the PC won't boot. Have updated BIOS to latest version. Have seen a couple other people mention this on the net but no solutions yet. Any ideas?

    Probably a BIOS bug.
    Try contact MSI for on this issue and see if they could provide any fix.
    >>How to contact MSI.<<

Maybe you are looking for

  • How can I re-activate my creative cloud  with a firewire disc in target mode?

    I am a hurrricane evacuee. I have lost my home to flooding. It will be months before I get my original internet connection back, if ever. I am staying at a friends and they have wifi, but I am not allowed to reboot their router or their modem. I have

  • Restrict WBS Element Type During Element Creation

    I have our Finance dept who is wanting to create a role that will restrict the users to creating ONLY a Statistical WBS Element, and no other type of WBS element.  I have looked through the auth objects associated with CJ30, CJ20N, CJ01 and CJ11, but

  • I know this is sooo basic, but how do I change the owner name?

    Sorry for such a basic question. I just bought this for my daughter and set it up and it has my name at the top toolbar and I want to change it to her name. Thanks.

  • User Roles and Authorizations

    As we know in MM different user have different roles to play and they need different SAP transaction and related activies. In SAP we define the particular user who are actually allow to access only certain transactions only? What are the steps to do

  • Jdeveloper and Jade

    hello developer my problem is the next one I program a system multi agents for the research of information and I don't manage to make the tie between JDeveloper and Jade if someone has some documentations on this topic, prayer to help me thank you be