|
|
@@ -1040,6 +1040,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
connect_flag = receive_data[1]
|
|
|
device_id = receive_data[2]
|
|
|
else:
|
|
|
+ logger.info("串口数据未监听到,继续等待...%s", port_name)
|
|
|
return False
|
|
|
print("关闭串口:{}".format(port_name))
|
|
|
logger.info("关闭串口:%s", port_name)
|
|
|
@@ -1078,6 +1079,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
state = await self.line_control.to_connect_com(port_name)
|
|
|
if not state:
|
|
|
return False
|
|
|
+ self.line_control.connect_state = True
|
|
|
return True
|
|
|
|
|
|
else:
|
|
|
@@ -1092,7 +1094,6 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
return False
|
|
|
# 走其他途径处理
|
|
|
|
|
|
-
|
|
|
def clearMyInstance(self):
|
|
|
SingletonType.clear_instance()
|
|
|
|
|
|
@@ -1192,16 +1193,16 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
return True, None
|
|
|
print("MCU 连接失败")
|
|
|
logger.info("MCU 连接失败")
|
|
|
- for port in self.p_list:
|
|
|
- logger.info(
|
|
|
- "MCU 连接失败处理list移除操作,self port name %s,p_list:%s",
|
|
|
- port_name,
|
|
|
- self.p_list,
|
|
|
- )
|
|
|
- if port == port_name:
|
|
|
- logger.info("MCU 连接失败处理list移除操作,移除 %s", port_name)
|
|
|
- self.p_list.remove(port)
|
|
|
- self.remove_port(port)
|
|
|
+ # for port in self.p_list:
|
|
|
+ # logger.info(
|
|
|
+ # "MCU 连接失败处理list移除操作,self port name %s,p_list:%s",
|
|
|
+ # port_name,
|
|
|
+ # self.p_list,
|
|
|
+ # )
|
|
|
+ # if port == port_name:
|
|
|
+ # logger.info("MCU 连接失败处理list移除操作,移除 %s", port_name)
|
|
|
+ # self.p_list.remove(port)
|
|
|
+ # self.remove_port(port)
|
|
|
message_data = {
|
|
|
"_type": "show_info",
|
|
|
"plugins_mode": "mcu",
|
|
|
@@ -1223,9 +1224,12 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
self.init_state = False
|
|
|
print("关闭MCU")
|
|
|
logger.info("关闭MCU")
|
|
|
+ def close_lineConnect(self):
|
|
|
+ ''''关闭有线遥控器连接'''
|
|
|
self.line_control.port_name = ""
|
|
|
self.line_control.close_connect()
|
|
|
-
|
|
|
+ print("关闭有线遥控器")
|
|
|
+ logger.info("关闭有线遥控器")
|
|
|
@property
|
|
|
def mcu_move_state(self):
|
|
|
if self.m_t == 1:
|
|
|
@@ -1629,20 +1633,8 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
device_status=2,
|
|
|
)
|
|
|
self.msg_type = "mcu"
|
|
|
- # 在第三张图时检查是否有对应图片生成
|
|
|
- # if index == 3:
|
|
|
- # # if not self.image_process_data.check_photo_is_get():
|
|
|
- # self.sendSocketMessage(
|
|
|
- # code=1,
|
|
|
- # msg="未获取到图片数据",
|
|
|
- # device_status=0,
|
|
|
- # )
|
|
|
- # self.action_state = 2
|
|
|
- # return
|
|
|
if index == total_len - 1:
|
|
|
- # 最后一个初始化处理
|
|
|
pass
|
|
|
- # self.action_state = 2
|
|
|
if self.is_stop_action == True:
|
|
|
self.msg_type = "run_mcu_stop"
|
|
|
self.sendSocketMessage(
|
|
|
@@ -1789,13 +1781,6 @@ async def checkMcuConnection(device_ctrl: DeviceControl):
|
|
|
except BaseException as e:
|
|
|
print("串口不存在{} {}".format(_port_name, e))
|
|
|
logger.info("串口不存在{} {}".format(_port_name, e))
|
|
|
- # if not device_ctrl.connect_state:
|
|
|
- # print("串口未连接,请检查")
|
|
|
- # device_ctrl.sendSocketMessage(
|
|
|
- # code=1, msg="串口未连接,请检查", device_status=-1
|
|
|
- # )
|
|
|
device_ctrl.is_init_while = False
|
|
|
- # device_ctrl.p_list = []
|
|
|
- # device_ctrl.temp_ports_dict = {}
|
|
|
print("MCU断开连接,已释放")
|
|
|
logger.info("MCU断开连接,已释放")
|