feat: 优化em增加采集数据方法

This commit is contained in:
caoqianming 2025-02-27 12:37:17 +08:00
parent d30ecabd16
commit bf35064f6e
1 changed files with 9 additions and 3 deletions

View File

@ -12,9 +12,15 @@ def get_tyy_data(*args):
resp = sc.recv(1024)
if len(resp) < 8:
raise ParseError("设备未启动")
json_data = resp[5:-4]
json_str = json_data.decode('utf-8')
return json.loads(json_str)
try:
json_data = resp[5:-4]
json_str = json_data.decode('utf-8')
res = json.loads(json_str)
except Exception:
raise
finally:
sc.close()
return res
if __name__ == '__main__':
print(get_tyy_data())