Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QserialPortInfo::availablePorts() do not give information about „/dev/ttyGS0“
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
16 Posts 4 Posters 1.9k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    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 ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @kuzulis can you help here?

      Qt has to stay free or it will die.

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

        @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;
        }
        
        1 Reply Last reply
        2
        • S Offline
          S Offline
          saurabh162
          wrote on last edited by saurabh162
          #7

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

          aha_1980A 1 Reply Last reply
          0
          • SGaistS SGaist

            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 ?

            S Offline
            S Offline
            saurabh162
            wrote on last edited by
            #8

            @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
            
            
            1 Reply Last reply
            0
            • S saurabh162

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

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

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

              Qt has to stay free or it will die.

              1 Reply Last reply
              1
              • S Offline
                S Offline
                saurabh162
                wrote on last edited by
                #10

                Hello @aha_1980

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

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  saurabh162
                  wrote on last edited by saurabh162
                  #11

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

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

                    @saurabh162 ,

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

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

                      Please see a fix: https://codereview.qt-project.org/#/c/260832/

                      1 Reply Last reply
                      2
                      • S Offline
                        S Offline
                        saurabh162
                        wrote on last edited by saurabh162
                        #14

                        Hello @kuzulis

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

                        Regards

                        Saurabh

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

                          @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).

                          1 Reply Last reply
                          2
                          • S Offline
                            S Offline
                            saurabh162
                            wrote on last edited by
                            #16

                            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

                            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