Results 1 to 10 of 10

Thread: Qextserual can't detect virtual com-port

  1. #1
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy 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...
    Qt Code:
    1. QextSerialEnumerator enumer;
    2. QList<QextPortInfo>ports = enumer.getPorts();
    3. QStringList strlist;
    4. strlist.clear();
    5. for( int i = 0; i < ports.count(); ++i) strlist << ports.at(i).portName;
    6. ui.comboBox_Comm->addItems(strlist);
    To copy to clipboard, switch view to plain text mode 

    In fact i have got the info from real comm-port, but can't get the info from virtual comm-port

    thanks!
    Jim

  2. #2
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qextserual can't detect virtual com-port

    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*.

  3. #3
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qextserual can't detect virtual com-port

    Quote Originally Posted by PaceyIV View Post
    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..

  4. #4
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qextserual can't detect virtual com-port

    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.

  5. #5
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qextserual can't detect virtual com-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..

  6. #6
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qextserual can't detect virtual com-port

    Quote Originally Posted by PaceyIV View Post
    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.

  7. #7
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qextserual can't detect virtual com-port

    Here my code.


    Qt Code:
    1. // Query available SerialPort name
    2.  
    3. QStringList MySerialPort::availablePortsName()
    4.  
    5. {
    6.  
    7. QextSerialPort testPort;
    8. testPort.setBaudRate(BAUD115200);
    9. testPort.setFlowControl(FLOW_OFF);
    10. testPort.setParity(PAR_NONE);
    11. testPort.setDataBits(DATA_8);
    12. testPort.setStopBits(STOP_1);
    13.  
    14. QStringList portsName;
    15. QString testPortName;
    16.  
    17. #ifdef _WIN
    18. for (int i=1; i<MAX_COM_PORT; i++)
    19. {
    20. testPortName = QString("COM%1").arg(i);
    21. testPort.setPortName(testPortName);
    22. if (testPort.open(QIODevice::ReadWrite))
    23. {
    24. portsName.append(testPortName);
    25. testPort.close();
    26. }
    27. }
    28.  
    29. #else // _UNIX
    30. QDir dir("/dev");
    31. QStringList filters;
    32.  
    33. filters << "ttyS*" << "ttyUSB*";
    34. dir.setNameFilters(filters);
    35. dir.setFilter(QDir::Files | QDir::System);
    36. QFileInfoList list = dir.entryInfoList();
    37.  
    38. for (int i=0; i< list.size(); i++)
    39. {
    40. portsName.append(list.at(i).canonicalFilePath ());
    41. }
    42. #endif
    43.  
    44. return portsName;
    45. }
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to PaceyIV for this useful post:

    blm (29th June 2009)

  9. #8
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qextserual can't detect virtual com-port

    thanks a lot, i will try it later!

  10. #9
    Join Date
    Oct 2012
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qextserual can't detect virtual com-port

    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.

  11. #10
    Join Date
    Nov 2012
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Qextserual can't detect virtual com-port

    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'

Similar Threads

  1. Q3ScrollView resists to scroll down to the garbage bin
    By sivrisinek in forum Qt Programming
    Replies: 0
    Last Post: 5th February 2009, 17:50
  2. Cost of pure virtual
    By ShaChris23 in forum General Programming
    Replies: 4
    Last Post: 4th November 2007, 18:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.