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*.
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..
Here my code.
Qt Code:
// Query available SerialPort name { 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++) { testPort.setPortName(testPortName); { portsName.append(testPortName); testPort.close(); } } #else // _UNIX QStringList filters; filters << "ttyS*" << "ttyUSB*"; dir.setNameFilters(filters); QFileInfoList list = dir.entryInfoList(); for (int i=0; i< list.size(); i++) { portsName.append(list.at(i).canonicalFilePath ()); } #endif return portsName; }To copy to clipboard, switch view to plain text mode
blm (29th June 2009)
thanks a lot, i will try it later!
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.
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'
Bookmarks