esh0 / android-serialport-api

Automatically exported from code.google.com/p/android-serialport-api
0 stars 0 forks source link

help me~~ recv keep missing bytes #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
hello. again...

i don't know your e-mail.

so, i'll write here. and simply.

base source code is this android-serialport-api.

and only changed SerialPortActivity.java file.

--- original source ---------------------------
private class ReadThread extends Thread {

        @Override
        public void run() {
            super.run();
            while(!isInterrupted()) {
                int size;
                try {
                    byte[] buffer = new byte[64];
                    if (mInputStream == null) return;
                    size = mInputStream.read(buffer);
                    if (size > 0) {
                        onDataReceived(buffer, size);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
                } catch(Exception e){    }
            }
        }
    }

---------------------------------------------------
----- and changed ---------------------------------
private class ReadThread extends Thread {

        @Override
        public void run() {
            super.run();
            while(!isInterrupted()) {
                int size;
                try {
                    byte[] buffer = new byte[64];
                    if (mInputStream == null) return;
                    size = mInputStream.read(buffer);
                    if (size > 0) {
                        onDataReceived(buffer, size);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
                } catch(Exception e){    }

                try
                {
                    Thread.sleep(1000);
                }catch(InterruptedException e){      }
            }
        }
    }
---------------------------------------------
just added
     Thread.sleep(1000);

and try to send '1' -- 600ms lather --> '2' -- 600ms later -> '3' ....~

then this source can't receive all of char.

this source will received '1', '3', '5'....~

Original issue reported on code.google.com by rod12...@gmail.com on 2 Jul 2014 at 8:40