[Solved]QSerialPortInfo::availablePorts() does not work. Can not enumerate serial ports
-
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.
-
[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.
-
[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."
-
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=02014/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. -
socat creates symlink, but QSerialPortInfo does not care about symlinks:
https://code.woboq.org/qt5/qtserialport/src/serialport/qserialportinfo_unix.cpp.html#91 -
socat creates symlink, but QSerialPortInfo does not care about symlinks:
https://code.woboq.org/qt5/qtserialport/src/serialport/qserialportinfo_unix.cpp.html#91@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.
-
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.