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

QSerialPort

Scheduled Pinned Locked Moved General and Desktop
24 Posts 2 Posters 10.9k 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
    mastinosoft
    wrote on last edited by
    #1

    Hi.
    I use the latest Qt 5.2 on Linux Mint. With Qt installation I get examples program. I found that very useful. But... I tried examples for Serial Port and all of them give after a few seconds the same error message "Resource temporarily unavailable". As I found in documentation it have to be because of readBufferSize.
    I add:
    @ struct Settings {
    QString name;
    qint32 baudRate;
    QString stringBaudRate;
    QSerialPort::DataBits dataBits;
    QString stringDataBits;
    QSerialPort::Parity parity;
    QString stringParity;
    QSerialPort::StopBits stopBits;
    QString stringStopBits;
    QSerialPort::FlowControl flowControl;
    qint64 readBufferSize(qint64 size); //here
    qint64 readBufferMaxSize(qint64 size);//here
    QString stringFlowControl;
    bool localEchoEnabled;
    };@
    and
    @private:
    void setReadBufferSize(qint64 size);@

    and
    @void MainWindow::openSerialPort()
    {
    SettingsDialog::Settings p = settings->settings();
    serial->setPortName(p.name);
    serial->setReadBufferSize(4800);@

    that calls function

    @void MainWindow::SetreadBufferSize(qint64 size)
    {
    serial->setReadBufferSize(size);

    }@

    but no matter which value I put on serial->setReadBufferSize I get the same error message

    I found another examples in Internet but I really want to use those that came with Qt installation,
    What I missing?

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

      @“Resource temporarily unavailable”@

      1. This is an system error. So, seems that problem in your device. Besides please provide an simple code && use-case to reproducing of problem.

      2. You can download the current sources of QtSerialPort from git and check again.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mastinosoft
        wrote on last edited by
        #3

        hi
        I don't think that some thing wrong with device. I use ttyS0 that linked to rfcomm0. If I connect to device thru Linux terminal no matter with ttyS or rfcomm then I can see that GPS send data cumming without interruptions. That means that device is working and connection is OK.
        Example that I working with is "terminal" from serial port examples that included in Qt installation.

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

          bq. I use ttyS0 that linked to rfcomm0.

          How do you create this link? why you do not use rfcomm0 directly?

          Also, please try to build QtSerialPort from latest sources and try to debug it.

          It is interest that "Resource temporarily unavailable" belongs to EAGAIN native error code.

          Can you check, what of syscall return this error? ::write() or ::read() or something?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mastinosoft
            wrote on last edited by
            #5

            I can use rfcomm0 directly but it not change the result.
            What do you mean from "latest sources", I just use demo example from latest version of QT.
            no ::write() or ::read() not gives any errors . I use only QByteArray data = serial->readAll();
            I try run GtkTerm that connects to ttyS0 and everything working fine.
            If I do the same from demo example then after receiving data around 5 sec. error msg appears.
            I can also use cat /dev/rfcomm0 and no problems.

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

              bq. What do you mean from “latest sources”

              Please see "WIKI":https://qt-project.org/wiki/QtSerialPort how to manually to build and install latest sources of QtSerialPort from Git.

              bq. I use only QByteArray data = serial->readAll();

              In this case, I suspect that this error go out from the system read() call or, maybe from QSocketNotifier... Need to do debugging. Only you yourself can do it.

              PS: It is better, please add this issue to Qt bug-tracker.. With a complete description as to reproduce it and so forth.

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

                UPD: Seems, I suspect where is a problem.. I try to create a patch for this. Please, wait.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mastinosoft
                  wrote on last edited by
                  #8

                  It will be very nice if you have any ideas about this problem.

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

                    Please try this patch: https://codereview.qt-project.org/#change,85414

                    Just try to change content in lines 772-775 and 895 and try to rebuild and check this error again. Because I can not able to reproduce this error on my side.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mastinosoft
                      wrote on last edited by
                      #10

                      thank you I'll try it tomorrow when I'll back to my job. Hope it will works.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mastinosoft
                        wrote on last edited by
                        #11

                        Hi tried to get to the code for Serial Port but it very complicated. Have to do a lot of registration and because I started with Linux just last month it will take more time that I have. Project have to be ready yesterday so I'm in trouble. If it possible can I found the famous SerialPort source code on the other way. You put changed *.cpp file but without all others file I can't do much with it.

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          kuzulis
                          Qt Champions 2020
                          wrote on last edited by
                          #12
                          1. download and install Git
                          2. enter command to download sources:
                            @git clone git://gitorious.org/qt/qtserialport.git@
                          3. enter command to change directory:
                            @cd qtserialport@
                          4. enter command to fetch a patch:
                            @git fetch https://codereview.qt-project.org/p/qt/qtserialport refs/changes/14/85414/2 && git checkout FETCH_HEAD@
                          5. Run QtCreator and open
                            @qtserialport/qtserialport.pro@
                            file in root directory
                          6. From the QtCreator, select your Kit with your desired Qt version (5.2) and re-build library
                          7. Open the console and go-to to the "shadow" build directory of the QtCreator
                          8. enter command:
                            @sudo make install@
                          9. re-run your application and check again
                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mastinosoft
                            wrote on last edited by
                            #13

                            Thank you, I'll try right now.

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mastinosoft
                              wrote on last edited by
                              #14

                              had some problem with git but now is OK

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mastinosoft
                                wrote on last edited by
                                #15

                                Now project opens but I have message:
                                @Executable /home/***/Documents/qtserialport/build-qtserialport-Desktop_Qt_5_2_1_GCC_64bit-Debug/examples/serialport/blockingmaster/blockingmaster does not exist.@
                                I have correct Kit information. "Shadow" build directory I spouse is "//build-qtserialport-Desktop_Qt_5_2_1_GCC_64bit-Debug" ?

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

                                  bq. “Shadow” build directory I spouse is “//build-qtserialport-Desktop_Qt_5_2_1_GCC_64bit-Debug” ?

                                  Yes. Now you should to run "sudo make install" to install QtSerialPort into your Qt 5.2 place (you can check it, see new qserialport*.so in your Qt 5.2 directory).

                                  bq. Now project opens but I have message:

                                  By default, the "make" command build only the library, without the examples.

                                  To build examples you should to enter "make all", or, is more simple - try to open blockingmaster.pro file from QtCreator and re-build an example and to run. :)

                                  1 Reply Last reply
                                  0
                                  • M Offline
                                    M Offline
                                    mastinosoft
                                    wrote on last edited by
                                    #17

                                    Thank you. I tried "Terminal" from examples and it not gives error messages but just stop to receive data. Nothing like this happens if I read data from Linux terminal.

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mastinosoft
                                      wrote on last edited by
                                      #18

                                      Thank you for all your time. I really appreciate that. But it seams that QSerialPort have problems. I switched to QBluetooth and now I receive all data as it have to be.
                                      Best regards.

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

                                        Can you please repeat again but with the new :

                                        @git fetch https://codereview.qt-project.org/p/qt/qtserialport refs/changes/14/85414/3 && git checkout FETCH_HEAD@

                                        command?

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          mastinosoft
                                          wrote on last edited by
                                          #20

                                          ***** ~/Documents/qtserialport $ git clone git://gitorious.org/qt/qtserialport.git
                                          Cloning into 'qtserialport'...
                                          remote: Counting objects: 5574, done.
                                          remote: Compressing objects: 100% (2815/2815), done.
                                          remote: Total 5574 (delta 3819), reused 3756 (delta 2719)
                                          Receiving objects: 100% (5574/5574), 1.46 MiB | 840 KiB/s, done.
                                          Resolving deltas: 100% (3819/3819), done.

                                          ***** ~/Documents $ cd qtserialport
                                          ***** ~/Documents/qtserialport $ git fetch https://codereview.qt-project.org/p/qt/qtserialport refs/changes/14/85414/3 && git checkout FETCH_HEAD
                                          fatal: Not a git repository (or any of the parent directories): .git

                                          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