目前在做一个串口通信的app,过程中pc模拟单片机给开发板串口发送命令时候出现了问题,inputStream.read方法一直阻塞,完全无法读取到数据,用了网上一个方法,while判断size=-1时候跳出循环,实际上,根本不会跳出去。
read方法是这样的:
*Reads some number of bytes from the input stream and stores them into
* the buffer array <code>b</code>. The number of bytes actually read is
* returned as an integer. This method blocks until input data is
* available, end of file is detected, or an exception is thrown.
*
* <p> If the length of <code>b</code> is zero, then no bytes are read and
* <code>0</code> is returned; otherwise, there is an attempt to read at
* least one byte. If no byte is available because the stream is at the
* end of the file, the value <code>-1</code> is returned; otherwise, at
* least one byte is read and stored into <code>b</code>.
*
* <p> The first byte read is stored into element <code>b[0]</code>, the
* next one into <code>