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. QSerialPortInfo::availablePorts() freeze for ~30s

QSerialPortInfo::availablePorts() freeze for ~30s

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 2.6k 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.
  • H Offline
    H Offline
    Hallot
    wrote on last edited by Hallot
    #1

    Dear Qt users,

    I recently changed the computer I am working on, and on the new system, every call to QSerialPortInfo::availablePorts() freeze the thread for about 30s, while it used to be instantaneous.
    Using the debugger, it seems to freeze in __lll_lock_wait_private or open64.
    If I run the application using sudo the same happens.
    It used to be working with pretty much the same versions of the kernel/Qt, so it's more of a system issue?

    Any idea of what could be the problem would be much appreciated.

    Some system information:
    CPU:
    vendor_id : GenuineIntel
    cpu family : 6
    model : 158
    model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    stepping : 9
    microcode : 0x80

    Kernel:
    4.14.14-1-MANJARO x86_64

    Selected software versions:
    glibc: 2.26
    gcc: 7.2.1 20171224
    Qt 5.10

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Charlie_Hdz
      wrote on last edited by
      #2

      Welcome @Hallot

      That's interesting, even though you might not have permission to access the ports, It should return really fast... Are you catching the QSerialPortInfo? What are you receiving in that QSerialPortInfo?

      Can you just that part of your code just to reference?

      Kind Regards,
      Enrique Hernandez
      gearstech.com.mx
      chernandez@gearstech.com.mx

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hallot
        wrote on last edited by Hallot
        #3

        Hello Charlie, thanks for your quick answer.

        Yes, when I do not have permission, it is really fast, and it fails as expected.
        It's when I have the permission that I encounter the issue.
        What's interesting though is that after all the wait, I have the correct devices returned.

        It's really that QSerialPortInfo::availablePorts() line that is the issue.
        It also happens when I compile and run the "Enumerator example".

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Have you tested with non Qt serial app, how it reacts to scanning for ports?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Charlie_Hdz
            wrote on last edited by
            #5

            It sounds that you have some issues with your new computer's port configuration. Which platform are you using?

            Anyway about the device that you want to connect by Serial... what is it?

            Kind Regards,
            Enrique Hernandez
            gearstech.com.mx
            chernandez@gearstech.com.mx

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hallot
              wrote on last edited by Hallot
              #6

              @mrjj I have tried python -m serial.tools.list_ports but the output is wrong though immediate.
              Do you have an application in mind I could try?

              @Charlie_Hdz It's a Manjaro linux on x86_64. I would tend to agree with you, but I have no idea where to start looking.
              It's a ftdi.

              mrjjM 1 Reply Last reply
              0
              • H Hallot

                @mrjj I have tried python -m serial.tools.list_ports but the output is wrong though immediate.
                Do you have an application in mind I could try?

                @Charlie_Hdz It's a Manjaro linux on x86_64. I would tend to agree with you, but I have no idea where to start looking.
                It's a ftdi.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Hallot
                well i always use minicom as its so simple
                moserial is also cool. (X11)
                I dont know Manjaro so maybe there is another installed already

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hallot
                  wrote on last edited by
                  #8

                  Hum, I'm not exactly sure how I can list all serial devices using minicom, but I have used libftdi and one of their example, and it lists my ftdi devices immediately.

                  mrjjM 1 Reply Last reply
                  0
                  • H Hallot

                    Hum, I'm not exactly sure how I can list all serial devices using minicom, but I have used libftdi and one of their example, and it lists my ftdi devices immediately.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Hallot
                    Oh, my bad, you actually type it so bad app for test.
                    Sorry.
                    so libftdi can enum all ports and not hang?
                    I wonder if it touches non ftdi ones. ( those not usb based)
                    if time permits you can try
                    https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them
                    (Søren Holm post)

                    Anyway, its most likely something under /dev that makes it hang.

                    I tried QSerialPortInfo on wm linux but i cant make it hang even when i remove
                    the serial ports so they are missing.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Charlie_Hdz
                      wrote on last edited by
                      #10

                      @mrjj said in QSerialPortInfo::availablePorts() freeze for ~30s:

                      I tried QSerialPortInfo on wm linux but i cant make it hang even when i remove
                      the serial ports so they are missing.

                      Sure, actually SerialPort tend to send "unknow" error messages instead of hanging functions.

                      Kind Regards,
                      Enrique Hernandez
                      gearstech.com.mx
                      chernandez@gearstech.com.mx

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

                        QSerialPortInfo does not use the open() system call if you do not call a deprecated isBusy() method (do not use it then). QSerialPortInfo use udev, sysfs and simple enumeration in /dev, in case previous methods were failed. You need to debug the QSerialPortInfo, or, at least try to strace a calls, where the stuck is happens.

                        PS: It is interest to know in what of 'backend' this happens: with udev, sysfs or simple enumeration by a masks from /dev directory to localise an issue.

                        PS2: From my expirience, the FTDI should work perfectly.

                        1 Reply Last reply
                        1
                        • H Offline
                          H Offline
                          Hallot
                          wrote on last edited by
                          #12

                          I'm pretty sure I use udev.
                          However, it looks there was a bug somewhere that got fixed because after the latest system update from Manjaro, the issue has disappeared.
                          No kernel or udev update though, so I am not sure what was at cause or what fixed it.

                          Anyway, I guess this can be considered solved, thanks a lot for the support.

                          1 Reply Last reply
                          2

                          • Login

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