摘要:
//两个字节换位 quint16 exchangeByte(unsigned short val) { unsigned char h = val >> 8; unsigned char l = val & 0xFF; unsigned short ret = l; ret <<= 8; ret | 阅读全文
摘要:
//ch更改某位的值,num是第几位(0-8) bool changBit(quint8 &ch, int bitVal, int num) { if(bitVal == 1) { ch |= (1 << num); } else { ch &= ~(1 << num); } return true 阅读全文
摘要:
//计算crc16位校验 ,如计算结果是0x5566,则高字节是55,低字节是66,需要根据情况交换高低字节 quint16 checkCrc16(quint8 *ptr, int len) { unsigned int i; quint16 crc = 0xFFFF; while(len--) { 阅读全文