QserialPortInfo::availablePorts() do not give information about „/dev/ttyGS0“



  • Dear Developers,

    On my embedded platform (Beaglebone black) USB port is emulated as Serial port „/dev/ttyGS0“.

    But when I try to scan available serial ports on my embedded platform using „QserialPortInfo::availablePorts()“.

    Then in output I do not get any information about emulated Serial Port „/dev/ttyGS0“. Whereas

    „QserialPortInfo::availablePorts()“ was successful in detecting other serial port „ttyS0“ (not emulated from USB) on my embedded platform.

    So please inform me why „QserialPortInfo::availablePorts()“ do not give any information about /dev/ttyGS0“ port ?

    Kindly inform me if you need any other information from me.

    Many thanks..


  • Lifetime Qt Champion

    Hi,

    That might be dependent on what version of Qt you are using. Which is it ? And what Linux distribution are you running ?



  • Hello @SGaist

    Thank you very much for fast reply.

    Version of Qt is : 5.7.1 and linux distribution I am using is given below.

    root@beaglebone:/home/root# uname -a
    Linux beaglebone 4.14.71-ti-r80 #1 SMP PREEMPT Fri Oct 5 23:50:11 UTC 2018 armvx
    root@beaglebone:/home/root# cat /etc/os-release
    PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
    NAME="Debian GNU/Linux"
    VERSION_ID="9"
    VERSION="9 (stretch)"
    ID=debian
    HOME_URL="https://www.debian.org/"
    SUPPORT_URL="https://www.debian.org/support"
    BUG_REPORT_URL="https://bugs.debian.org/"
    

    Please inform me if you need any other information from me.

    Thanks :)


  • Lifetime Qt Champion

    It's a bit an old version but IIRC, it should be good to access the device...

    Can you check if it is a symlink ?


  • Qt Champions 2018

    @kuzulis can you help here?



  • @saurabh162 said in QserialPortInfo::availablePorts() do not give information about „/dev/ttyGS0“:

    /dev/ttyGS0

    Try latest version of Qt as 5.7.1 is too old (at least try v 5.9). And then we be investigate an issue.

    UPD:

    1. do you have the /dev/ttyGS0 in a filesystem in reality?
    2. try this comamnd: udevadm info --name=/dev/ttyGS0 and paste an output here.
    3. try compile and run the following code (what is it return? true/false?):
    #include <linux/serial.h> 
    
    bool foo()
    {
        const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
        const int fd = ::open("/dev/ttyGS0", flags);
        if (fd != -1) {
            struct serial_struct serinfo;
            const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
            ::close(fd);
            if (retval != -1 && serinfo.type != PORT_UNKNOWN)
                return true;
        }
        return false;
    }
    


  • Hello @SGaist , @aha_1980, @kuzulis

    Thank you very much for your help

    I will surely install Qt5.9 on my Beaglebone black and compile cross tool chain on host machine corresponding to it but at this moment I cannot do it due to other priorities.

    Following are the answers to questions asked by @kuzulis

    1. do you have the /dev/ttyGS0 in a filesystem in reality?

    Ans) Yes, I have it and I am manually opening this port using following code in Beagebone black and doing communication which is also working perfectly.

    isBBBSerialOpened = co2SerialPortobject.OpenConfigureCO2HW("/dev/ttyGS0" ,
                                             co2SerialPortobject.ReadWrite,
                                             co2SerialPortobject.Baud9600,
                                             co2SerialPortobject.Data8,
                                             co2SerialPortobject.NoParity,
                                             co2SerialPortobject.OneStop,
                                             co2SerialPortobject.NoFlowControl);
    
    1. try this comamnd: udevadm info --name=/dev/ttyGS0 and paste an output here ?

    Ans)

    
    udevadm info --name=/dev/ttyGS0
    P: /devices/virtual/tty/ttyGS0
    N: ttyGS0
    E: DEVNAME=/dev/ttyGS0
    E: DEVPATH=/devices/virtual/tty/ttyGS0
    E: MAJOR=243
    E: MINOR=0
    E: SUBSYSTEM=tty
    E: TAGS=:systemd:
    E: USEC_INITIALIZED=32563390
    E: net.ifnames=0
    

    Q) try compile and run the following code (what is it return? true/false?): ?

    #include <linux/serial.h> 
    
    bool foo()
    {
        const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
        const int fd = ::open("/dev/ttyGS0", flags);
        if (fd != -1) {
            struct serial_struct serinfo;
            const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
            ::close(fd);
            if (retval != -1 && serinfo.type != PORT_UNKNOWN)
                return true;
        }
        return false;
    }
    

    Ans) After compiling above code I got following errors

    test.c:3:1: error: unknown type name ��‘bool��’
     bool foo()
     ^~~~
    test.c: In function ��‘foo��’:
    test.c:5:11: error: unknown type name ��‘mode_t��’
         const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
               ^~~~~~
    test.c:5:26: error: ��‘O_RDWR��’ undeclared (first use in this function)
         const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
                              ^~~~~~
    test.c:5:26: note: each undeclared identifier is reported only once for each function it appears in
    test.c:5:35: error: ��‘O_NONBLOCK��’ undeclared (first use in this function)
         const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
                                       ^~~~~~~~~~
    test.c:5:48: error: ��‘O_NOCTTY��’ undeclared (first use in this function)
         const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
                                                    ^~~~~~~~
    test.c:6:20: error: expected expression before ��‘:��’ token
         const int fd = ::open("/dev/ttyGS0", flags);
                        ^
    test.c:9:28: error: expected expression before ��‘:��’ token
             const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
                                ^
    test.c:10:9: error: expected expression before ��‘:��’ token
             ::close(fd);
             ^
    test.c:12:20: error: ��‘true��’ undeclared (first use in this function)
                 return true;
                        ^~~~
    test.c:14:12: error: ��‘false��’ undeclared (first use in this function)
         return false;
    

    Please inform me if you need any other information from me.

    many thanks :)



  • @SGaist said in QserialPortInfo::availablePorts() do not give information about „/dev/ttyGS0“:

    IIRC

    Hello @SGaist, Thank you very much. I checked but "ttyGS0" is not symlink following the command I used to check it.

    root@beaglebone:/dev# ls -l ttyGS0
    crw--w---- 1 root tty 243, 0 Apr 17 10:08 ttyGS0
    
    

  • Qt Champions 2018

    @saurabh162

    For your code: replace bool with int and true with 1 resp. false with 0. Or simply use a C++ instead a C file.

    For the other errors you will need some more includes, Google should help you there.



  • Hello @aha_1980

    Thank you very much for the help ..I will try to compile it again and will update you



  • Hello @aha_1980,

    I have run above function foo() and got

    retval = -1 from following statement

    const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
    

    Additionally when I print value of variable errno after calling above statement, then it comes out to be 25.

    Moreover value of serinfo.type variable is 2(#define PORT_16450 2)

    can you please inform me what can be reasons for it and how can I solve it ?

    I am also trying to solve this problem at my side and will update you if I get any progress.

    Many thanks :)



  • @saurabh162 ,

    Hmm.. Seems, need to debug the QSerialPortInfo class to see what happens there.





  • Hello @kuzulis

    Thank you very much..Can you please inform me how can I apply this fix to my Qt.

    Regards

    Saurabh



  • @saurabh162 said in QserialPortInfo::availablePorts() do not give information about „/dev/ttyGS0“:

    Can you please inform me how can I apply this fix to my Qt.

    Just modify that file in a qtserialport sources and rebuild it. Or, just wait for a next Qt release (seems to 5.12.4).



  • Hello Kuzulis,

    Thanks a lot for your update ...

    I think using latest fixed version of Qt release (seems to 5.12.4) will be better choice. Please inform me, what should I do with this query should I close it or leave it open till I test it with Qt release (seems to 5.12.4).

    Regards Saurabh


Log in to reply
 

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