feat: 优化em增加采集数据方法
This commit is contained in:
parent
d30ecabd16
commit
bf35064f6e
|
@ -12,9 +12,15 @@ def get_tyy_data(*args):
|
||||||
resp = sc.recv(1024)
|
resp = sc.recv(1024)
|
||||||
if len(resp) < 8:
|
if len(resp) < 8:
|
||||||
raise ParseError("设备未启动")
|
raise ParseError("设备未启动")
|
||||||
json_data = resp[5:-4]
|
try:
|
||||||
json_str = json_data.decode('utf-8')
|
json_data = resp[5:-4]
|
||||||
return json.loads(json_str)
|
json_str = json_data.decode('utf-8')
|
||||||
|
res = json.loads(json_str)
|
||||||
|
except Exception:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
sc.close()
|
||||||
|
return res
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(get_tyy_data())
|
print(get_tyy_data())
|
Loading…
Reference in New Issue