解析报文

This commit is contained in:
Guoqs
2024-07-31 15:27:59 +08:00
parent e7db8be29e
commit a6d3cf3366
2 changed files with 11 additions and 45 deletions

View File

@@ -20,6 +20,7 @@ public class YKCUtils {
* @return
*/
public static boolean checkMsg(byte[] msg) {
// log.info("checkMsg:{}", BytesUtil.binary(msg, 16));
// 起始标志
byte[] head = BytesUtil.copyBytes(msg, 0, 1);
// 数据长度
@@ -66,6 +67,11 @@ public class YKCUtils {
return false;
}
public static void main(String[] args) {
byte[] length = new byte[]{0x22};
System.out.println(BytesUtil.bytesToIntLittle(length));
}
/**
* 转换电压电流以及起始soc
* 精确到小数点后一位;待机置零
@@ -127,46 +133,6 @@ public class YKCUtils {
return bytes;
}
public static void main(String[] args) {
String frameTypeStr = "0x01";
byte[] bytes = frameTypeStr2Bytes(frameTypeStr);
System.out.println("转为byte数组:" + Arrays.toString(bytes));
String frameType2Str = frameType2Str(bytes);
System.out.println("转为Str:" + frameType2Str);
// String hexString = "681E0000003388000000000027012302081602434533880000000000270101008361";
// byte[] byteArray = new byte[hexString.length() / 2];
// for (int i = 0; i < byteArray.length; i++) {
// int index = i * 2;
// int j = Integer.parseInt(hexString.substring(index, index + 2), 16);
// byteArray[i] = (byte) j;
// }
// System.out.println(byteArray);
// String binary = BytesUtil.binary(byteArray, 16);
// String aaa = DatatypeConverter.printHexBinary(byteArray);
// System.out.println(binary);
// System.out.println(aaa);
// String targetCRC = "0abb";
// String substring = StringUtils.substring(targetCRC, 0, 2);
// String substring1 = StringUtils.substring(targetCRC, 2, 4);
// String crc = substring1 + substring;
//
// String hexString = "4f";
// byte[] bytes = new byte[]{0x4f};
//
// String s = transitionTemperature(bytes);
// System.out.println(s);
//
// byte[] bytess = new byte[]{(byte) 0x80, (byte) 0x1A, 0x06, 0x00};
// String s1 = convertDecimalPoint(bytess, 5);
// System.out.println(s1);
//
// String amount = "1000";
// byte[] priceByte = getPriceByte(amount, 2);
// System.out.println(BytesUtil.bin2HexStr(priceByte));
}
/**
* 转换温度
* BIN 码 1 整形,偏移量-50待机置零