回滚,修复bug

This commit is contained in:
sityliu 2024-05-12 01:15:28 +08:00
parent 1537003d13
commit 3ed9393b01
5 changed files with 36 additions and 32 deletions

View File

@ -25,6 +25,5 @@ class Config:
VOICE_CMD_SUB = '/python/mqtt/voice_cmd'
ACTION_CMD_SUB = 'dc4f224c4ebe'
# 程序变量
RUN_FLAG = 1

View File

@ -16,7 +16,7 @@
离家模式68 FF 11
我已回家68 FF 22
校验语音模块AA 55 05 55 AA 返回=> aa 15
程序启动语音播报AA 55 05 55 AA 返回=> aa 15
校验语音模块AA 55 03 55 AA 返回=> aa 19不播放语音

View File

@ -132,7 +132,7 @@ if __name__ == '__main__':
# 校验语音模块串口是否运行异常
elif (ser_cmd == 'ffffffffff') or (client.callback_result == 'ffffffffff'):
master_control.run_flage(voice, check_code, ser_cmd, client)
master_control.run_flage(voice, check_code, ser_cmd)
save_log.info('语音模块校验成功!')
time.sleep(1)

View File

@ -20,34 +20,37 @@ save_log_error = SaveLogger('voice_processing.pyw', log_file=log_file_path1)
def get_voice_data(ser_data):
# try:
com_input1 = ser_data.readline()
# except Exception as e:
# save_log_error.error(f'get_voice_data(); com_input = ser_data.readline(); Error: {e}')
com_input1 = None # 初始化为None避免后续引用前未定义的问题
try:
com_input1 = ser_data.readline()
except Exception as e:
save_log_error.error(f'get_voice_data(); com_input = ser_data.readline(); Error: {e}')
return # 或者根据需要处理异常后继续或终止函数执行
if not com_input1:
pass
# 开灯
elif com_input1.hex() == 'a487':
save_log.info(f'开灯指令处理完返回,command:{com_input1.hex()}')
# 关灯
elif com_input1.hex() == 'a488':
save_log.info(f'关灯指令处理完返回,command:{com_input1.hex()}')
# 暖色灯
elif com_input1.hex() == 'd366':
save_log.info(f'打开暖色灯指令处理完返回,command:{com_input1.hex()}')
# 关暖色灯
elif com_input1.hex() == 'd388':
save_log.info(f'关闭暖色灯指令处理完返回,command:{com_input1.hex()}')
# 打开WIFI插座01
elif com_input1.hex() == 'sba1':
save_log.info(f'打开WIFI插座指令处理完返回,command:{com_input1.hex()}')
# 关闭WIFI插座01
elif com_input1.hex() == 'sbb1':
save_log.info(f'关闭WIFI插座指令处理完返回,command:{com_input1.hex()}')
elif com_input1.hex() == 'aa15' or com_input1.hex() == 'aa19' or com_input1.hex() == 'aa12':
pass
else:
save_log_error.error(f'Instruction error; error command: {com_input1.hex()}')
# 确保com_input1有值后再进行后续判断
if com_input1:
com_input1_hex = com_input1.hex()
# 开灯
if com_input1_hex == 'a487':
save_log.info(f'开灯指令处理完返回,command:{com_input1_hex}')
# 关灯
elif com_input1_hex == 'a488':
save_log.info(f'关灯指令处理完返回,command:{com_input1_hex}')
# 暖色灯
elif com_input1_hex == 'd366':
save_log.info(f'打开暖色灯指令处理完返回,command:{com_input1_hex}')
# 关暖色灯
elif com_input1_hex == 'd388':
save_log.info(f'关闭暖色灯指令处理完返回,command:{com_input1_hex}')
# 打开WIFI插座01
elif com_input1_hex == 'sba1':
save_log.info(f'打开WIFI插座指令处理完返回,command:{com_input1_hex}')
# 关闭WIFI插座01
elif com_input1_hex == 'sbb1':
save_log.info(f'关闭WIFI插座指令处理完返回,command:{com_input1_hex}')
elif com_input1_hex == 'aa15' or com_input1_hex == 'aa19' or com_input1_hex == 'aa12' or com_input1_hex == 'ffffffffff':
pass
else:
save_log_error.error(f'Instruction error; error command: {com_input1_hex}')
return com_input1.hex()
return com_input1_hex

2
ttyUSBLink.rules Normal file
View File

@ -0,0 +1,2 @@
ACTION=="add",KERNELS=="1-1.1:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="vice_usb0"
ACTION=="add",KERNELS=="1-1.3:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="control_usb1"