blackfire531
3/17/2020 - 7:54 AM

异或校验

quint8 caculateChecksum(QByteArray buf, int len)
{
  int i;
  quint8 checksum = 0;
  for(i=0;i<len;i++)
  {
    checksum^=buf.at(i);
  }
#if (BEDUG_PRINT_CHECK)
  qDebug()<<QString("#异或校验#校验值:0x%1").arg(checksum,0,16);
#endif
  return checksum;
}