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

byte is missing!! #44

Open
GoogleCodeExporter opened this issue Mar 31, 2016 · 3 comments
Open

byte is missing!! #44

GoogleCodeExporter opened this issue Mar 31, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

while(1)
{
    iLen = m_cInputStream.read(bytesBuffer);

    if(iLen > 0)
    {
        // Toast Show
    }


    Thread.sleep(10000);
}

example source for explain.

and i will send '0' -> then, app will show toast [ 0 ].

and i will send '1' directly -> If, it is ideal situation, then 10second after 
showing toast [1].

but didn't showing...

where is my '1'...??? why missing byte?

Original issue reported on code.google.com by [email protected] on 7 May 2014 at 9:05

@GoogleCodeExporter
Copy link
Author

and only running this app.

Original comment by [email protected] on 7 May 2014 at 9:07

@GoogleCodeExporter
Copy link
Author

Please send me whole code to verify. 

Original comment by [email protected] on 29 May 2014 at 6:49

@GoogleCodeExporter
Copy link
Author

oh i don't know your e-mail.

so, i'll write here. and simply.

base 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' -- 500ms later --> '2' -- 500ms later -> '3' ....~

then this source can't receive all of char.

Original comment by [email protected] on 3 Jun 2014 at 7:29

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