|
|
@@ -925,7 +925,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
device_status=-1,
|
|
|
)
|
|
|
print("串口:{} 被占用".format(port_name))
|
|
|
- return
|
|
|
+ return False
|
|
|
|
|
|
await asyncio.sleep(2)
|
|
|
print("开始发送命令")
|
|
|
@@ -940,7 +940,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
data=None,
|
|
|
)
|
|
|
serial_handle.close()
|
|
|
- return
|
|
|
+ return False
|
|
|
print("尝试写入数据")
|
|
|
|
|
|
buf = bytearray(b"")
|
|
|
@@ -953,7 +953,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
except serial.SerialTimeoutException:
|
|
|
print("写入数据错误")
|
|
|
serial_handle.close()
|
|
|
- return
|
|
|
+ return False
|
|
|
|
|
|
await asyncio.sleep(0.3)
|
|
|
print("尝试接收命令")
|
|
|
@@ -1034,12 +1034,14 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
# # 异步循环获取设备信息
|
|
|
# self.to_get_mcu_base_info()
|
|
|
# asyncio.gather(getBaseInfo())
|
|
|
+ return True
|
|
|
else:
|
|
|
print("串口无法识别")
|
|
|
self.sendSocketMessage(
|
|
|
code=1,
|
|
|
msg="串口无法识别,请重新插拔拍照机USB", data=message_data, device_status=-1
|
|
|
)
|
|
|
+ return False
|
|
|
# 走其他途径处理
|
|
|
|
|
|
# 检查当前MCU链接是否正常
|
|
|
@@ -1680,8 +1682,10 @@ async def checkMcuConnection(device_ctrl: DeviceControl):
|
|
|
for _port_name, _port_value in ports_dict.items():
|
|
|
if _port_name not in device_ctrl.p_list:
|
|
|
try:
|
|
|
+ flag = await device_ctrl.add_port_by_linkage(_port_name)
|
|
|
+ if flag == False:
|
|
|
+ continue
|
|
|
device_ctrl.p_list.append(_port_name)
|
|
|
- await device_ctrl.add_port_by_linkage(_port_name)
|
|
|
except BaseException as e:
|
|
|
print("串口不存在{} {}".format(_port_name, e))
|
|
|
print("MCU断开连接,已释放")
|