Commit bc0ee344 authored by 耿迪迪's avatar 耿迪迪

校验问题修改 gengdidi

parent c1dfa26a
......@@ -43,9 +43,10 @@ public class CrcUtil {
int CRC = getCRC(bytes);
//高低位转换,看情况使用(譬如本人这次对led彩屏的通讯开发就规定校验码高位在前低位在后,也就不需要转换高低位)
if(reverse){
//高低位互换,输出符合相关工具对Modbus CRC16的运算
CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8);
}
return Integer.toHexString(CRC);
return String.format("%04x", CRC);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment