diff --git a/src/plugins/openmv/tools/driveserialnumber.cpp b/src/plugins/openmv/tools/driveserialnumber.cpp index 909f574bbcf..624135beb32 100644 --- a/src/plugins/openmv/tools/driveserialnumber.cpp +++ b/src/plugins/openmv/tools/driveserialnumber.cpp @@ -13,28 +13,28 @@ extern QMutex dfu_util_working; QString serialPortDriveSerialNumber(const QString &portName) { -#if defined(Q_OS_WIN) - Utils::Process process; - std::chrono::seconds timeout(10); - process.setTextChannelMode(Utils::Channel::Output, Utils::TextChannelMode::MultiLine); - process.setTextChannelMode(Utils::Channel::Error, Utils::TextChannelMode::MultiLine); - process.setCommand(Utils::CommandLine(Utils::FilePath::fromString(QStringLiteral("powershell")), - QStringList() - << QStringLiteral("-Command") - << QString(QStringLiteral("(Get-PnpDeviceProperty -InstanceId (Get-WmiObject Win32_SerialPort | Where-Object { $_.DeviceID -eq '%1' }).PNPDeviceId | Where-Object { $_.KeyName -eq 'DEVPKEY_Device_Parent' }).Data")).arg(QString(portName)))); - process.runBlocking(timeout, Utils::EventLoopMode::Off); - - if(process.result() == Utils::ProcessResult::FinishedWithSuccess) - { - QRegularExpressionMatch match = QRegularExpression("\\\\(\\w+)$").match(process.stdOut().trimmed()); - if (match.hasMatch()) return match.captured(1); - } -#elif (defined(Q_OS_LINUX) || defined(Q_OS_MAC)) +// #if defined(Q_OS_WIN) +// Utils::Process process; +// std::chrono::seconds timeout(10); +// process.setTextChannelMode(Utils::Channel::Output, Utils::TextChannelMode::MultiLine); +// process.setTextChannelMode(Utils::Channel::Error, Utils::TextChannelMode::MultiLine); +// process.setCommand(Utils::CommandLine(Utils::FilePath::fromString(QStringLiteral("powershell")), +// QStringList() +// << QStringLiteral("-Command") +// << QString(QStringLiteral("(Get-PnpDeviceProperty -InstanceId (Get-WmiObject Win32_SerialPort | Where-Object { $_.DeviceID -eq '%1' }).PNPDeviceId | Where-Object { $_.KeyName -eq 'DEVPKEY_Device_Parent' }).Data")).arg(QString(portName)))); +// process.runBlocking(timeout, Utils::EventLoopMode::On); + +// if(process.result() == Utils::ProcessResult::FinishedWithSuccess) +// { +// QRegularExpressionMatch match = QRegularExpression("\\\\(\\w+)$").match(process.stdOut().trimmed()); +// if (match.hasMatch()) return match.captured(1); +// } +// #elif (defined(Q_OS_LINUX) || defined(Q_OS_MAC)) MyQSerialPortInfo info = MyQSerialPortInfo(QSerialPortInfo(portName)); return info.serialNumber(); -#endif +// #endif - return QString(); +// return QString(); } QString driveSerialNumber(const QString &drivePath) @@ -48,7 +48,7 @@ QString driveSerialNumber(const QString &drivePath) QStringList() << QStringLiteral("-Command") << QString(QStringLiteral("(Get-Disk -Number (Get-Partition -DriveLetter '%1').DiskNumber).SerialNumber")).arg(QString(drivePath).remove(QStringLiteral(":")).remove(QStringLiteral("/"))))); - process.runBlocking(timeout, Utils::EventLoopMode::Off); + process.runBlocking(timeout, Utils::EventLoopMode::On); if(process.result() == Utils::ProcessResult::FinishedWithSuccess) { @@ -67,7 +67,7 @@ QString driveSerialNumber(const QString &drivePath) << QStringLiteral("-J") << QStringLiteral("-o") << QStringLiteral("MOUNTPOINT,NAME,SERIAL"))); - process.runBlocking(timeout, Utils::EventLoopMode::Off); + process.runBlocking(timeout, Utils::EventLoopMode::On); if(process.result() == Utils::ProcessResult::FinishedWithSuccess) { @@ -114,7 +114,7 @@ QString driveSerialNumber(const QString &drivePath) process.setCommand(Utils::CommandLine(Utils::FilePath::fromString(QStringLiteral("system_profiler")), QStringList() << QStringLiteral("SPUSBDataType") << QStringLiteral("-json"))); - process.runBlocking(timeout, Utils::EventLoopMode::Off); + process.runBlocking(timeout, Utils::EventLoopMode::On); if(process.result() == Utils::ProcessResult::FinishedWithSuccess) { @@ -142,7 +142,7 @@ QString driveSerialNumber(const QString &drivePath) << QStringLiteral("list") << QStringLiteral("-plist") << diskName)); - process.runBlocking(timeout, Utils::EventLoopMode::Off); + process.runBlocking(timeout, Utils::EventLoopMode::On); if (process.stdOut().contains(QString(QStringLiteral("%1")).arg(drivePath))) { diff --git a/src/plugins/openmv/tools/myqserialportinfo.cpp b/src/plugins/openmv/tools/myqserialportinfo.cpp index e98058be771..ad18bf933a6 100644 --- a/src/plugins/openmv/tools/myqserialportinfo.cpp +++ b/src/plugins/openmv/tools/myqserialportinfo.cpp @@ -83,7 +83,7 @@ MyQSerialPortInfo::MyQSerialPortInfo(const QSerialPortInfo &info) << QStringLiteral("-v") << QStringLiteral("-d") << QString(QStringLiteral("%1:%2")).arg(m_vendorIdentifier, 4, 16, QLatin1Char('0')).arg(m_productIdentifier, 4, 16, QLatin1Char('0')))); - process.runBlocking(timeout, Utils::EventLoopMode::Off); + process.runBlocking(timeout, Utils::EventLoopMode::On); if(process.result() == Utils::ProcessResult::FinishedWithSuccess) {