Results 1 to 5 of 5

Thread: QSerialPort::ResourceError called endlessly when USB detached

  1. #1
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QSerialPort::ResourceError called endlessly when USB detached

    Hi,
    My app' is talking with a GSM modem, over USB.
    • /dev/ttyACM0 is used for pppd (external process, not within my Qt app').

    • /dev/ttyACM5 is used for 'control' AT commands (RSSI, provider local time, voice calls, etc.)


    Everything is working fine till the modem's USB cable is plugged out (actually, every few hours the modem crashes, or something else, which ends up in the USB interface is destroyed, what seems to my Linux as a detach-event).

    On detach:
    • pppd dies and frees /dev/ttyACM0.

    • My QSerialPort receives a ResourceError signal, I call MyQSerialPort.close() and receive another ResourceError signal, in an endless loop. The app' finally crashes (but the Linux doesn't), but the modem has already reconnected and uDev creates ttyACM0, 1, 2, 3, 4, 6, 7 - missing ttyACM5 (because it was held by the app').


    What am I doing wrong?
    Should I disconnect all signals from MyQSerialPort before calling close(), and reconnect after?
    I'm afraid of a memory/resource leak.

    Qt 5.5.1, Linux.

    Thanks
    Last edited by RamiRosenbaum; 31st March 2016 at 11:14.

  2. #2
    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: QSerialPort::ResourceError called endlessly when USB detached

    it is already be fixed in 5.6.0

  3. #3
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSerialPort::ResourceError called endlessly when USB detached

    I prefer not to upgrade my Qt version.
    There's also the licencing issue that has changed in that version...

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSerialPort::ResourceError called endlessly when USB detached

    Delete the object and recreate it for further use?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSerialPort::ResourceError called endlessly when USB detached

    For those coming here from Ubuntu or derivatives, I've uploaded a patched version of qt5 serialport package to my ppa: https://launchpad.net/~hyozd/+archiv...tu/serialplot/ . I basically back-ported fixes from Qt 5.6. Here is the diff:

    Qt Code:
    1. --- a/src/serialport/qserialport_unix.cpp
    2. +++ b/src/serialport/qserialport_unix.cpp
    3. @@ -208,14 +208,11 @@
    4.  
    5. void QSerialPortPrivate::close()
    6. {
    7. - if (settingsRestoredOnClose) {
    8. - if (::tcsetattr(descriptor, TCSANOW, &restoredTermios) == -1)
    9. - setError(getSystemError());
    10. - }
    11. + if (settingsRestoredOnClose)
    12. + ::tcsetattr(descriptor, TCSANOW, &restoredTermios);
    13.  
    14. #ifdef TIOCNXCL
    15. - if (::ioctl(descriptor, TIOCNXCL) == -1)
    16. - setError(getSystemError());
    17. + ::ioctl(descriptor, TIOCNXCL);
    18. #endif
    19.  
    20. if (readNotifier) {
    21. @@ -228,8 +225,7 @@
    22. writeNotifier = Q_NULLPTR;
    23. }
    24.  
    25. - if (qt_safe_close(descriptor) == -1)
    26. - setError(getSystemError());
    27. + qt_safe_close(descriptor);
    28.  
    29. lockFileScopedPointer.reset(Q_NULLPTR);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 7
    Last Post: 12th October 2016, 09:48
  2. Performance issues with detached QProcess
    By simon71717 in forum Qt Programming
    Replies: 1
    Last Post: 15th January 2014, 11:07
  3. Ignoring stdout and stder of detached process
    By Lapsio in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2012, 06:38
  4. Positioning Detached Process Window
    By GTBuilder in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2008, 01:17
  5. Information From Detached Process
    By GTBuilder in forum Qt Programming
    Replies: 6
    Last Post: 18th February 2008, 15:49

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.