fix
This commit is contained in:
parent
0cc08a8c5c
commit
3ef98ab448
@ -25,12 +25,12 @@ public class CRC8Utils {
|
||||
*/
|
||||
public static byte calcCrc8_E5(byte[] data) {
|
||||
byte crc = 0;
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
crc ^= data[j];
|
||||
for (byte datum : data) {
|
||||
crc ^= datum;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if ((crc & 0x80) != 0) {
|
||||
crc = (byte) ((crc) << 1);
|
||||
crc ^= 0xE5;
|
||||
crc ^= (byte) 0xE5;
|
||||
} else {
|
||||
crc = (byte) ((crc) << 1);
|
||||
}
|
||||
|
||||
@ -78,8 +78,7 @@ public class ByteUtils {
|
||||
byte[] write = new byte[length];
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < bytes.size(); i++) {
|
||||
byte[] values = bytes.get(i);
|
||||
for (byte[] values : bytes) {
|
||||
addBytes(write, values, index);
|
||||
index += values.length;
|
||||
}
|
||||
@ -312,7 +311,8 @@ public class ByteUtils {
|
||||
if (StringUtils.isBlank(hexStr)) {
|
||||
return null;
|
||||
}
|
||||
if (hexStr.length() % 2 != 0) {//长度为单数
|
||||
// 长度为单数
|
||||
if (hexStr.length() % 2 != 0) {
|
||||
hexStr = "0" + hexStr; // 前面补0
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user