Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Connecting arduino (Galileo) failed with QSerialPort
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Connecting arduino (Galileo) failed with QSerialPort

Scheduled Pinned Locked Moved General and Desktop
12 Posts 6 Posters 4.6k 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.
  • M Offline
    M Offline
    MrMNight
    wrote on last edited by
    #2

    I think you can try something like this:
    @
    QSerialPort * serial = new QSerialPort(“/dev/ttyACM0”);
    if(serial->open(QIODevice::ReadWrite))
    {
    //setup your serialport params - baudrate, databits, parity, flowcontrol, stopbits, dataerrorpolicy
    //do something there whatever you want - send "a" for example
    }
    else
    {
    out << serial->errorString() << endl;
    }
    @

    1 Reply Last reply
    0
    • E Offline
      E Offline
      edward_zhu
      wrote on last edited by
      #3

      [quote author="MrMNight" date="1394527326"]I think you can try something like this:
      [/quote]

      Thanks for your reply, but it seems that the error occurs when it goes to

      @serial->open()@

      and then, jumps to

      @serial->errorString()@

      and I also tried to set databits\parity\etc. but it still doesn't work.

      I wonder if it need some extra setting.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MrMNight
        wrote on last edited by
        #4

        try run this
        @
        for (QSerialPortInfo port : QSerialPortInfo::availablePorts())
        {
        qDebug() << port.portName();
        }
        @

        Does this list contains "ttyACM0"?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          edward_zhu
          wrote on last edited by
          #5

          [quote author="MrMNight" date="1394533009"]try run this
          @
          for (QSerialPortInfo port : QSerialPortInfo::availablePorts())
          {
          qDebug() << port.portName();
          }
          @

          Does this list contains "ttyACM0"?[/quote]

          Yes. It can be found by QSerialPortInfo::availablePorts() on both OS X(cu.modemxxxxx) and Xubuntu(ttyACM0).

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MrMNight
            wrote on last edited by
            #6

            Do you have enough permissions to read and write to your ttyACM0?
            I don't know how to perform this on Mac, but in Xubuntu you can add your user to dialout group, simply write in console (terminal)
            @
            sudo adduser your_user_name dialout
            @

            and try to run again your code.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              edward_zhu
              wrote on last edited by
              #7

              [quote author="MrMNight" date="1394535113"]Do you have enough permissions to read and write to your ttyACM0?
              I don't know how to perform this on Mac, but in Xubuntu you can add your user to dialout group, simply write in console (terminal)
              @
              sudo adduser your_user_name dialout
              @

              and try to run again your code.[/quote]

              Thanks for your help! I solved this by removing
              @QIODevice::Unbuffered@
              It seems that ardunio doesn't support such openmode.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kuzulis
                Qt Champions 2020
                wrote on last edited by
                #8
                1. QIODevice::Unbuffered does not supported by QtSerialPort
                2. After write() you should call waitForBytesWritten(), because otherwise nothing to be write.
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MrMNight
                  wrote on last edited by
                  #9

                  You are welcome, in "documentation":http://qt-project.org/doc/qt-5.1/qtserialport/qserialport.html#open there are warning "The mode has to be QIODevice::ReadOnly, QIODevice::WriteOnly, or QIODevice::ReadWrite. Other modes are unsupported."

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kripashree
                    wrote on last edited by
                    #10

                    Hi edward_zhu,

                    Can you share the code for connecting to USB(/dev/ttyACM0) in QT here?
                    I need to connect to the device from Linux QT.

                    Please consider this as High Priority.I will be waiting for the code.

                    Regards,
                    Kripa

                    jsulmJ aha_1980A 2 Replies Last reply
                    0
                    • K kripashree

                      Hi edward_zhu,

                      Can you share the code for connecting to USB(/dev/ttyACM0) in QT here?
                      I need to connect to the device from Linux QT.

                      Please consider this as High Priority.I will be waiting for the code.

                      Regards,
                      Kripa

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @kripashree said in [SOLVED] Connecting arduino (Galileo) failed with QSerialPort:

                      Please consider this as High Priority.I will be waiting for the code.

                      Please don't be so demanding!
                      This is user forum where people help for free.
                      Nobody here is obliged to consider anything high priority or deliver code!

                      And when asking you should provide more information.
                      What is the device you want to connect to?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • K kripashree

                        Hi edward_zhu,

                        Can you share the code for connecting to USB(/dev/ttyACM0) in QT here?
                        I need to connect to the device from Linux QT.

                        Please consider this as High Priority.I will be waiting for the code.

                        Regards,
                        Kripa

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

                        Hi @kripashree: edward_zhu was last only 5 years ago, I doubt he will see your request. And even if he did, he might not even have it anymore.

                        So please answer the questions @jsulm gave you, and we will see if we can help you.

                        Regards

                        Qt has to stay free or it will die.

                        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