目前我已经实现写命令到串口读数据,然后将串口数据读到缓冲区,但是不能读全,我做的现在最多只能读到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
解决方案 »
- myEclipse自带的tomcat启动正常换成本地安装的Tomcat加载SSH项目就不能启动报错Skipped installing application
- 为什么我访问8080端口
- 下列java代碼有什麽錯誤?
- 求解:myeclipse8.6为什么连接不上数据库sql05呢?
- 关于html的一个问题
- 有关Regular expressions
- 跪求解释 看不懂 jls.............类型参数和类型变量不是在运行时具体化的。因此,不同的参数化类型是由相同的类或接口在运行时实现的
- Vector的一个小问题。
- 小小问题请解决!
- Java 工具
- 跪求sybase或oracle数据库中怎么才能实时获得某个表新插入的数据
- java命令抛出java.lang.UnsupportedClassVersionError异常
byte[] buf=new byte[1024]while((len=in.read(buf))!=-1)
{}