View Full Version : Qextserual can't detect virtual com-port
Hey everybody,
just got a question if anyone noticed similar problem to mine..
im using qt 4.5 with qexserialport 1.2 alpha
got a device connected to USB Serial Port (FTDI)
I noticed that it actually cant detect it...
QextSerialEnumerator enumer;
QList<QextPortInfo>ports = enumer.getPorts();
QStringList strlist;
strlist.clear();
for( int i = 0; i < ports.count(); ++i) strlist << ports.at(i).portName;
ui.comboBox_Comm->addItems(strlist);
In fact i have got the info from real comm-port, but can't get the info from virtual comm-port:confused:
thanks!
Jim
PaceyIV
17th June 2009, 22:35
I don't use this alpha version of Qextserialport.
You can scan a list of QString("COM%1").arg(i) and try to open the port: if you can open it, there is an available port. On Linux you can query the list of /dev/ttyS* and /dev/ttyUSB*.
I don't use this alpha version of Qextserialport.
You can scan a list of QString("COM%1").arg(i) and try to open the port: if you can open it, there is an available port. On Linux you can query the list of /dev/ttyS* and /dev/ttyUSB*.
thanks, but i have got the list of com port information, but except for the vitual com port..
PaceyIV
19th June 2009, 14:16
I don't understand. What's the difference between a virtual-com and a real-com port?
If I connect my Arduino with the USB cable on my PC (a microcontroller with the FTDI chip), Windows, same as Linux, shows me a COM3 or a /dev/ttyUSB0. This is a virtual com port, but the system operator is the only subject that knows this. Any programs see that port as a real serial port.
indeed, i can see the virtual-com port under device management (windows), und i can use other software to open the port, but, only my Qt code, as i described, can't detect die virtual-com port.
so i don't understand, if the QextSerialEnumerator support the virtual-device or not..
I don't use this alpha version of Qextserialport.
You can scan a list of QString("COM%1").arg(i) and try to open the port: if you can open it, there is an available port. On Linux you can query the list of /dev/ttyS* and /dev/ttyUSB*.
however, i notice that you can scan the port with a normal version of Qextserialport?
I used the alpha version of Qextserialport because it can easy detect the port information.
PaceyIV
19th June 2009, 15:35
Here my code.
// Query available SerialPort name
QStringList MySerialPort::availablePortsName()
{
QextSerialPort testPort;
testPort.setBaudRate(BAUD115200);
testPort.setFlowControl(FLOW_OFF);
testPort.setParity(PAR_NONE);
testPort.setDataBits(DATA_8);
testPort.setStopBits(STOP_1);
QStringList portsName;
QString testPortName;
#ifdef _WIN
for (int i=1; i<MAX_COM_PORT; i++)
{
testPortName = QString("COM%1").arg(i);
testPort.setPortName(testPortName);
if (testPort.open(QIODevice::ReadWrite))
{
portsName.append(testPortName);
testPort.close();
}
}
#else // _UNIX
QDir dir("/dev");
QStringList filters;
filters << "ttyS*" << "ttyUSB*";
dir.setNameFilters(filters);
dir.setFilter(QDir::Files | QDir::System);
QFileInfoList list = dir.entryInfoList();
for (int i=0; i< list.size(); i++)
{
portsName.append(list.at(i).canonicalFilePath ());
}
#endif
return portsName;
}
thanks a lot, i will try it later!
sHs
9th December 2012, 17:54
Hi,
I use code very similiar to the one PaceyIV posted.
The problem is that my system gets blocked whenever a COM Port is not existing but Qt tries to open it anyways. My whole application freezes for about 5 seconds
I have two ideas for a solution.
Let the open methods run in the background. How? I dont know.
Set a timeout for the open method. How? I dont know.
Another option would be a different code that avoids opening ports that dont exist, is there a solution for that?
Any help is highly appreciated.
sankarakumar
13th December 2012, 08:45
hi i want to get the corresponding port name when we choose a printer name in a combobox.....i stuck with it for few days,,,kindly help me'
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.