Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Port scanning is not working properly
Forum Updated to NodeBB v4.3 + New Features

Port scanning is not working properly

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 512 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • serkan_trS Offline
    serkan_trS Offline
    serkan_tr
    wrote on last edited by
    #1

    Hi,
    I typed the command below on my Windows computer and when I ran it, no output was produced. I typed the command below on my Windows computer and when I ran it, no output was produced. I wonder why this is happening and what is the solution. Why can't I print or see the ports? I uninstalled and reinstalled the application (QT6) but not the solution.

    The code used to print all ports on Linux devices and Windows, and if something was connected to the port, it would also print other information. Now it only sees the FTDI I connected.

    I installed stm32cubeide on my system, is there a chance that it will break the working of QT?

    code:

    #include <QCoreApplication>
    #include <QSerialPort>
    #include <QSerialPortInfo>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        foreach (const QSerialPortInfo &portInfo, QSerialPortInfo::availablePorts()) {
            qDebug() << "-----------------------------------------------------";
            qDebug() << "Port Name:          " << portInfo.portName();
            qDebug() << "System Location:    " << portInfo.systemLocation();
            qDebug() << "Description:        " << portInfo.description();
            qDebug() << "Manufacturer:       " << portInfo.manufacturer();
            qDebug() << "Serial Number:      " << portInfo.serialNumber();
    
        }
    
        return a.exec();
    }
    
    
    jsulmJ 1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by mrdebug
      #6

      Hi, the code is correct and there isn't a problem on Qt related to serial ports.
      In order to have a comport available in Qt you should verify if it is correctly configured in Windows, please have a look at the Windows devices list and check that the driver is configured correctly.
      You can't know what it is attached to a comport without to check it by protocol, for example if you want to know if there is a modem plugged in you should use the AT commands in all com ports to search for a modem. You only can know if a comport in already open or not.
      The vendor is relative to the usb adapter but the device could be different.
      If you want to use a usb device without to configured it you could use libusb.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      2
      • serkan_trS serkan_tr

        Hi,
        I typed the command below on my Windows computer and when I ran it, no output was produced. I typed the command below on my Windows computer and when I ran it, no output was produced. I wonder why this is happening and what is the solution. Why can't I print or see the ports? I uninstalled and reinstalled the application (QT6) but not the solution.

        The code used to print all ports on Linux devices and Windows, and if something was connected to the port, it would also print other information. Now it only sees the FTDI I connected.

        I installed stm32cubeide on my system, is there a chance that it will break the working of QT?

        code:

        #include <QCoreApplication>
        #include <QSerialPort>
        #include <QSerialPortInfo>
        #include <QDebug>
        
        int main(int argc, char *argv[])
        {
            QCoreApplication a(argc, argv);
        
            foreach (const QSerialPortInfo &portInfo, QSerialPortInfo::availablePorts()) {
                qDebug() << "-----------------------------------------------------";
                qDebug() << "Port Name:          " << portInfo.portName();
                qDebug() << "System Location:    " << portInfo.systemLocation();
                qDebug() << "Description:        " << portInfo.description();
                qDebug() << "Manufacturer:       " << portInfo.manufacturer();
                qDebug() << "Serial Number:      " << portInfo.serialNumber();
        
            }
        
            return a.exec();
        }
        
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @serkan_tr said in Port scanning is not working properly:

        Why can't I print or see the ports?

        Because QSerialPortInfo::availablePorts() returns an empty list.
        Does your machine have working serial ports?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        serkan_trS 1 Reply Last reply
        1
        • A Offline
          A Offline
          ankou29666
          wrote on last edited by
          #3

          one interesting thing you should do : print to console the size of the list

          QList <QSerialPortInfo> listPorts = QSerialPortInfo::availablePorts() ;
          qDebug() << "Serial ports count : " << listPorts.size() ;
          

          So that you get an explicit indication of an empty list.

          serkan_trS 1 Reply Last reply
          1
          • jsulmJ jsulm

            @serkan_tr said in Port scanning is not working properly:

            Why can't I print or see the ports?

            Because QSerialPortInfo::availablePorts() returns an empty list.
            Does your machine have working serial ports?

            serkan_trS Offline
            serkan_trS Offline
            serkan_tr
            wrote on last edited by
            #4

            @jsulm In normal use, it showed all "com" ports whether something was plugged in or not. When I deploy the code and run it on a different computer, it gives the correct output.

            It turned out right:
            5778125078356149340.jpg

            I use my computer as a dual operating system and this code works correctly on the Linux side. It does not work correctly on the Windows side on the computer I built it on. When I run the executable on a different computer, it works correctly.

            Make sure the code is correct. The only problem is that there seems to be a situation on my Windows computer that prevents this from happening. This code was working correctly when I first wrote it. But the last time I tried it, it stopped working properly.

            1 Reply Last reply
            0
            • A ankou29666

              one interesting thing you should do : print to console the size of the list

              QList <QSerialPortInfo> listPorts = QSerialPortInfo::availablePorts() ;
              qDebug() << "Serial ports count : " << listPorts.size() ;
              

              So that you get an explicit indication of an empty list.

              serkan_trS Offline
              serkan_trS Offline
              serkan_tr
              wrote on last edited by
              #5

              @ankou29666 Make sure the code is correct. The only problem is that there seems to be a situation on my Windows computer that prevents this from happening. This code was working correctly when I first wrote it. But the last time I tried it, it stopped working properly.

              1 Reply Last reply
              0
              • mrdebugM Offline
                mrdebugM Offline
                mrdebug
                wrote on last edited by mrdebug
                #6

                Hi, the code is correct and there isn't a problem on Qt related to serial ports.
                In order to have a comport available in Qt you should verify if it is correctly configured in Windows, please have a look at the Windows devices list and check that the driver is configured correctly.
                You can't know what it is attached to a comport without to check it by protocol, for example if you want to know if there is a modem plugged in you should use the AT commands in all com ports to search for a modem. You only can know if a comport in already open or not.
                The vendor is relative to the usb adapter but the device could be different.
                If you want to use a usb device without to configured it you could use libusb.

                Need programmers to hire?
                www.labcsp.com
                www.denisgottardello.it
                GMT+1
                Skype: mrdebug

                1 Reply Last reply
                2
                • serkan_trS serkan_tr has marked this topic as solved on

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved