We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以添加一个自动计算crc校验码功能,`def calculate_crc(data): # 预置寄存器为0xFFFF crc = 0xFFFF
for byte in data: # 将数据帧的字节与寄存器的高8位进行异或运算 crc ^= byte # 右移8次 for _ in range(8): # 检查最低位 if crc & 0x0001: # 如果最低位为1,与0xA001进行异或运算 crc = (crc >> 1) ^ 0xA001 else: # 否则不进行异或运算 crc >>= 1 # 返回低8位和高8位 low_byte = crc & 0x00FF high_byte = (crc >> 8) & 0x00FF return low_byte, high_byte
data_frame = [0x01, 0x03, 0x15, 0x20, 0x00, 0x02]
low, high = calculate_crc(data_frame)
print(f"低8位: {low:02X}, 高8位: {high:02X}")`
The text was updated successfully, but these errors were encountered:
这个功能以后会做的
Sorry, something went wrong.
No branches or pull requests
可以添加一个自动计算crc校验码功能,`def calculate_crc(data):
# 预置寄存器为0xFFFF
crc = 0xFFFF
示例数据帧
data_frame = [0x01, 0x03, 0x15, 0x20, 0x00, 0x02]
计算CRC校验码
low, high = calculate_crc(data_frame)
print(f"低8位: {low:02X}, 高8位: {high:02X}")`
The text was updated successfully, but these errors were encountered: