QSerialPort



  • 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?



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



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



  • 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?



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



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



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



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



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



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



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


  • Thank you, I'll try right now.



  • had some problem with git but now is OK



  • 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" ?



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



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



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



  • 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?



  • ***** ~/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



  • Need to do change directory from "~/Documents/qtserialport"

    ~/Documents/qtserialport $ cd qtserialport

    because you do pull into ~/Documents/qtserialport but not into ~/Documents

    please try again :)



  • hi again.
    Now I tried the new one you sent me. But unfortunately I have the same result. No error messaged but data stops after a few seconds.



  • Ok. Many thanks for your time. Seems that the solution of this problem should be postponed until I won't get an Bluetooth dongle and so on.



  • Thank you. If you need to know so use I "Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)" and Qstarz 818XT GPS on
    "Linux Mint 14 Nadia". Have a nice weekend.


Log in to reply
 

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