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. Qt Serial- Open function returns false
Forum Updated to NodeBB v4.3 + New Features

Qt Serial- Open function returns false

Scheduled Pinned Locked Moved Solved Mobile and Embedded
10 Posts 2 Posters 874 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.
  • S Offline
    S Offline
    skankhunt42
    wrote on last edited by
    #1

    Hey guys. I am new in Qt and trying to communicate with my STM board via Serial Port. But I can't open the serial port with serialPort->open(QIODevice::ReadWrite). I couldn't find where I am doing wrong. I need help.
    e1d366aa-4e20-4821-ba38-8920d04a25fd-image.png

    1 Reply Last reply
    0
    • S Offline
      S Offline
      skankhunt42
      wrote on last edited by
      #9

      What a stupid I am. The name of port I am trying to use is COM6 but i gave name randomly STMcomm in code. The name should be same. Thank you for your support sir.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        You might want to print the error returned by the error property.

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

        1 Reply Last reply
        1
        • S Offline
          S Offline
          skankhunt42
          wrote on last edited by
          #3

          Thanks for answer but how should I call that specific error function?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Did you try to just send its value to qDebug() << ?

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              skankhunt42
              wrote on last edited by
              #5

              It says no error but then why the if statement happens to be 1?
              937dc703-c5ce-48db-b51d-5c1e0d1cad01-image.png

              1 Reply Last reply
              0
              • S Offline
                S Offline
                skankhunt42
                wrote on last edited by
                #6

                problem evolved to that now. The error string is ="System couldn't find the referred file"
                0e51eb0c-a1ff-43c6-86ab-a050dfe97ec8-image.png

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  Good, one more thing: there's no reason for your serialPort variable to be statically declared. You should fix that.

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

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    skankhunt42
                    wrote on last edited by
                    #8

                    I know I am asking too much but I don't know what is statically declared means. I looked a bit and as I understand that means initializing without new.

                    I moved *QSerialPort serialPort; part to header file if you meant that. But it didn't help. I can't understand why it should be so hard to just use simple serial port.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      skankhunt42
                      wrote on last edited by
                      #9

                      What a stupid I am. The name of port I am trying to use is COM6 but i gave name randomly STMcomm in code. The name should be same. Thank you for your support sir.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        Your use of static falls in the last paragraphe of this article.

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

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved