Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help me~~ recv keep missing bytes #45

Open
GoogleCodeExporter opened this issue Apr 18, 2016 · 0 comments
Open

help me~~ recv keep missing bytes #45

GoogleCodeExporter opened this issue Apr 18, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant