日期:2014-05-17 浏览次数:21076 次
while (true) {
byte[] b2 = new byte[2]; //先用3个字节来判断FF FF FF
int r = socket1.Receive(b2,b2.Length,0);
if(r == 0){
continue ;
}
if(Encoding .ASCII .GetString (b2,0,r) != "FFFFFF"){ //如果找到3个FF 就开始找后面的17个字节
break ;
}else{
byte[] b3 = new byte[16];
int rs = socket1.Receive (b3,b3.Length ,0); //这个接收会不会影响我下面写的数据转换???
if(rs == 0){
continue ;
}
string dingwei = b3[2].ToString("X2") + b3[1].ToString("X2") + b3[0].ToString("X2") ; //这是开始的前3个
string speed = b3[3].ToString("X2");
string angle = b3[5].ToString("X2")+ b3[4].ToString("X2");
string fx = b3[6].ToString("X2");
}