目前我已经实现写命令到串口读数据,然后将串口数据读到缓冲区,但是不能读全,我做的现在最多只能读到1545个字节,
但是我需要的远不只这么多,请问应该怎么处理呢。代码如下:
while (in.available() > 0) {
numByte = in.read(readBuffer);
numBytes += numByte;
System.out.print(numBytes);
for(;m<numBytes;m++)
{
String hex = Integer.toHexString(readBuffer[m] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
str1[m]=hex;
a+=hex;
}
} // while
但是我需要的远不只这么多,请问应该怎么处理呢。代码如下:
while (in.available() > 0) {
numByte = in.read(readBuffer);
numBytes += numByte;
System.out.print(numBytes);
for(;m<numBytes;m++)
{
String hex = Integer.toHexString(readBuffer[m] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
str1[m]=hex;
a+=hex;
}
} // while
byte[] buf=new byte[1024]while((len=in.read(buf))!=-1)
{}