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. [Solved]QSerialPortInfo::availablePorts() does not work. Can not enumerate serial ports

[Solved]QSerialPortInfo::availablePorts() does not work. Can not enumerate serial ports

Scheduled Pinned Locked Moved General and Desktop
22 Posts 5 Posters 12.2k 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.
  • J Offline
    J Offline
    jmimi
    wrote on last edited by
    #8

    Thanks kuzulis
    But now, QSerialPortInfo does not find my usb ports.
    I will change the source code and rebuild again to have platform`s.

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

      Then please do

      bq. $udevadm info --name=/dev/ttyXYZ -a

      where ttyXYZ - name of your USB device and give print out.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jmimi
        wrote on last edited by
        #10

        I print it in this thread already at above.
        I mean from USB device like mouse.
        I say QPortSerailInfo should not list these usb ports? e.g mouse
        Thanks

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

          Sorry?

          [quote]I print it in this thread already at above.[/quote]
          That you printed is not belongs to the USB devices.

          [quote]
          I mean from USB device like mouse.
          I say QPortSerailInfo should not list these usb ports? e.g mouse
          [/quote]
          Mouse is not an serial port's device (not an tty device). The QSeralPortInfo works only with the serial port's devices. But in case your mouse will be present in system as serial device (with the appropriate driver) - then QSeralPortInfo will work with this.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jmimi
            wrote on last edited by
            #12

            Thank you for helping me.
            You say USB mouse is not a serial port?
            I run a virtual serial port using socat and again QSerialPortInfo did not find.
            Maybe I have problem in understanding usb concept and serial port.
            I think any usb device assigned to a serial port e.g usb webcam.
            I attach a usb webcam to my computer and QSerialPortInfo did not find it also.
            I ran a command for my mouse :
            @ udevadm info --name=/dev/input/mouse0 -a

            Udevadm info starts with the device specified by the devpath and then
            walks up the chain of parent devices. It prints for every device
            found, all possible attributes in the udev rules key format.
            A rule to match, can be composed by the attributes of the device
            and the attributes from one single parent device.

            looking at device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input5/mouse0':
            KERNEL=="mouse0"
            SUBSYSTEM=="input"
            DRIVER==""

            looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input5':
            KERNELS=="input5"
            SUBSYSTEMS=="input"
            DRIVERS==""
            ATTRS{name}=="A4Tech PS/2+USB Mouse"
            ATTRS{phys}=="usb-0000:00:1a.0-1.1/input0"
            ATTRS{uniq}==""
            ATTRS{properties}=="0"

            looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0':
            KERNELS=="1-1.1:1.0"
            SUBSYSTEMS=="usb"
            DRIVERS=="usbhid"
            ATTRS{bInterfaceNumber}=="00"
            ATTRS{bAlternateSetting}==" 0"
            ATTRS{bNumEndpoints}=="01"
            ATTRS{bInterfaceClass}=="03"
            ATTRS{bInterfaceSubClass}=="01"
            ATTRS{bInterfaceProtocol}=="02"
            ATTRS{supports_autosuspend}=="1"

            looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1':
            KERNELS=="1-1.1"
            SUBSYSTEMS=="usb"
            DRIVERS=="usb"
            ATTRS{configuration}=="HID-Compliant Mouse"
            ATTRS{bNumInterfaces}==" 1"
            ATTRS{bConfigurationValue}=="1"
            ATTRS{bmAttributes}=="a0"
            ATTRS{bMaxPower}=="100mA"
            ATTRS{urbnum}=="174621"
            ATTRS{idVendor}=="09da"
            ATTRS{idProduct}=="000a"
            ATTRS{bcdDevice}=="0002"
            ATTRS{bDeviceClass}=="00"
            ATTRS{bDeviceSubClass}=="00"
            ATTRS{bDeviceProtocol}=="00"
            ATTRS{bNumConfigurations}=="1"
            ATTRS{bMaxPacketSize0}=="8"
            ATTRS{speed}=="1.5"
            ATTRS{busnum}=="1"
            ATTRS{devnum}=="3"
            ATTRS{devpath}=="1.1"
            ATTRS{version}==" 1.10"
            ATTRS{maxchild}=="0"
            ATTRS{quirks}=="0x0"
            ATTRS{avoid_reset_quirk}=="0"
            ATTRS{authorized}=="1"
            ATTRS{manufacturer}=="A4Tech"
            ATTRS{product}=="PS/2+USB Mouse"

            looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1':
            KERNELS=="1-1"
            SUBSYSTEMS=="usb"
            DRIVERS=="usb"
            ATTRS{configuration}==""
            ATTRS{bNumInterfaces}==" 1"
            ATTRS{bConfigurationValue}=="1"
            ATTRS{bmAttributes}=="e0"
            ATTRS{bMaxPower}==" 0mA"
            ATTRS{urbnum}=="77"
            ATTRS{idVendor}=="8087"
            ATTRS{idProduct}=="0020"
            ATTRS{bcdDevice}=="0000"
            ATTRS{bDeviceClass}=="09"
            ATTRS{bDeviceSubClass}=="00"
            ATTRS{bDeviceProtocol}=="01"
            ATTRS{bNumConfigurations}=="1"
            ATTRS{bMaxPacketSize0}=="64"
            ATTRS{speed}=="480"
            ATTRS{busnum}=="1"
            ATTRS{devnum}=="2"
            ATTRS{devpath}=="1"
            ATTRS{version}==" 2.00"
            ATTRS{maxchild}=="6"
            ATTRS{quirks}=="0x0"
            ATTRS{avoid_reset_quirk}=="0"
            ATTRS{authorized}=="1"

            looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1':
            KERNELS=="usb1"
            SUBSYSTEMS=="usb"
            DRIVERS=="usb"
            ATTRS{configuration}==""
            ATTRS{bNumInterfaces}==" 1"
            ATTRS{bConfigurationValue}=="1"
            ATTRS{bmAttributes}=="e0"
            ATTRS{bMaxPower}==" 0mA"
            ATTRS{urbnum}=="25"
            ATTRS{idVendor}=="1d6b"
            ATTRS{idProduct}=="0002"
            ATTRS{bcdDevice}=="0303"
            ATTRS{bDeviceClass}=="09"
            ATTRS{bDeviceSubClass}=="00"
            ATTRS{bDeviceProtocol}=="00"
            ATTRS{bNumConfigurations}=="1"
            ATTRS{bMaxPacketSize0}=="64"
            ATTRS{speed}=="480"
            ATTRS{busnum}=="1"
            ATTRS{devnum}=="1"
            ATTRS{devpath}=="0"
            ATTRS{version}==" 2.00"
            ATTRS{maxchild}=="2"
            ATTRS{quirks}=="0x0"
            ATTRS{avoid_reset_quirk}=="0"
            ATTRS{authorized}=="1"
            ATTRS{manufacturer}=="Linux 3.3.4-5.fc17.x86_64 ehci_hcd"
            ATTRS{product}=="EHCI Host Controller"
            ATTRS{serial}=="0000:00:1a.0"
            ATTRS{authorized_default}=="1"

            looking at parent device '/devices/pci0000:00/0000:00:1a.0':
            KERNELS=="0000:00:1a.0"
            SUBSYSTEMS=="pci"
            DRIVERS=="ehci_hcd"
            ATTRS{vendor}=="0x8086"
            ATTRS{device}=="0x3b3c"
            ATTRS{subsystem_vendor}=="0x1028"
            ATTRS{subsystem_device}=="0x0447"
            ATTRS{class}=="0x0c0320"
            ATTRS{irq}=="16"
            ATTRS{local_cpus}=="00000000,0000000f"
            ATTRS{local_cpulist}=="0-3"
            ATTRS{numa_node}=="-1"
            ATTRS{dma_mask_bits}=="32"
            ATTRS{consistent_dma_mask_bits}=="32"
            ATTRS{broken_parity_status}=="0"
            ATTRS{msi_bus}==""
            ATTRS{companion}==""
            ATTRS{uframe_periodic_max}=="100"

            looking at parent device '/devices/pci0000:00':
            KERNELS=="pci0000:00"
            SUBSYSTEMS==""
            DRIVERS==""
            @

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

              bq. You say USB mouse is not a serial port?

              Yes. The USB mouse it is an "input" class device, not an "tty" class device (i.e. not an serial port).

              bq. I run a virtual serial port using socat and again QSerialPortInfo did not find.

              You should do modifications in source code (as I say before) and then your /dev/ttyS0 device will listed.

              bq. Maybe I have problem in understanding usb concept and serial port.

              Yes, it is. :)

              [quote]
              I think any usb device assigned to a serial port e.g usb webcam.
              I attach a usb webcam to my computer and QSerialPortInfo did not find it also.
              [/quote]

              Sorry, you are wrong. :)

              In any case, your PC's has not any serial ports. You has only a few "faked" /dev/ttyS0-S3 (maybe up to ttyS14) serial ports. It is normal... You can read more about serial ports e.g. "here":http://www.tldp.org/HOWTO/Serial-HOWTO-10.html.

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #14

                [quote author="jmimi" date="1388572677"]You say USB mouse is not a serial port?[/quote]Hi,

                USB = "Universal Serial Bus", not "Serial Port". This is what most serial ports look like: http://en.wikipedia.org/wiki/File:Serial_port.jpg

                The Serial Port is a very old technology. They can still be found in embedded systems and industrial systems, but modern PCs don't supply them any more.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jmimi
                  wrote on last edited by
                  #15

                  Thank you kuzulis.
                  You're patient and meek.
                  I shall read more and more.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jmimi
                    wrote on last edited by
                    #16

                    JKSH : Hi .
                    But usb is serial not parallel.
                    I know RS232 is a serial port and I think usb is serial too.

                    1 Reply Last reply
                    0
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by
                      #17

                      [quote author="jmimi" date="1388575219"]I know RS232 is a serial port and I think usb is serial too.[/quote]Yes, USB and RS-232 communications are both serial, but their protocols are VERY different:

                      • Serial port: http://en.wikipedia.org/wiki/RS-232#Signals
                      • USB: http://en.wikipedia.org/wiki/USB#Communication

                      Nowadays, when people say "serial port", they mean "RS-232". Even though data is transmitted through USB cables serially, USB does not use the RS-232 standard. Therefore, USB ports are not considered serial ports.

                      From the "Qt documentation":http://qt-project.org/doc/qt-5/topics-network-connectivity.html#serial-port-communication:

                      "The Qt Serial Port module provides a C++ API for communicating through serial ports, using the RS-232 standard. It works with physical ports and also with drivers that emulate these ports. Examples of serial port emulators include virtual COM ports, com0com emulators, and the Bluetooth SPP."

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jmimi
                        wrote on last edited by
                        #18

                        Thanks you JKSH
                        I should read more.
                        I create a virtual com port using socat according below
                        @$ socat -d -d pty,raw,echo=0, pty,raw,echo=0

                        2014/01/01 16:03:58 socat[10509] N PTY is /dev/pts/4
                        2014/01/01 16:03:58 socat[10509] N PTY is /dev/pts/5
                        2014/01/01 16:03:58 socat[10509] N starting data transfer loop with FDs [3,3] and [5,5]

                        @
                        But QSerialPortInfo did not find for me. According to documentation you linked, it should be happened but it didn`t.
                        So I willchange the source code according to kuzulis said and test again.
                        I do not have the device right now. I want to develop software without it and will test with the device actually. communication with device is part of my software. So I need to create a virtual com port and test with it.

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          huseyinkozan
                          wrote on last edited by
                          #19

                          socat creates symlink, but QSerialPortInfo does not care about symlinks:
                          https://code.woboq.org/qt5/qtserialport/src/serialport/qserialportinfo_unix.cpp.html#91

                          aha_1980A 1 Reply Last reply
                          0
                          • H huseyinkozan

                            socat creates symlink, but QSerialPortInfo does not care about symlinks:
                            https://code.woboq.org/qt5/qtserialport/src/serialport/qserialportinfo_unix.cpp.html#91

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

                            @huseyinkozan Please create a report at bugreports.qt.io for this. This forum is not the right place to discuss if the behavior is correct or not.

                            And @kuzulis, you might be interested in this.

                            Qt has to stay free or it will die.

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

                              Yes, QSPI ignores the socat's symlinks, because it is not a serial ports at all. It is not a bug. If you want to use a virtual serial ports on linux, please use the tty0tty kernel module.

                              H 1 Reply Last reply
                              1
                              • K kuzulis

                                Yes, QSPI ignores the socat's symlinks, because it is not a serial ports at all. It is not a bug. If you want to use a virtual serial ports on linux, please use the tty0tty kernel module.

                                H Offline
                                H Offline
                                huseyinkozan
                                wrote on last edited by
                                #22

                                @kuzulis Thanks. Tried tty0tty, but it have a bug. So, switched to crossed USB converters.

                                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