问题描述
我已经在Unity中安装了Android Java插件,并创建了一个系统,该系统使用蓝牙SPP通信在微控制器和Android之间高速发送和接收字节数组。
如果Java的InputStream.read(byte[] b)
在Android收到时执行,则一次调用将冻结约10ms。
当微型计算机发送7字节或更多字节的数组时,InputStream.read(byte[] b)
将对其进行高速处理。
Java是否不适合立即吐出接收到的数组的过程?
Java:
static public byte[] BluetoothReceive() {
int readLen = -1;
byte[] buffer = new byte[6];
// If you can connect to the module
if (connectFlg) {
try
{
readLen = mInputStream.read(buffer);
Log.i(TAG,"[0] = " + buffer[0] + ","
+ "[1] = " + buffer[1] + ","
+ "[2] = " + buffer[2] + ","
+ "[3] = " + buffer[3] + ","
+ "[4] = " + buffer[4] + ","
+ "[5] = " + buffer[5]
);
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException ee){
ee.printStackTrace();
}
}
return buffer;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)