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. if I unplug the device then also function QSerialPortInfo::availablePorts(); show serial port is avaiable. Is it other ways to find the devices is disconnected or not?
Forum Updated to NodeBB v4.3 + New Features

if I unplug the device then also function QSerialPortInfo::availablePorts(); show serial port is avaiable. Is it other ways to find the devices is disconnected or not?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.3k Views
  • 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.
  • Y Offline
    Y Offline
    Yash001
    wrote on last edited by
    #1

    I am using Qt 5.6.3. Here I found some realated document https://bugreports.qt.io/browse/QTBUG-50052. Inside the Document, find the unconnected port with help of error but I could not generate the error because port open,close, read, write handle into separate thread. current thread, just check the device is connected or not. if device is connected then data will be trasfer manually from GUI or receive into GUI.

    Device is not connected which is identify by comparing two list, already connected port and available port.

    auto availablePorts = QSerialPortInfo::availablePorts();

    if already connected port is not avaiable into avaiable port the device is disconnected and device show into GUI.

    auto error = QSerialPort::SerialPortError();
    qdebug() << "error" << error;

    here i am always getting QSerialPort::NoError.

    How can I solve this issue? or how can i Use QserialPortinfo from another verison of QT?

    aha_1980A 1 Reply Last reply
    0
    • Y Yash001

      I am using Qt 5.6.3. Here I found some realated document https://bugreports.qt.io/browse/QTBUG-50052. Inside the Document, find the unconnected port with help of error but I could not generate the error because port open,close, read, write handle into separate thread. current thread, just check the device is connected or not. if device is connected then data will be trasfer manually from GUI or receive into GUI.

      Device is not connected which is identify by comparing two list, already connected port and available port.

      auto availablePorts = QSerialPortInfo::availablePorts();

      if already connected port is not avaiable into avaiable port the device is disconnected and device show into GUI.

      auto error = QSerialPort::SerialPortError();
      qdebug() << "error" << error;

      here i am always getting QSerialPort::NoError.

      How can I solve this issue? or how can i Use QserialPortinfo from another verison of QT?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Yash001,

      which platform are you using?

      QSerialPortInfo uses OS functions to detect the ports. So first we need to make sure your OS handles this properly.

      Qt has to stay free or it will die.

      1 Reply Last reply
      2
      • Y Offline
        Y Offline
        Yash001
        wrote on last edited by
        #3

        I am using OS window 10, Qt 5.6.3 with visual studio 2017.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by kuzulis
          #4

          On Windows, if you try to unplug an already opened serial port, then the QSPI may show that this serial port is available within some time, or, until you do not close it. It is completelly OS-specific issue, as Andre already said before.

          If you want to watch for a true serial port availability, then you need to implement own class-watcher, using WM_DEVICECHANGE on Windows, or, using udev's API on Linux (if you needs in).

          PS: Also I recomment update your Qt to latest.

          1 Reply Last reply
          3

          • Login

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