views:

816

answers:

2

Hi, I'm begginner in java, I'm writing ("FLASH").getbytes() like this to serialport.

After I'll get FLASH_OK as response, again I've to send file request.

After that I'll get response as FILE_OK then I have read file up to end of the file.

I'm not getting how to do this process plz help me.

Thanks for reply

A: 

Looks like to need a SerialPortReader which needs to implement a SerialPortEventListener

     public void serialEvent(SerialPortEvent event)
     {
            case SerialPortEvent.DATA_AVAILABLE:
            byte[] readBuffer = new byte[40];

            try
      {
                while (inputStream.available() > 0)
                {
                    int numBytes = inputStream.read(readBuffer);
                }
                System.out.print(new String(readBuffer));

                System.out.println();
                System.out.println("DTR: " + serialPort.isDTR());
                System.out.println("DSR: " + serialPort.isDSR());
                System.out.println("CTS: " + serialPort.isCTS());
                System.out.println("RTS: " + serialPort.isRTS());
                System.out.println();
                outputStream.write("ACTIVESYNC".getBytes());
      }
            catch (IOException e)
      {
                e.printStackTrace();
            }
VonC
+1  A: 

So I am just going to give you my stock answer: If you're working with serial comms, you want to at least take a look at SerialPort from http://www.SerialIO.com. I have found it to be very well priced, no royalties, and rock solid and stable.

I tried several serial comms libraries, Sun's, IBM's and RxTx, and had stability problems with all of them in the production environment. Whereas SerialPort has been stable since the beginning, with a 24/7 Window 200x Server for a modem to TCP/IP bridge system.

Software Monkey