0 Replies Latest reply on May 27, 2009 7:15 AM by 843807

    Serial Event

      Hello guys,

      this is rohit working on serial port programing in java. here m facing problems,
      i have one function for receiving data from serialport, at the time of receving it is printing right data but after that it should get out of that function although i have put a break stmt still it is not getting out of that function. please take this code and give me solution for this asap.

      *// my function

      **public void serialEvent(SerialPortEvent event) {**

      **System.out.println("start of the 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:**
      **case SerialPortEvent.DATA_AVAILABLE:**
      **// we get here if data has been received**
      **System.out.println("in the event ");**
      **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) {}**

      **System.out.println("out of main switchcase");**
      **// System.out.println("closed");**
      **// close();**
      **// serialPort.removeEventListener();**
      **// System.exit(0);**