feat: 优化em增加采集数据方法
This commit is contained in:
parent
d30ecabd16
commit
bf35064f6e
|
@ -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())
|
Loading…
Reference in New Issue