diff --git a/OtaUpdate/CdcUpdater.cpp b/OtaUpdate/CdcUpdater.cpp index 0509d4d..a1ebb5d 100644 --- a/OtaUpdate/CdcUpdater.cpp +++ b/OtaUpdate/CdcUpdater.cpp @@ -87,13 +87,17 @@ bool CdcUpdater::write(Command command, const uint8_t *data, uint32_t size) { void CdcUpdater::timerEvent(QTimerEvent *event) { const auto serialPortInfos = QSerialPortInfo::availablePorts(); for (const QSerialPortInfo &portInfo : serialPortInfos) { + LOG(info) << "portName:" << portInfo.portName().toStdString() + << ", vendorIdentifier: " << portInfo.vendorIdentifier(); if (portInfo.vendorIdentifier() == 0xffff) { LOG(info) << "founded device: " << portInfo.portName().toStdString(); emit deviceDiscovered(portInfo); killTimer(m_timerId); m_timerId = -1; + break; } } + LOG(info) << "----------"; } void CdcUpdater::transferBin() { diff --git a/Peripheral/DeviceDiscovery.cpp b/Peripheral/DeviceDiscovery.cpp index 28f1185..10a2035 100644 --- a/Peripheral/DeviceDiscovery.cpp +++ b/Peripheral/DeviceDiscovery.cpp @@ -54,7 +54,7 @@ std::shared_ptr DeviceDiscovery::find(const std::string } if (index >= 0) { IMFMediaSource *source = nullptr; - result = devices[0]->ActivateObject(IID_PPV_ARGS(&source)); + result = devices[index]->ActivateObject(IID_PPV_ARGS(&source)); if (FAILED(result)) { } else { ret = std::make_shared(source); @@ -80,11 +80,11 @@ std::string DeviceDiscovery::deviceName(IMFActivate *device) { void DeviceDiscovery::enterOtaMode(const std::shared_ptr &device, std::error_code &error) { auto resolutions = deviceResolutions(device); - // for (auto &[w, h] : resolutions) { - // LOG(info) << w << " " << h; - // } + LOG(info) << "device resolutions:"; + for (auto &[w, h] : resolutions) { + LOG(info) << "\t" << w << "*" << h; + } - // LOG(info) << "resolutions: " << resolutions.size(); int32_t otaSpecificHeight = -1; for (auto &[width, height] : resolutions) { if (width == OtaSpecificWidth) { @@ -95,6 +95,8 @@ void DeviceDiscovery::enterOtaMode(const std::shared_ptr &device, std::e if (otaSpecificHeight <= 0) { LOG(error) << "cannot find ota specific resolution."; return; + } else { + LOG(info) << "found ota specific resolution: " << OtaSpecificWidth << "x" << otaSpecificHeight; } IMFMediaType *type = nullptr;