Results 1 to 10 of 10

Thread: QtSerialPort - SerialPortInfo returns 0 ports available

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Location
    N/A
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QtSerialPort - SerialPortInfo returns 0 ports available

    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?

    Qt Code:
    1. QList<QSerialPortInfo> serialPortInfoList = QSerialPortInfo::availablePorts();
    2. QTextStream out(stdout);
    3.  
    4. out << QObject::tr("Total number of ports available: ") << serialPortInfoList.count() << endl;
    5.  
    6. foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) {
    7. out << endl
    8. << QObject::tr("Port: ") << serialPortInfo.portName() << endl
    9. << QObject::tr("Location: ") << serialPortInfo.systemLocation() << endl
    10. << QObject::tr("Description: ") << serialPortInfo.description() << endl
    11. << QObject::tr("Manufacturer: ") << serialPortInfo.manufacturer() << endl
    12. << QObject::tr("Vendor Identifier: ") << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) : QByteArray()) << endl
    13. << QObject::tr("Product Identifier: ") << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) : QByteArray()) << endl
    14. << QObject::tr("Busy: ") << (serialPortInfo.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) << endl;
    15. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. QT += core gui sql serialport
    To copy to clipboard, switch view to plain text mode 

    Output:

    Total number of ports available: 0

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtSerialPort - SerialPortInfo returns 0 ports available

    This may be an issue with Windows Setup API not showing the errant device.

    What happens if you just try to open COMx?

  3. #3
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtSerialPort - SerialPortInfo returns 0 ports available

    2 slanina,

    Possibly it is regression which belongs to a recent patch which had to optimize enumeration: https://codereview.qt-project.org/#change,53725

    Also already created issue about this bug: https://bugreports.qt-project.org/br...TPLAYGROUND-27

    May you give detailed information on the used device (VID/PID/Class GUID and etc), and also give *.inf driver files?


    UPD:
    At present the solution isn't known. Temporarily you can use workaround - simply to roll away change to this patch for QSerialPortInfo.

    PS:
    Win32 API again and again throws to us "surprises".
    The behavior of Setup API doesn't give in to logic, or I don't understand something...

  4. #4
    Join Date
    Apr 2013
    Location
    N/A
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtSerialPort - SerialPortInfo returns 0 ports available

    Quote Originally Posted by kuzulis View Post
    2 slanina,

    Possibly it is regression which belongs to a recent patch which had to optimize enumeration: https://codereview.qt-project.org/#change,53725

    Also already created issue about this bug: https://bugreports.qt-project.org/br...TPLAYGROUND-27

    May you give detailed information on the used device (VID/PID/Class GUID and etc), and also give *.inf driver files?


    UPD:
    At present the solution isn't known. Temporarily you can use workaround - simply to roll away change to this patch for QSerialPortInfo.

    PS:
    Win32 API again and again throws to us "surprises".
    The behavior of Setup API doesn't give in to logic, or I don't understand something...
    It is a custom device I am developing from one sample given by NXP for their LPC series of microcontrollers (LPC11U35). It is based on the code that works fine on the device side as given by NXP. Actually based on that code I did a device and one code in October 2012 but then I have used QtExtSerialPort and it enumerated fine.
    Enumeration would be beneficial to me, since I could then detect and parse manufacturer name and device name (basically me) and make sure the user does not need to select a COM port - so I could have an "auto connect" upon application loading.

    Any hints how to rollback the patch? I have never done this on Windows.

    Upload of .inf file seems to fail so I am copying it below. It uses NXP VID/PID since it is their example...

    Qt Code:
    1. ;************************************************************
    2. ; Windows USB CDC ACM Setup File
    3. ; Copyright (c) 2000 Microsoft Corporation
    4.  
    5.  
    6. [Version]
    7. Signature="$Windows NT$"
    8. Class=Ports
    9. ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
    10. Provider=%MFGNAME%
    11. LayoutFile=layout.inf
    12. CatalogFile=%MFGFILENAME%.cat
    13. DriverVer=11/15/2007,5.1.2600.0
    14.  
    15. [Manufacturer]
    16. %MFGNAME%=DeviceList, NTamd64
    17.  
    18. [DestinationDirs]
    19. DefaultDestDir=12
    20.  
    21.  
    22. ;------------------------------------------------------------------------------
    23. ; Windows 2000/XP/Vista-32bit Sections
    24. ;------------------------------------------------------------------------------
    25.  
    26. [DriverInstall.nt]
    27. include=mdmcpq.inf
    28. CopyFiles=DriverCopyFiles.nt
    29. AddReg=DriverInstall.nt.AddReg
    30.  
    31. [DriverCopyFiles.nt]
    32. usbser.sys,,,0x20
    33.  
    34. [DriverInstall.nt.AddReg]
    35. HKR,,DevLoader,,*ntkern
    36. HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
    37. HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
    38.  
    39. [DriverInstall.nt.Services]
    40. AddService=usbser, 0x00000002, DriverService.nt
    41.  
    42. [DriverService.nt]
    43. DisplayName=%SERVICE%
    44. ServiceType=1
    45. StartType=3
    46. ErrorControl=1
    47. ServiceBinary=%12%\%DRIVERFILENAME%.sys
    48.  
    49. ;------------------------------------------------------------------------------
    50. ; Vista-64bit Sections
    51. ;------------------------------------------------------------------------------
    52.  
    53. [DriverInstall.NTamd64]
    54. include=mdmcpq.inf
    55. CopyFiles=DriverCopyFiles.NTamd64
    56. AddReg=DriverInstall.NTamd64.AddReg
    57.  
    58. [DriverCopyFiles.NTamd64]
    59. %DRIVERFILENAME%.sys,,,0x20
    60.  
    61. [DriverInstall.NTamd64.AddReg]
    62. HKR,,DevLoader,,*ntkern
    63. HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
    64. HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
    65.  
    66. [DriverInstall.NTamd64.Services]
    67. AddService=usbser, 0x00000002, DriverService.NTamd64
    68.  
    69. [DriverService.NTamd64]
    70. DisplayName=%SERVICE%
    71. ServiceType=1
    72. StartType=3
    73. ErrorControl=1
    74. ServiceBinary=%12%\%DRIVERFILENAME%.sys
    75.  
    76.  
    77. ;------------------------------------------------------------------------------
    78. ; Vendor and Product ID Definitions
    79. ;------------------------------------------------------------------------------
    80. ; When developing your USB device, the VID and PID used in the PC side
    81. ; application program and the firmware on the microcontroller must match.
    82. ; Modify the below line to use your VID and PID. Use the format as shown below.
    83. ; Note: One INF file can be used for multiple devices with different VID and PIDs.
    84. ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
    85. ;------------------------------------------------------------------------------
    86. [SourceDisksFiles]
    87. [SourceDisksNames]
    88. [DeviceList]
    89. %DESCRIPTION%=DriverInstall, USB\VID_1FC9&PID_2047
    90.  
    91. [DeviceList.NTamd64]
    92. %DESCRIPTION%=DriverInstall, USB\VID_1FC9&PID_2047
    93.  
    94.  
    95. ;------------------------------------------------------------------------------
    96. ; String Definitions
    97. ;------------------------------------------------------------------------------
    98. ;Modify these strings to customize your device
    99. ;------------------------------------------------------------------------------
    100. [Strings]
    101. MFGFILENAME="CDC_vista"
    102. DRIVERFILENAME ="usbser"
    103. MFGNAME="http://www.lpcware.com/content/project/LPCUSBlib"
    104. INSTDISK="LPCUSBlib CDC Driver Installer"
    105. DESCRIPTION="Communications Port"
    106. SERVICE="USB RS-232 Emulation Driver"
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtSerialPort - SerialPortInfo returns 0 ports available

    It is clear. It seems that this problem is observed with USB CDC ACM devices.

    Please try new patch: https://bugreports.qt-project.org/br...TPLAYGROUND-27

    And please let me know about results.
    Last edited by kuzulis; 26th April 2013 at 14:27.

Similar Threads

  1. Adding QtSerialPort as a library -
    By HSPalm in forum Newbie
    Replies: 14
    Last Post: 26th June 2014, 16:16
  2. Help to generate QtSerialPort documentation
    By cstr in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2013, 19:04
  3. Replies: 18
    Last Post: 3rd December 2012, 17:05
  4. QtSerialPort synchronous approach
    By codein in forum Newbie
    Replies: 2
    Last Post: 4th September 2012, 09:45
  5. cannot build qtserialport
    By banlinhtienphong in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2011, 05:56

Tags for this Thread

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.