Debug -> infinity
От: cradee  
Дата: 11.09.10 06:07
Оценка:
Здравстыуйте, уважаемые.

Помогите разобраться в ситуации


Eclipse Helios Release;
JDK 1.6.0_21;
Linux MCBC


Пишу приложение для работы с RS232, используя javax.comm, и одна ситуация поставила в тупик. Вот кусок кода:

public void serialEvent(SerialPortEvent event) {
        // TODO Auto-generated method stub
        switch(event.getEventType()) {
            case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
            case SerialPortEvent.BI:
            case SerialPortEvent.CD:
            case SerialPortEvent.CTS:
            case SerialPortEvent.DSR:
            case SerialPortEvent.FE:
            case SerialPortEvent.OE:
            case SerialPortEvent.PE:
            case SerialPortEvent.RI:
                break;
            case SerialPortEvent.DATA_AVAILABLE:
                byte[] readBuffer = null;
                try {
                    readBuffer = new byte[inputStream.available()];
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                try {
                    int count = 0;
                    while(this.inputStream.available() > 0) {
                        count++;
                        int numBytes = inputStream.read(readBuffer);
                    }
                    System.out.println(getHex(readBuffer));
                    System.out.println(readBuffer.length);
                    System.out.println(this.inputStream.available());
                    outputStream.close();
                    inputStream.close();
                    serialPort.removeEventListener();
                } catch (IOException e) {}
                break;


При сборке и компиляции проекта все проходит на ура, а точнее

count = 1;


Но как только пытаюсь отдебажить этот кусок цикл while уходит в бесконечность. Как такое взмжно?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.