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



  • Hi
    I can not enumerate serial ports in my application.
    I try terminal example which comes with sdk, but that did not work also.
    @QSerialPortInfo::availablePorts()@
    The above code does not work.
    Also I rebuild serial port package with libudev in my system but it didnt work. You think whats the problem?

    Thanks
    I use :
    Qt 5.2
    Fedora 17



  • Are you sure that your host has an serial ports?

    Please provide an print out from command:
    [quote]udevadm info --name=/dev/ttyS0 -a[/quote]

    where /dev/ttyS0 - name of your device (you must paste your device name instead of /dev/ttyS0).

    UPD: Or just an:
    [quote]udevadm info -a[/quote]



  • Thanks for reply
    I ran first command with some under /dev and get "device node not found"
    For second command, there is an error for not providing path or name.
    I'm confusing so tiny. Isn`t QSerialPortInfo enumerate all devices under /dev?



  • This is output for my usb :
    @$udevadm info --name=/dev/ttyS0 -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/platform/serial8250/tty/ttyS0':
    KERNEL=="ttyS0"
    SUBSYSTEM=="tty"
    DRIVER==""

    looking at parent device '/devices/platform/serial8250':
    KERNELS=="serial8250"
    SUBSYSTEMS=="platform"
    DRIVERS=="serial8250"

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



  • You are sure that your /dev/ttyS0 is a physically present on PC?

    A "platform" serial ports are ignored by library, because in most cases (usual) this devices physically is not present in the PC's. Usual they present and used only on the Embedded boards (ARM and so on).

    Problem is in impossible to define (at least we don't know as) a validity of this "platform" serial ports on any boards (platforms). Therefore enumeration of these ports is disabled intentionally.

    You can read more about this issue here: https://bugreports.qt-project.org/browse/QTBUG-32024

    To enable enumeration of such devices you must modify file "qserialportinfo_unix.cpp": comments out all continue operators where meet comparison with the QStringLiteral("platform").



  • Thanks
    No, Im not sure. But at least, QSerialPortInfo shouldnt find my usb ports?
    And I need platform`s. Because maybe I need create virtual port.



  • bq. QSerialPortInfo shouldn`t find my usb ports?

    It should work fine.

    bq. And I need platform`s. Because maybe I need create virtual port.

    Here need to do modifications in source code.



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



  • Then please do

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

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



  • 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



  • 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.



  • 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==""
    @



  • 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.


  • Moderators

    [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.



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



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


  • Moderators

    [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:

    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."



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.