}
cTmp1=xorDat&0xf0; //取高4位 cTmp1>>=4; //右移4次移到低4位 cTmp1+=0x30;
cTmp2=xorDat&0x0f; //取低4位 cTmp2+=0x30;
if((cTmp1==RecBuf[10])&&(cTmp2==RecBuf[11]))
{ SendBuf[1]=RecBuf[0];SendBuf[2]=RecBuf[1]; //地址与接收到的地址相同 //SendBuf[3]= SendBuf[4]= //发送的字节数 cTmp=SendDat;cTmp&=0xf0; //取高4位 cTmp>>=4; //右移4位 SendBuf[5]=0x30+cTmp; cTmp=SendDat;cTmp&=0x0f; SendBuf[6]=0x30+cTmp;//发送的值 //////以下计算异或码 xorDat=SendBuf[1]; for(i=2;i<7;i++) {
xorDat^=SendBuf[i]; } cTmp1=xorDat&0xf0; //取高4位 cTmp1>>=4; cTmp1+=0x30; cTmp2=xorDat&0x0f; //取低4位 cTmp2+=0x30;
SendBuf[7]=cTmp1;SendBuf[8]=cTmp2; //做异或运算 UartSends(SendBuf,10); } } } }