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. Looking for a signal in QSerialPort class that tells when the port gets disconnect

Looking for a signal in QSerialPort class that tells when the port gets disconnect

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.1k Views 1 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.
  • S Offline
    S Offline
    samsam
    wrote on last edited by
    #1

    Hi,
    I'm using QSerialPort class and would like to connect an event to a SIGNAL that tells me when the serial port is disconnected.
    Is there a signal for that?
    If there is no signal, how should I check this issue with out checking with timeout each x seconds if
    @port->isOpen() == true@

    ???

    thanks.

    1 Reply Last reply
    0
    • siropS Offline
      siropS Offline
      sirop
      wrote on last edited by
      #2

      Try void error(QSerialPort::SerialPortError error) .

      To be, or not to be: that is the question:
      Whether ’tis nobler in the mind to suffer
      The slings and arrows of outrageous fortune,
      Or to take arms against a sea of troubles,
      And by opposing end them?

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

        http://qt-project.org/doc/qt-4.8/qiodevice.html#aboutToClose

        1 Reply Last reply
        0
        • S Offline
          S Offline
          samsam
          wrote on last edited by
          #4

          Hi
          Meanwhile I didn't find a working solution for this problem, non of the above worked for me, non of the above signals were emitted when I disconnected the serial cable. :(

          does someone know about other solution for this problem?

          thanks a lot!

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

            bq. when I disconnected the serial cable

            What do you mean about "disconnected the serial cable"?

            If this means about RS232/TTL side, then it is impossible to know that cable is "disconnected", since RS232 interface does not provide this features.

            If this means about disconnecting of USB/Serial converter from USB port, then can be use QSerialPort::ResourceError (please read documentation). But this signal will be emmited only if the port was open (but even it doesn't guarantee it, depends on HW driver). Perhaps in the future we will refuse ResourceError signal.

            A common solution (for USB/Serial or PCI/Serial) devices - it is watching for system event about connecting/disconnecting of device (using udev and so on).

            You can look how this works from:

            https://code.google.com/p/qextserialport/source/browse/src/qextserialenumerator.h

            or

            https://gitorious.org/qserialdevice/qserialdevice/source/55692a7caf58fba51f859b8e015b2bbd7d92e1b6:src/qserialdeviceenumerator/serialdeviceenumerator.h

            1 Reply Last reply
            0

            • Login

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