20260905:modbus指令调试工具替换空格
This commit is contained in:
parent
aa24948f8a
commit
d6377494b4
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user