isrishu / android-serialport-api

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

byte is missing!! #44

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 rod12...@gmail.com on 7 May 2014 at 9:05

GoogleCodeExporter commented 9 years ago
and only running this app.

Original comment by rod12...@gmail.com on 7 May 2014 at 9:07

GoogleCodeExporter commented 9 years ago
Please send me whole code to verify. 

Original comment by i...@eurotronik.si on 29 May 2014 at 6:49

GoogleCodeExporter commented 9 years ago
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 rod12...@gmail.com on 3 Jun 2014 at 7:29