// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include #include #include void enumeratePorts() { //! [enumerate_ports] const auto serialPortInfos = QSerialPortInfo::availablePorts(); for (const QSerialPortInfo &portInfo : serialPortInfos) { qDebug() << "\n" << "Port:" << portInfo.portName() << "\n" << "Location:" << portInfo.systemLocation() << "\n" << "Description:" << portInfo.description() << "\n" << "Manufacturer:" << portInfo.manufacturer() << "\n" << "Serial number:" << portInfo.serialNumber() << "\n" << "Vendor Identifier:" << (portInfo.hasVendorIdentifier() ? QByteArray::number(portInfo.vendorIdentifier(), 16) : QByteArray()) << "\n" << "Product Identifier:" << (portInfo.hasProductIdentifier() ? QByteArray::number(portInfo.productIdentifier(), 16) : QByteArray()); } //! [enumerate_ports] } int main(int argc, char **argv) { QCoreApplication app(argc, argv); enumeratePorts(); return app.exec(); } #include "doc_src_serialport.moc"