finnal
This commit is contained in:
@@ -37,10 +37,15 @@ async def websocket_distance(websocket: WebSocket):
|
||||
# except Exception as log_e:
|
||||
# print(f"日志写入失败: {log_e}")
|
||||
#调用 Modbus 可执行文件
|
||||
result = subprocess.run(
|
||||
[MODBUS_BIN_PATH, str(int(distance))],
|
||||
capture_output=True, text=True, timeout=5
|
||||
# print(f"调用 Modbus 程序,传递距离: {distance}")
|
||||
signal = "echo 'orangepi' | sudo "+ MODBUS_BIN_PATH
|
||||
result = subprocess.run(
|
||||
[signal],
|
||||
# shell=True,ocapture_output=True, text=True, timeout=0
|
||||
shell=True
|
||||
)
|
||||
# print("signal:", signal)
|
||||
# print(f"Modbus 程序返回: {result.stdout.strip()}, 错误: {result.stderr.strip()}")
|
||||
if result.returncode != 0:
|
||||
# 发送错误信息给客户端
|
||||
await websocket.send_json({
|
||||
|
Reference in New Issue
Block a user