20260905:modbus指令调试工具替换空格

This commit is contained in:
zhugongping 2026-09-05 09:13:24 +08:00
parent aa24948f8a
commit d6377494b4
2 changed files with 4 additions and 1 deletions

View File

@ -48,6 +48,8 @@ def main():
print("已连接。")
for hex_bytes in MODBUS_DATA_HEX:
# 替换所有的空格
hex_bytes = hex_bytes.replace(" ", "")
# 0.将十六进制字符串转换为字节
modbus_bytes = unhexlify(hex_bytes)

View File

@ -133,7 +133,8 @@ public class CRC16Utils {
public static void main(String[] args) throws Exception {
String hex = "01030400110018AA3C";
String hex = "01060004001E";
hex = hex.replace(" ", "");
byte[] bytes = ByteUtils.hexToByte(hex);
String crc = getCRC(bytes);
System.out.println(crc);