求助帮忙分析代码
int i,wlen,rlen;char command='\0';
char txbuff[6];
char revbuff[7];
QByteArray rev = " ";
for(command=0x10;command<=0x20;command++)
{
//printf("\n command:%#x",command);
if( (command == 0x1b)| (command == 0x1c) )
continue;
memset(txbuff,'\0',sizeof(txbuff));
txbuff[0]=0xAA;
txbuff[1]=0xFF;
txbuff[2]=command;
txbuff[3]=0xFF;
txbuff[3]= txbuff[3]^txbuff[2];
txbuff[4]=0xFF;
txbuff[5]='\0';
fflush(stdout);
wlen = m_tty.tty_write(sel_fd,txbuff,6);
fflush(stdout);
memset(revbuff,'\0',sizeof(revbuff));
rlen = m_tty.tty_read(sel_fd,revbuff,7);
fflush(stdout);
if(rlen < 0)
{
printf("read serial error!\n");
rlen = m_tty.tty_read(sel_fd,revbuff,7);
}
rev = " ";
for(i=2;i<4;i++)
rev.append(revbuff[i]);
char str[3]= {'\0'};
char value = '\0';
char *temp = rev.data();
i=0;
for(i=0;i<3;i++){
str[i]= *temp;
temp++;
}
value = (str[1] << 4)|str[2];
char d[2] = {'\0'};
sprintf(d,"%x",value);
for(i=2;i<5;i++)
{
printf(" %x",revbuff[i]);
}
revbuff[6]=0;
for(i=2;i<4;i++)
{
revbuff[5]=revbuff[5]^revbuff[i];
}
这段代码看不太明白,各位大侠帮忙分析一下,谢谢