Results 1 to 2 of 2

Thread: QSerialPort very slow to close

  1. #1
    Join Date
    Jan 2016
    Posts
    17
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QSerialPort very slow to close

    I have a QSerialPort m_serialPort communicating correctly with a Bluetooth connection. I can close the port from the code using m_serialPort->close() and it works normally.

    If I power off the device I can detect that it has gone because I 'ping' my device every second. When I get no answer to my 'ping' I try to close the port but m_serialPort->close() takes 20s to return.

    Why does it take 20s?

    If this is unavoidable is there another way I can 'kill' the QSerialPort?

    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSerialPort very slow to close

    Operating systems generally have a defined time-out period for ports, network sockets, and the like where they wait until this time has elapsed before releasing the system resources. This is probably to improve reliability - these are drivers for physical devices after all, and if there is a momentary break in communications, the software shouldn't instantly shut down the channel but wait a reasonable amount of time before concluding that the connection is truly broken. These protocols were developed back in the days when 110 and 300 baud modems were the norm, so what was a "reasonable time" then isn't so reasonable now.

    Most operating systems give you a way to set these timeouts, see the Windows documentation, for example. You may have to dip into OS-specific coding in order to get access to that, though.

  3. The following user says thank you to d_stranz for this useful post:

    BrianNorman (2nd May 2016)

Similar Threads

  1. QSerialPort Bluetooth SPP Slow Response
    By BrianNorman in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2016, 09:55
  2. midi child does not close when I call close()
    By qlands in forum Qt Programming
    Replies: 7
    Last Post: 29th July 2011, 22:25
  3. QT application not close after close the mainwindow
    By artome in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2011, 22:23
  4. Replies: 2
    Last Post: 17th December 2010, 19:01
  5. Why is QBuffer's close call so slow?
    By eekisa in forum Qt Programming
    Replies: 4
    Last Post: 8th April 2009, 12:07

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.