111,094
社区成员




private void ReceiveData()
{
try
{
Byte[] buf = new Byte[1];
string sbReadline2str = string.Empty;
if (sp.IsOpen){
//int bytes = sp.BytesToRead; 程序加上这两句Unity就会卡死并且强制退出。
//print (bytes);
sp.Read(buf, 0, 1);
}else{
print ("没有数据");
}
if (buf.Length == 0)
{
return;
}
if (buf != null)
{
for (int i = 0; i < buf.Length; i++)
{
sbReadline2str += buf[i].ToString("X2");
queueDataPool.Enqueue(sbReadline2str);
}
}
}
catch (Exception ex)
{
Debug.Log(ex);
}
}