本文整理汇总了C++中QSerialPortInfo::hasVendorIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ QSerialPortInfo::hasVendorIdentifier方法的具体用法?C++ QSerialPortInfo::hasVendorIdentifier怎么用?C++ QSerialPortInfo::hasVendorIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSerialPortInfo
的用法示例。
在下文中一共展示了QSerialPortInfo::hasVendorIdentifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
// Found the available ports, associated vendor id and product id
foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()){
if(serialPortInfo.hasVendorIdentifier() && serialPortInfo.hasProductIdentifier()){
if(serialPortInfo.vendorIdentifier() == found_vendorID){
if(serialPortInfo.productIdentifier() == found_productID){
arm_portname = serialPortInfo.portName();
arm_port_is_available = true;
}
}
}
}
示例2: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
// Get list of all serial ports
QList<QSerialPortInfo> serialInfoList = QSerialPortInfo::availablePorts();
qDebug();
if (!serialInfoList.size() > 0)
{
qDebug() << "no serial ports found";
return app.exec();
}
else
{
qDebug() << "List all serial ports";
qDebug() << "---------------------";
for (int i=0; i<serialInfoList.size(); i++)
{
QSerialPortInfo serialInfo = serialInfoList.at(i);
qDebug() << "port: " << i;
qDebug() << " name: " << serialInfo.portName();
qDebug() << " description: " << serialInfo.description();
qDebug() << " manufacturer: " << serialInfo.manufacturer();
//qDebug() << " serial Number: " << serialInfo.serialNumber();
if (serialInfo.hasVendorIdentifier())
{
qDebug() << " vendorId: " << serialInfo.vendorIdentifier();
}
if (serialInfo.hasProductIdentifier())
{
qDebug() << " producId: " << serialInfo.productIdentifier();
}
qDebug();
}
}
qDebug() << "opening panels controller";
QSerialPortInfo serialInfo = serialInfoList.at(0);
bias::PanelsController pcontrol(serialInfo);
bool isOpen = pcontrol.open();
if (!isOpen)
{
qDebug() << " unable to open device";
return app.exec();
}
qDebug() << " device opened";
if (true)
{
qDebug() << " blink led";
pcontrol.blinkLED();
QThread::msleep(4000);
}
// Test allOn, allOff
if (true)
{
for (int i=0; i<5; i++)
{
qDebug() << " all on";
pcontrol.allOn();
QThread::msleep(500);
qDebug() << " all off";
pcontrol.allOff();
QThread::msleep(500);
}
}
// Test setToGrayLevel
if (true)
{
for (int i=0; i<2; i++)
{
for (int j=1; j<bias::PanelsController::NUM_GRAY_LEVEL; j++)
{
qDebug() << " set to gray level = " << j;
pcontrol.setToGrayLevel(j);
QThread::msleep(100);
}
for (int j=bias::PanelsController::NUM_GRAY_LEVEL-1; j>=0; j--)
{
qDebug() << " set to gray level = " << j;
pcontrol.setToGrayLevel(j);
QThread::msleep(100);
}
}
}
// Test setConfigID
if (true)
{
int id = 1;
qDebug() << " set config id = " << id;
pcontrol.setConfigID(id);
QThread::msleep(1000);
}
// Test setPatternID
if (true)
//.........这里部分代码省略.........