I have Qt 5.0.1 on Windows 7 64-bit and I have downloaded and installed QtSerialPort following instructions on Wiki. I use MS VC++ Express 2010 compiler.
With simple example code from cenumerator I get 0 ports available. However, in Control Panel and using terminal program I can connect to my serial device.
I also did a quick Python script and it works from there using PySerial.
Any thoughts how to fix this?
QList<QSerialPortInfo> serialPortInfoList = QSerialPortInfo::availablePorts();
out <<
QObject::tr("Total number of ports available: ") << serialPortInfoList.
count() << endl;
foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) {
out << endl
<<
QObject::tr("Port: ") << serialPortInfo.
portName() << endl
<<
QObject::tr("Location: ") << serialPortInfo.
systemLocation() << endl
<<
QObject::tr("Description: ") << serialPortInfo.
description() << endl
<<
QObject::tr("Manufacturer: ") << serialPortInfo.
manufacturer() << endl
<<
QObject::tr("Vendor Identifier: ") <<
(serialPortInfo.
hasVendorIdentifier() ?
QByteArray::number(serialPortInfo.
vendorIdentifier(),
16) : QByteArray()) << endl
<<
QObject::tr("Product Identifier: ") <<
(serialPortInfo.
hasProductIdentifier() ?
QByteArray::number(serialPortInfo.
productIdentifier(),
16) : QByteArray()) << endl
}
QList<QSerialPortInfo> serialPortInfoList = QSerialPortInfo::availablePorts();
QTextStream out(stdout);
out << QObject::tr("Total number of ports available: ") << serialPortInfoList.count() << endl;
foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) {
out << endl
<< QObject::tr("Port: ") << serialPortInfo.portName() << endl
<< QObject::tr("Location: ") << serialPortInfo.systemLocation() << endl
<< QObject::tr("Description: ") << serialPortInfo.description() << endl
<< QObject::tr("Manufacturer: ") << serialPortInfo.manufacturer() << endl
<< QObject::tr("Vendor Identifier: ") << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) : QByteArray()) << endl
<< QObject::tr("Product Identifier: ") << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) : QByteArray()) << endl
<< QObject::tr("Busy: ") << (serialPortInfo.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) << endl;
}
To copy to clipboard, switch view to plain text mode
QT += core gui sql serialport
QT += core gui sql serialport
To copy to clipboard, switch view to plain text mode
Output:
Total number of ports available: 0
Bookmarks