This commit is contained in:
2025-11-21 14:55:52 +08:00
parent e3ecd0550f
commit 26ed8df502
36 changed files with 908 additions and 433 deletions

View File

@ -470,9 +470,10 @@ class command_hex:
"""
# 寻找连续三个0x2C的情况
for idx in range(len(response) - 2):
if response[idx] == 0x2C and response[idx+1] == 0x2C and response[idx+2] == 0x2C:
response=response[:idx]
# for idx in range(len(response) - 2):
# if response[idx] == 0x2C and response[idx+1] == 0x2C and response[idx+2] == 0x2C:
# response=response[:idx]
# break
# 验证响应长度
if len(response) <= 1 or len(response) != response[0] + 1:
raise ValueError("应答数据长度不正确")
@ -499,7 +500,12 @@ class command_hex:
loc_string = ''
if data_part:
try:
loc_string = data_part.decode('ascii')
first_empty = loc_string.find(',,,')
if first_empty != -1:
loc_string = loc_string[:first_empty]
print('收到数据:',loc_string)
except UnicodeDecodeError:
print(f"无法将数据转换为ASCII字符串: {data_part}")
return loc_string