From: SnickerSun Date: Mon, 15 Dec 2025 05:07:20 +0000 (+0800) Subject: 优化测试流程,lcd 测试时 保证测试马达和录音的时候,提前关闭lcd。 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=600fe6ef2a3ae3b3eea235ce3b40e444b51957fc;p=mirrors%2Ffactory_tool.git 优化测试流程,lcd 测试时 保证测试马达和录音的时候,提前关闭lcd。 4G测试提前开启电源,保证测试信号数据稳定。 --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 67a6f32..4f38330 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,4 @@ -#include "mainwindow.h" +#include "mainwindow.h" #include "ui_mainwindow.h" #include "config_manager.h" #include @@ -27,7 +27,7 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); - setWindowTitle("雷鸟产测工具 V1.4"); + setWindowTitle("雷鸟产测工具 V1.5"); // 确保控制台输出使用UTF-8编码 QTextCodec *utf8Codec = QTextCodec::codecForName("UTF-8"); @@ -79,6 +79,7 @@ MainWindow::MainWindow(QWidget *parent) lcdTestPopupShown = false; motorTestPopupShown = false; isWaitingForUserConfirm = false; + lcdBacklightOn = false; // 初始化LCD背光状态为关闭 keyTestStarted = false; keyTestDialog = nullptr; audioTestPopupShown = false; @@ -1272,6 +1273,15 @@ void MainWindow::readSerialData() qDebug() << "跳过CAT1信号数据(格式不匹配):" << line.left(50) + "..."; } } + + // 检测LCD背光状态 + if (line.contains("LCD backlight turned on")) { + lcdBacklightOn = true; + qDebug() << "检测到LCD背光开启日志,更新LCD状态为开启"; + } else if (line.contains("uapi_lcd_backlight_off")) { + lcdBacklightOn = false; + qDebug() << "检测到LCD背光关闭日志,更新LCD状态为关闭"; + } } // 限制缓存最大长度 @@ -1477,28 +1487,49 @@ void MainWindow::onLcdTestTimer() serial->write("AT^LCDTEST=2\r\n"); qDebug() << "发送LCD退出指令: AT^LCDTEST=2"; - // 发送关闭LCD指令,确保其他测试时LCD是关闭的 - QTimer::singleShot(100, this, [this]() { - if (isProductionTestRunning && serial && serial->isOpen()) { - serial->write("AT^LCDOFF\r\n"); - qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; - ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); - } - }); - - // LCD颜色测试完成,检查用户是否已确认 - if (!isWaitingForUserConfirm) { - // 用户已确认,可以继续下一个测试 - QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning) { - qDebug() << "用户已确认LCD结果,推进到下一个测试"; - skipToNextEnabledTest(); + // 如果LCD测试被选中且LCD是开启状态,才需要关闭LCD + if (isTestItemEnabled("lcd") && lcdBacklightOn) { + // 发送关闭LCD指令 + QTimer::singleShot(100, this, [this]() { + if (isProductionTestRunning && serial && serial->isOpen()) { + serial->write("AT^LCDOFF\r\n"); + qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; + ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); + + // LCD关闭后延迟1秒,然后延迟2秒再继续下一个测试 + QTimer::singleShot(1000, this, [this]() { + // LCD颜色测试完成,检查用户是否已确认 + if (!isWaitingForUserConfirm) { + // 用户已确认,延迟2秒后继续下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + qDebug() << "用户已确认LCD结果,推进到下一个测试"; + skipToNextEnabledTest(); + } + }); + } else { + // 用户还未确认,等待用户确认后再继续 + qDebug() << "LCD颜色测试完成,等待用户确认结果"; + ui->statusbar->showMessage("LCD测试完成,等待用户确认结果", 3000); + } + }); } }); } else { - // 用户还未确认,等待用户确认后再继续 - qDebug() << "LCD颜色测试完成,等待用户确认结果"; - ui->statusbar->showMessage("LCD测试完成,等待用户确认结果", 3000); + // LCD测试未启用或LCD已关闭,直接继续 + if (!isWaitingForUserConfirm) { + // 用户已确认,延迟2秒后继续下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + qDebug() << "用户已确认LCD结果,推进到下一个测试"; + skipToNextEnabledTest(); + } + }); + } else { + // 用户还未确认,等待用户确认后再继续 + qDebug() << "LCD颜色测试完成,等待用户确认结果"; + ui->statusbar->showMessage("LCD测试完成,等待用户确认结果", 3000); + } } } } @@ -1528,6 +1559,35 @@ void MainWindow::performMotorTest() qDebug() << "开始马达测试"; ui->recvTextEdit->append("========== 开始马达测试 =========="); + // 如果LCD测试已启用,检查LCD状态,如果开启则关闭 + if (isTestItemEnabled("lcd") && lcdBacklightOn) { + qDebug() << "LCD测试已启用且LCD背光处于开启状态,关闭LCD"; + serial->write("AT^LCDOFF\r\n"); + qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; + ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); + + // LCD关闭后延迟1秒再进行下一步 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning && currentTestStep == TEST_MOTOR) { + performMotorTestContinue(); + } + }); + return; // 先返回,等待LCD关闭完成 + } else if (isTestItemEnabled("lcd") && !lcdBacklightOn) { + qDebug() << "LCD测试已启用但LCD背光已关闭,无需操作"; + } + + // LCD已关闭或未启用,直接继续马达测试 + performMotorTestContinue(); +} + +// 继续马达测试(LCD关闭后或无需关闭LCD时调用) +void MainWindow::performMotorTestContinue() +{ + if (!isProductionTestRunning || currentTestStep != TEST_MOTOR) { + return; + } + // 重置马达测试状态 motorTestPopupShown = false; @@ -1575,9 +1635,9 @@ void MainWindow::onMotorTestTimer() if (!motorTestPopupShown) { showMotorTestConfirmDialog(); } else { - // 如果弹窗已经显示过,直接开始下一个测试 - qDebug() << "马达确认弹窗已显示过,推进到下一个测试"; - skipToNextEnabledTest(); + // 如果弹窗已经显示过,说明用户已经确认过了,不应该再调用skipToNextEnabledTest + // 因为showMotorTestConfirmDialog中已经处理了推进到下一个测试的逻辑 + qDebug() << "马达确认弹窗已显示过,不再重复处理"; } } @@ -1606,68 +1666,54 @@ void MainWindow::perform4GTest() initRetry4GCount++; qDebug() << "4G测试 - 初始化尝试次数:" << initRetry4GCount; - // 第一次4G测试时更新状态并进行CAT1电源控制 if (initRetry4GCount == 1) { ui->recvTextEdit->append("========== 开始4G测试 =========="); - updateTestStatus("ppp", STATUS_TESTING); - - // 先发送AT^CAT1POWER=0关闭CAT1电源 - serial->write("AT^CAT1POWER=0\r\n"); - qDebug() << "发送CAT1电源关闭指令: AT^CAT1POWER=0"; - ui->statusbar->showMessage("4G测试中 - 重置CAT1电源...", 2000); - - // 延迟1秒后发送AT^CAT1POWER=1开启CAT1电源 - QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning && serial->isOpen()) { - serial->write("AT^CAT1POWER=1\r\n"); - qDebug() << "发送CAT1电源开启指令: AT^CAT1POWER=1"; - ui->statusbar->showMessage("4G测试中 - 启动CAT1电源...", 2000); - - // 延迟1秒后发送AT^CAT1LOGLEVEL=4指令 - QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning && serial->isOpen()) { - serial->write("AT^CAT1LOGLEVEL=4\r\n"); - qDebug() << "发送CAT1日志级别设置指令: AT^CAT1LOGLEVEL=4"; - ui->statusbar->showMessage("4G测试中 - 设置CAT1日志级别...", 2000); - - // 延迟1秒后发送AT^PPPSTOPDIAL指令 - QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning && serial->isOpen()) { - serial->write("AT^PPPSTOPDIAL\r\n"); - qDebug() << "发送PPP停止拨号指令: AT^PPPSTOPDIAL"; - ui->statusbar->showMessage("4G测试中 - 停止PPP拨号...", 3000); - - // 延迟5秒后重置标志并开始4G信号检测 - QTimer::singleShot(5000, this, [this]() { - if (isProductionTestRunning) { - // 重置标志 - hasReceivedSignalSim = false; - hasReceivedPppInfo = true; // 标记为已收到,跳过PPP等待 - pppCommandCount = 0; - - // 直接开始4G信号质量检测 - qDebug() << "PPPSTOPDIAL延时完成,直接开始4G信号质量检测"; - currentTestStep = TEST_PPP_SIGNAL; - perform4GSignalTest(); - } - }); - } - }); - } - }); - } - }); - return; // 第一次调用时直接返回,等待定时器执行后续步骤 + } else { + ui->recvTextEdit->append(QString("========== 4G测试重试 (第%1次) ==========").arg(initRetry4GCount)); } + updateTestStatus("ppp", STATUS_TESTING); - // 非第一次调用,直接进行4G环境初始化(重试时) - ui->statusbar->showMessage(QString("4G测试中 - 初始化中...(%1/10)").arg(initRetry4GCount), 5000); + // 4G电源已在初始化阶段开关,这里直接使用CAT1GETSIGNAL获取信号 + qDebug() << "4G电源已在初始化阶段开关,直接开始4G信号质量检测"; + ui->statusbar->showMessage("4G测试中 - 开始信号强度检测...", 3000); - // 不再发送PPPENVINIT指令,直接启动定时器等待后续处理 + // 重置标志 + hasReceivedSignalSim = false; + hasReceivedPppInfo = true; // 标记为已收到,跳过PPP等待 + hasReceivedFirstSignal = false; // 重置,确保能重新启动CAT1测试 + pppCommandCount = 0; + + // 初始化CAT1信号测试计数器 + cat1SignalTestCount = 0; + cat1SignalReceivedCount = 0; + cat1SignalGoodCount = 0; + cat1Signal99Count = 0; + cat1SignalTotalValue = 0; + + // 停止可能正在运行的定时器 + if (cat1SignalTimer->isActive()) { + cat1SignalTimer->stop(); + qDebug() << "停止CAT1信号测试定时器"; + } + if (signal4GTimer->isActive()) { + signal4GTimer->stop(); + qDebug() << "停止4G信号检测定时器"; + } - // 启动5秒超时定时器,如果没收到回复就重试 - test4GTimer->start(5000); - qDebug() << "启动4G测试超时定时器(5秒)"; + // 直接开始CAT1信号测试,使用CAT1GETSIGNAL指令 + currentTestStep = TEST_PPP_SIGNAL; + qDebug() << "开始CAT1信号测试,发送AT^CAT1GETSIGNAL指令"; + ui->recvTextEdit->append("========== 开始4G信号质量测试 =========="); + ui->statusbar->showMessage("开始CAT1信号测试,每2秒检测一次...", 3000); + + // 启动CAT1信号测试定时器,每2秒发送一次 + cat1SignalTimer->start(2000); + + // 立即发送第一次CAT1信号检测指令 + serial->write("AT^CAT1GETSIGNAL\r\n"); + cat1SignalTestCount++; + qDebug() << "发送第" << cat1SignalTestCount << "次CAT1信号检测指令: AT^CAT1GETSIGNAL"; + ui->recvTextEdit->append(">>> 发送指令: AT^CAT1GETSIGNAL"); } // 检查4G初始化结果 @@ -1775,26 +1821,8 @@ void MainWindow::check4GInitResult(const QString& data) } if (data.contains("PPP environment initialized successfully")) { - qDebug() << "4G初始化通过"; - ui->statusbar->showMessage("4G初始化通过,发送运行时更新指令", 2000); - - // 标记已收到PPPINFO相关打印 - hasReceivedPppInfo = true; - - // 4G初始化通过,发送运行时更新指令 - currentTestStep = TEST_PPP_UPDATE; - serial->write("AT^PPPRUNTIMEUPDATE\r\n"); - qDebug() << "发送4G运行时更新指令: AT^PPPRUNTIMEUPDATE"; - - // 延迟2秒后开始4G信号质量检测 - QTimer::singleShot(2000, this, [this]() { - if (isProductionTestRunning) { - qDebug() << "开始4G信号质量检测"; - currentTestStep = TEST_PPP_SIGNAL; - perform4GSignalTest(); - } - }); - // ui->ProductionTestButton->setText("开始产测"); + qDebug() << "4G初始化通过(已废弃,不再使用PPP相关指令)"; + // PPP相关指令已失效,不再处理 } else if (data.contains("PPP init failed")) { qDebug() << "4G初始化失败,重试中..."; @@ -2022,34 +2050,62 @@ void MainWindow::showLcdTestConfirmDialog() serial->write("AT^LCDTEST=2\r\n"); qDebug() << "LCD测试通过,发送停止LCD测试指令: AT^LCDTEST=2"; - // 发送关闭LCD指令,确保其他测试时LCD是关闭的 - QTimer::singleShot(100, this, [this]() { - if (isProductionTestRunning && serial && serial->isOpen()) { - serial->write("AT^LCDOFF\r\n"); - qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; - ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); - } - }); - - // 停止LCD定时器,防止继续切换颜色和重复调用马达测试 - if (lcdTestTimer->isActive()) { - lcdTestTimer->stop(); - qDebug() << "停止LCD定时器,防止继续切换颜色和重复调用马达测试"; - } - - // 推进到下一个启用的测试 - if (isProductionTestRunning) { - qDebug() << "LCD测试通过确认,推进到下一个测试"; - qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; - - // 延迟一点确保LCD定时器完全停止,然后推进到下一个测试 + // 如果LCD测试被选中且LCD是开启状态,才需要关闭LCD + if (isTestItemEnabled("lcd") && lcdBacklightOn) { + // 发送关闭LCD指令 QTimer::singleShot(100, this, [this]() { - if (isProductionTestRunning) { - skipToNextEnabledTest(); + if (isProductionTestRunning && serial && serial->isOpen()) { + serial->write("AT^LCDOFF\r\n"); + qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; + ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); + + // LCD关闭后延迟1秒,然后延迟2秒再继续下一个测试 + QTimer::singleShot(1000, this, [this]() { + // 停止LCD定时器,防止继续切换颜色和重复调用马达测试 + if (lcdTestTimer->isActive()) { + lcdTestTimer->stop(); + qDebug() << "停止LCD定时器,防止继续切换颜色和重复调用马达测试"; + } + + // 推进到下一个启用的测试 + if (isProductionTestRunning) { + qDebug() << "LCD测试通过确认,延迟2秒后推进到下一个测试"; + qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; + + // 延迟2秒确保LCD完全关闭,然后推进到下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + skipToNextEnabledTest(); + } + }); + } else { + qDebug() << "产测未运行,无法继续测试"; + } + }); } }); } else { - qDebug() << "产测未运行,无法继续测试"; + // LCD测试未启用或LCD已关闭,直接继续 + // 停止LCD定时器,防止继续切换颜色和重复调用马达测试 + if (lcdTestTimer->isActive()) { + lcdTestTimer->stop(); + qDebug() << "停止LCD定时器,防止继续切换颜色和重复调用马达测试"; + } + + // 推进到下一个启用的测试 + if (isProductionTestRunning) { + qDebug() << "LCD测试通过确认,延迟2秒后推进到下一个测试"; + qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; + + // 延迟2秒确保LCD完全关闭,然后推进到下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + skipToNextEnabledTest(); + } + }); + } else { + qDebug() << "产测未运行,无法继续测试"; + } } } else if (msgBox.clickedButton() == failButton) { @@ -2062,34 +2118,58 @@ void MainWindow::showLcdTestConfirmDialog() serial->write("AT^LCDTEST=2\r\n"); qDebug() << "LCD测试失败,发送停止LCD测试指令: AT^LCDTEST=2"; - // 发送关闭LCD指令,确保其他测试时LCD是关闭的 - QTimer::singleShot(100, this, [this]() { - if (isProductionTestRunning && serial && serial->isOpen()) { - serial->write("AT^LCDOFF\r\n"); - qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; - ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); - } - }); - - // 停止LCD定时器,防止重复调用马达测试 - if (lcdTestTimer->isActive()) { - lcdTestTimer->stop(); - qDebug() << "停止LCD定时器,防止重复调用马达测试"; - } - - // 即使失败也继续下一个测试 - if (isProductionTestRunning) { - qDebug() << "LCD测试失败确认,继续下一个测试"; - qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; - - // 延迟一点确保LCD定时器完全停止,然后推进到下一个测试 + // 如果LCD测试被选中且LCD是开启状态,才需要关闭LCD + if (isTestItemEnabled("lcd") && lcdBacklightOn) { + // 发送关闭LCD指令 QTimer::singleShot(100, this, [this]() { - if (isProductionTestRunning) { - skipToNextEnabledTest(); + if (isProductionTestRunning && serial && serial->isOpen()) { + serial->write("AT^LCDOFF\r\n"); + qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; + ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD)"); + + // LCD关闭后延迟1秒,然后延迟2秒再继续下一个测试 + QTimer::singleShot(1000, this, [this]() { + // 停止LCD定时器,防止重复调用马达测试 + if (lcdTestTimer->isActive()) { + lcdTestTimer->stop(); + qDebug() << "停止LCD定时器,防止重复调用马达测试"; + } + + // 即使失败也继续下一个测试 + if (isProductionTestRunning) { + qDebug() << "LCD测试失败确认,延迟2秒后继续下一个测试"; + qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; + + // 延迟2秒确保LCD完全关闭,然后继续下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + skipToNextEnabledTest(); + } + }); + } + }); } }); } else { - qDebug() << "产测未运行,无法继续测试"; + // LCD测试未启用或LCD已关闭,直接继续 + // 停止LCD定时器,防止重复调用马达测试 + if (lcdTestTimer->isActive()) { + lcdTestTimer->stop(); + qDebug() << "停止LCD定时器,防止重复调用马达测试"; + } + + // 即使失败也继续下一个测试 + if (isProductionTestRunning) { + qDebug() << "LCD测试失败确认,延迟2秒后继续下一个测试"; + qDebug() << "当前产测状态:" << isProductionTestRunning << "当前测试步骤:" << currentTestStep; + + // 延迟2秒确保LCD完全关闭,然后继续下一个测试 + QTimer::singleShot(2000, this, [this]() { + if (isProductionTestRunning) { + skipToNextEnabledTest(); + } + }); + } } } else if (msgBox.clickedButton() == retestButton) { @@ -2242,9 +2322,20 @@ void MainWindow::showMotorTestConfirmDialog() } // 用户确认完成,马达测试结束,推进到下一个测试 + // 先重置等待确认标志,确保skipToNextEnabledTest可以正常推进 + qDebug() << "马达测试确认对话框关闭,重置标志"; + qDebug() << "重置前 - isWaitingForUserConfirm:" << isWaitingForUserConfirm << "motorTestPopupShown:" << motorTestPopupShown; + isWaitingForUserConfirm = false; + motorTestPopupShown = false; // 重置弹窗标志,允许下次测试时重新显示 + qDebug() << "重置后 - isWaitingForUserConfirm:" << isWaitingForUserConfirm << "motorTestPopupShown:" << motorTestPopupShown; + if (isProductionTestRunning && currentTestStep == TEST_MOTOR) { - qDebug() << "马达测试确认完成,推进到下一个测试"; + qDebug() << "马达测试确认完成,准备推进到下一个测试"; + qDebug() << "isProductionTestRunning:" << isProductionTestRunning << "currentTestStep:" << currentTestStep; skipToNextEnabledTest(); + } else { + qDebug() << "马达测试确认完成,但条件不满足,不推进"; + qDebug() << "isProductionTestRunning:" << isProductionTestRunning << "currentTestStep:" << currentTestStep; } } @@ -2260,6 +2351,23 @@ void MainWindow::performKeyTest() } if (!isProductionTestRunning || currentTestStep != TEST_KEY) { + qDebug() << "按键测试条件不满足,退出函数"; + qDebug() << "isProductionTestRunning:" << isProductionTestRunning; + qDebug() << "currentTestStep:" << currentTestStep << "期望:" << TEST_KEY; + return; + } + + // 检查是否正在等待用户确认马达测试结果,如果是则等待 + // 只有在两个标志都为true时才等待(说明确认弹窗还在显示) + if (isWaitingForUserConfirm && motorTestPopupShown) { + qDebug() << "马达测试正在等待用户确认,延迟启动按键测试"; + qDebug() << " isWaitingForUserConfirm:" << isWaitingForUserConfirm << "motorTestPopupShown:" << motorTestPopupShown; + QTimer::singleShot(500, this, [this]() { + if (isProductionTestRunning && currentTestStep == TEST_KEY && + !(isWaitingForUserConfirm && motorTestPopupShown)) { + performKeyTest(); + } + }); return; } @@ -2564,34 +2672,87 @@ void MainWindow::checkBuildVerResult(const QString& data) serial->write("AT^PMADDVOTE\r\n"); qDebug() << "发送AT^PMADDVOTE指令(第2次): AT^PMADDVOTE"; - // 再延迟1秒后切换到LCD测试阶段(如果启用) - QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning) { - // 检查LCD测试是否启用 - if (isTestItemEnabled("lcd")) { - qDebug() << "AT^PMADDVOTE指令发送完成,开始LCD测试"; - ui->statusbar->showMessage("初始化完成,开始LCD测试", 2000); - - // 切换到LCD测试阶段 - currentTestStep = TEST_LCD; + // 如果4G测试已启用,先关闭和开启4G电源 + if (isTestItemEnabled("ppp")) { + qDebug() << "4G测试已启用,在初始化阶段先关闭和开启4G电源"; + // 先发送AT^CAT1POWER=0关闭CAT1电源 + serial->write("AT^CAT1POWER=0\r\n"); + qDebug() << "发送CAT1电源关闭指令: AT^CAT1POWER=0 (初始化阶段)"; + + // 延迟1秒后发送AT^CAT1POWER=1开启CAT1电源 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning && serial->isOpen()) { + serial->write("AT^CAT1POWER=1\r\n"); + qDebug() << "发送CAT1电源开启指令: AT^CAT1POWER=1 (初始化阶段)"; - // 延迟1秒后开始LCD测试 + // 延迟1秒后发送AT^CAT1LOGLEVEL=4指令 QTimer::singleShot(1000, this, [this]() { - if (isProductionTestRunning && currentTestStep == TEST_LCD) { - qDebug() << "开始LCD测试流程"; - performLcdTest(); + if (isProductionTestRunning && serial->isOpen()) { + serial->write("AT^CAT1LOGLEVEL=4\r\n"); + qDebug() << "发送CAT1日志级别设置指令: AT^CAT1LOGLEVEL=4 (初始化阶段)"; + + // 延迟1秒后切换到LCD测试阶段(如果启用) + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning) { + // 检查LCD测试是否启用 + if (isTestItemEnabled("lcd")) { + qDebug() << "4G电源初始化完成,开始LCD测试"; + ui->statusbar->showMessage("初始化完成,开始LCD测试", 2000); + + // 切换到LCD测试阶段 + currentTestStep = TEST_LCD; + + // 延迟1秒后开始LCD测试 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning && currentTestStep == TEST_LCD) { + qDebug() << "开始LCD测试流程"; + performLcdTest(); + } + }); + } else { + qDebug() << "4G电源初始化完成,LCD测试未启用,跳过"; + ui->statusbar->showMessage("初始化完成,LCD测试未启用,跳过", 2000); + + // LCD未启用,跳过到下一个启用的测试 + currentTestStep = TEST_LCD; + skipToNextEnabledTest(); + } + } + }); } }); - } else { - qDebug() << "AT^PMADDVOTE指令发送完成,LCD测试未启用,跳过"; - ui->statusbar->showMessage("初始化完成,LCD测试未启用,跳过", 2000); - - // LCD未启用,跳过到下一个启用的测试 - currentTestStep = TEST_LCD; - skipToNextEnabledTest(); } - } - }); + }); + } else { + // 4G测试未启用,直接切换到LCD测试阶段 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning) { + // 检查LCD测试是否启用 + if (isTestItemEnabled("lcd")) { + qDebug() << "AT^PMADDVOTE指令发送完成,开始LCD测试"; + ui->statusbar->showMessage("初始化完成,开始LCD测试", 2000); + + // 切换到LCD测试阶段 + currentTestStep = TEST_LCD; + + // 延迟1秒后开始LCD测试 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning && currentTestStep == TEST_LCD) { + qDebug() << "开始LCD测试流程"; + performLcdTest(); + } + }); + } else { + qDebug() << "AT^PMADDVOTE指令发送完成,LCD测试未启用,跳过"; + ui->statusbar->showMessage("初始化完成,LCD测试未启用,跳过", 2000); + + // LCD未启用,跳过到下一个启用的测试 + currentTestStep = TEST_LCD; + skipToNextEnabledTest(); + } + } + }); + } } }); } @@ -3374,6 +3535,34 @@ void MainWindow::performAudioTest() qDebug() << "开始录音测试(自动模式:AT^AUDIOTEST)"; ui->recvTextEdit->append("========== 开始录音测试 =========="); + + // 录音测试前,无论LCD状态如何,都强制关闭LCD + // 因为按键测试时按下按键可能会自动开启LCD,但状态可能没有及时更新 + // 为了确保LCD关闭,无论状态如何都发送关闭命令 + qDebug() << "录音测试前强制关闭LCD(无论状态如何)"; + qDebug() << "当前LCD状态 - LCD测试启用:" << isTestItemEnabled("lcd") << "LCD背光状态:" << lcdBacklightOn; + serial->write("AT^LCDOFF\r\n"); + qDebug() << "发送指令: AT^LCDOFF (关闭LCD)"; + ui->recvTextEdit->append(">>> 发送指令: AT^LCDOFF (关闭LCD,录音测试前强制关闭)"); + + // 更新LCD状态为关闭(因为发送了关闭命令) + lcdBacklightOn = false; + + // LCD关闭后延迟1秒再进行下一步 + QTimer::singleShot(1000, this, [this]() { + if (isProductionTestRunning && currentTestStep == TEST_AUDIO) { + performAudioTestContinue(); + } + }); +} + +// 继续录音测试(LCD关闭后或无需关闭LCD时调用) +void MainWindow::performAudioTestContinue() +{ + if (!isProductionTestRunning || currentTestStep != TEST_AUDIO) { + return; + } + updateTestStatus("audio", STATUS_TESTING); ui->statusbar->showMessage("录音测试中:正在发送AUDIOTEST指令...", 3000); @@ -4753,36 +4942,28 @@ void MainWindow::perform4GSignalTest() return; } - qDebug() << "开始4G信号质量测试"; + qDebug() << "开始4G信号质量测试(统一使用CAT1GETSIGNAL)"; ui->recvTextEdit->append("========== 开始4G信号质量测试 =========="); ui->statusbar->showMessage("4G信号质量测试中...", 5000); - // 根据MODEM类型选择不同的测试方式 - if (isEGModem()) { - qDebug() << "检测到EG系列MODEM,使用CAT1信号测试方式"; - // EG系列MODEM:等待接收到第一次signal值后启动CAT1测试 - // 这里不需要主动发送指令,等待设备自动发送包含signal的数据 - ui->statusbar->showMessage("等待CAT1信号数据...", 5000); - - // 启动超时检测,如果长时间没有收到signal数据则失败 - signal4GTimer->start(10000); // 10秒超时 - qDebug() << "启动CAT1信号等待超时检测(10秒)"; - } else { - qDebug() << "检测到非EG系列MODEM,使用传统PPPSIGNALINFO测试方式"; - // 重置计数器 - signalTest4GCount = 0; - signalReceived4GCount = 0; - signalGood4GCount = 0; - - // 立即发送第一次信号检测指令 - serial->write("AT^PPPSIGNALINFO\r\n"); - qDebug() << "发送4G信号检测指令: AT^PPPSIGNALINFO"; - signalTest4GCount++; - - // 启动5秒定时器,定期检测信号质量 - signal4GTimer->start(5000); - qDebug() << "启动4G信号检测定时器(5秒间隔)"; - } + // 统一使用CAT1GETSIGNAL测试方式,不再区分MODEM类型,不再使用PPP相关指令 + // 初始化CAT1信号测试计数器 + cat1SignalTestCount = 0; + cat1SignalReceivedCount = 0; + cat1SignalGoodCount = 0; + cat1Signal99Count = 0; + cat1SignalTotalValue = 0; + hasReceivedFirstSignal = true; // 标记为已启动,直接开始CAT1测试 + + // 启动CAT1信号测试定时器,每2秒发送一次 + cat1SignalTimer->start(2000); + ui->statusbar->showMessage("开始CAT1信号测试,每2秒检测一次...", 3000); + + // 立即发送第一次CAT1信号检测指令 + serial->write("AT^CAT1GETSIGNAL\r\n"); + cat1SignalTestCount++; + qDebug() << "发送第" << cat1SignalTestCount << "次CAT1信号检测指令: AT^CAT1GETSIGNAL"; + ui->recvTextEdit->append(">>> 发送指令: AT^CAT1GETSIGNAL"); } // 4G信号检测定时器槽函数 @@ -4806,23 +4987,17 @@ void MainWindow::on4GSignalTimer() updateTestStatus("ppp", STATUS_FAILED); } } else { - // 非EG系列MODEM:继续发送PPPSIGNALINFO指令 - serial->write("AT^PPPSIGNALINFO\r\n"); - qDebug() << "定时发送4G信号检测指令: AT^PPPSIGNALINFO (第" << (signalTest4GCount + 1) << "次)"; - signalTest4GCount++; + // 非EG系列MODEM:统一使用CAT1GETSIGNAL,不再使用PPPSIGNALINFO + // 这个分支理论上不会执行到,因为perform4GSignalTest已经统一使用CAT1GETSIGNAL + signal4GTimer->stop(); + qDebug() << "4G信号检测超时,测试失败"; + ui->statusbar->showMessage("4G信号检测超时,测试失败", 5000); - // 如果发送次数过多,停止测试并失败 - if (signalTest4GCount >= 10) { // 最多发送10次指令 (约30秒) - signal4GTimer->stop(); - qDebug() << "4G信号检测发送10次指令,未收到足够有效数据,测试失败"; - ui->statusbar->showMessage("4G信号检测超时,测试失败", 5000); - - // 显示4G重复测试弹窗 - if (isProductionTestRunning) { - show4GRetryDialog("4G信号检测超时"); - } else { - updateTestStatus("ppp", STATUS_FAILED); - } + // 显示4G重复测试弹窗 + if (isProductionTestRunning) { + show4GRetryDialog("4G信号检测超时"); + } else { + updateTestStatus("ppp", STATUS_FAILED); } } } @@ -4908,18 +5083,10 @@ void MainWindow::onCat1SignalTimer() return; } - // 根据MODEM类型发送不同的信号检测指令 - if (isEGModem()) { - // EG系列MODEM使用CAT1GETSIGNAL指令 - serial->write("AT^CAT1GETSIGNAL\r\n"); - cat1SignalTestCount++; - qDebug() << "发送第" << cat1SignalTestCount << "次CAT1信号检测指令: AT^CAT1GETSIGNAL (EG系列MODEM)"; - } else { - // N7系列或其他MODEM使用PPPSIGNALINFO指令 - serial->write("AT^PPPSIGNALINFO\r\n"); - cat1SignalTestCount++; - qDebug() << "发送第" << cat1SignalTestCount << "次信号检测指令: AT^PPPSIGNALINFO (非EG系列MODEM)"; - } + // 统一使用CAT1GETSIGNAL指令 + serial->write("AT^CAT1GETSIGNAL\r\n"); + cat1SignalTestCount++; + qDebug() << "发送第" << cat1SignalTestCount << "次CAT1信号检测指令: AT^CAT1GETSIGNAL"; } // 检查4G信号质量结果 @@ -6132,14 +6299,18 @@ bool MainWindow::isTestItemEnabled(const QString& testName) const void MainWindow::skipToNextEnabledTest() { if (!isProductionTestRunning) { + qDebug() << "skipToNextEnabledTest: 产测未运行,退出"; return; } + qDebug() << "skipToNextEnabledTest: 当前测试步骤:" << currentTestStep; + // 根据当前测试步骤,推进到下一个启用的测试项 if (currentTestStep == TEST_LCD) { // LCD测试完成,检查马达测试 if (isTestItemEnabled("motor")) { currentTestStep = TEST_MOTOR; + qDebug() << "skipToNextEnabledTest: 推进到马达测试"; performMotorTest(); } else { qDebug() << "马达测试未启用,跳过"; @@ -6149,8 +6320,20 @@ void MainWindow::skipToNextEnabledTest() } } else if (currentTestStep == TEST_MOTOR) { // 马达测试完成,检查按键测试 + // 检查是否正在等待用户确认马达测试结果(只有在确认弹窗还在显示时才等待) + qDebug() << "skipToNextEnabledTest: 马达测试步骤,检查状态"; + qDebug() << " isWaitingForUserConfirm:" << isWaitingForUserConfirm; + qDebug() << " motorTestPopupShown:" << motorTestPopupShown; + + if (isWaitingForUserConfirm && motorTestPopupShown) { + qDebug() << "skipToNextEnabledTest: 马达测试正在等待用户确认,暂不推进到按键测试"; + return; // 等待用户确认完成后再推进 + } + + qDebug() << "skipToNextEnabledTest: 马达测试已完成,推进到按键测试"; if (isTestItemEnabled("key")) { currentTestStep = TEST_KEY; + qDebug() << "skipToNextEnabledTest: 推进到按键测试,调用performKeyTest()"; performKeyTest(); } else { qDebug() << "按键测试未启用,跳过"; diff --git a/mainwindow.h b/mainwindow.h index 6caa716..70f33fe 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -56,6 +56,7 @@ private slots: void performLcdTest(); // LCD测试 void performLcdColorTest(); // LCD颜色测试 void performMotorTest(); // 马达测试 + void performMotorTestContinue(); // 继续马达测试(LCD关闭后调用) void perform4GTest(); // 4G测试 void perform4GSignalTest(); // 4G信号质量测试 void onLcdTestTimer(); // LCD测试定时器 @@ -80,6 +81,7 @@ private slots: void checkKeyTestResult(const QString& data); // 检查按键测试结果 void showKeyTestConfirmDialog(bool allKeysTested); // 显示按键测试确认弹窗 void performAudioTest(); // 执行录音测试 + void performAudioTestContinue(); // 继续录音测试(LCD关闭后调用) void showAudioTestDialog(); // 显示录音测试弹窗 void onAudioRecordTimer(); // 录音测试定时器(3秒录音) void checkAudioTestResult(const QString& data); // 检查录音测试结果 @@ -161,6 +163,7 @@ private: bool lcdTestPopupShown; // LCD测试弹窗是否已显示 bool motorTestPopupShown; // 马达测试弹窗是否已显示 bool isWaitingForUserConfirm; // 是否正在等待用户确认 + bool lcdBacklightOn; // LCD背光状态:true=开启,false=关闭 bool keyTestStarted; // 按键测试是否已开始 int keyTestStatus[4]; // 按键测试状态 0=未测试 1=已测试 QDialog *keyTestDialog; // 按键测试弹窗 diff --git a/releasePackage/LN_Factorytool_V1.5.zip b/releasePackage/LN_Factorytool_V1.5.zip new file mode 100644 index 0000000..4bd6b2e Binary files /dev/null and b/releasePackage/LN_Factorytool_V1.5.zip differ diff --git a/releasePackage/LN_Factorytool_V1.5/LeiNiaoFactoryTool.exe b/releasePackage/LN_Factorytool_V1.5/LeiNiaoFactoryTool.exe new file mode 100644 index 0000000..b9f5b5b Binary files /dev/null and b/releasePackage/LN_Factorytool_V1.5/LeiNiaoFactoryTool.exe differ diff --git a/releasePackage/LN_Factorytool_V1.5/settings.json b/releasePackage/LN_Factorytool_V1.5/settings.json new file mode 100644 index 0000000..b12d9c4 --- /dev/null +++ b/releasePackage/LN_Factorytool_V1.5/settings.json @@ -0,0 +1,36 @@ +{ + "bootDetectionKeywords": [ + "BuildVer", + "NAND flash ID", + "NAND ID:" + ], + "factoryModeCheckCommand": "AT^FACTORY", + "factoryModeKeywords": [ + "FACTORY TEST MODE:" + ], + "testCheckboxes": { + "4g": true, + "bt": true, + "btn": false, + "charge": true, + "lcd": true, + "mic": false, + "ntc": false, + "vib": true + }, + "testConfig": { + "audioLevelStandard": "低", + "audioVolume": "2.0", + "bluetoothAddress": "", + "bluetoothRSSI": "", + "expectedModemVer": "EG800AKCN91LCR07A01M04_OCPU_QPY_BETA1022", + "expectedPYVer": "", + "expectedVer": "", + "portName": "COM42 (USB-Enhanced-SERIAL CH343)" + }, + "versionInfoCommands": [ + "AT^CAT1GETVER", + "AT^CAT1GETSIGNAL", + "AT^FACTORY" + ] +}