添加升级串口打开失败后继续尝试的逻辑。
This commit is contained in:
@ -42,9 +42,7 @@ CdcUpdater::~CdcUpdater() {
|
||||
|
||||
void CdcUpdater::start(const QString &path, const QSerialPortInfo &info) {
|
||||
if (info.isNull()) {
|
||||
if (m_timerId < 0) {
|
||||
m_timerId = startTimer(1000);
|
||||
}
|
||||
startSearchDevice();
|
||||
} else {
|
||||
open(info);
|
||||
}
|
||||
@ -54,6 +52,12 @@ void CdcUpdater::start(const QString &path, const QSerialPortInfo &info) {
|
||||
emit progressChanged(++m_progress);
|
||||
}
|
||||
|
||||
void CdcUpdater::startSearchDevice() {
|
||||
if (m_timerId < 0) {
|
||||
m_timerId = startTimer(1000);
|
||||
}
|
||||
}
|
||||
|
||||
bool CdcUpdater::open(const QSerialPortInfo &info) {
|
||||
m_serialPort = std::make_shared<QSerialPort>(info);
|
||||
connect(m_serialPort.get(), &QSerialPort::readyRead, this, &CdcUpdater::onReadyRead);
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
CdcUpdater(QObject *parent = nullptr);
|
||||
~CdcUpdater();
|
||||
void start(const QString &path, const QSerialPortInfo &info = QSerialPortInfo());
|
||||
void startSearchDevice();
|
||||
bool open(const QSerialPortInfo &info);
|
||||
static std::optional<QSerialPortInfo> searchDevice();
|
||||
|
||||
|
Reference in New Issue
Block a user