每日更新;
This commit is contained in:
@@ -170,12 +170,12 @@ def display_data(modbus_map: dict, address: int, data: list):
|
||||
data_len = 2
|
||||
elif current_map[1] == 4:
|
||||
""" 字符串表示 """
|
||||
data_len = 16
|
||||
data_len = current_map[2]
|
||||
item = display_str(data, data_len)
|
||||
item = item.decode()
|
||||
elif current_map[1] == 5:
|
||||
""" 载波地址表示 """
|
||||
data_len = 3
|
||||
data_len = current_map[2]
|
||||
item = display_str(data, data_len)
|
||||
item = trans_list_to_str(item)
|
||||
|
||||
@@ -203,13 +203,30 @@ def check_frame_modbus(frame, block=None):
|
||||
""" 升级回复帧 """
|
||||
if code_subfunc == 0x01 and frame[3] == 0x00:
|
||||
return frame[4] * 256 + frame[5]
|
||||
elif code_subfunc == 0x02 and frame[3] == 0x00:
|
||||
elif code_subfunc == 0x02:
|
||||
""" 解析帧序号及返回值, 不做序列号校验 """
|
||||
update_result = frame[3]
|
||||
update_index = frame[4] * 256 + frame[5]
|
||||
if type(block) is dict and block['index'] != update_index:
|
||||
raise("Error slave response.")
|
||||
return update_index
|
||||
# 检查严重错误标志
|
||||
if update_result == 0xFF:
|
||||
raise("Error, Update abort.")
|
||||
if update_result >= 0xA0 or update_result == 0x0F:
|
||||
check_result = False
|
||||
else:
|
||||
check_result = True
|
||||
if update_result >= 0xA0:
|
||||
update_result -= 0x90
|
||||
if update_result >= 0x20:
|
||||
check_hope = update_index + (update_result & 0x0F)
|
||||
elif update_result >= 0x10:
|
||||
check_hope = update_index - (update_result & 0x0F)
|
||||
else:
|
||||
check_hope = None
|
||||
return check_result, update_index, check_hope
|
||||
elif code_subfunc == 0x03 and frame[3] == 0x00:
|
||||
return frame[4] * 256 + frame[5]
|
||||
else:
|
||||
raise("Func code or Return code error.")
|
||||
elif code_func == 0x03 or code_func == 0x04:
|
||||
""" 数据读取帧 """
|
||||
if frame[2] == len(frame[3:-2]):
|
||||
|
||||
Reference in New Issue
Block a user