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 5.2 and write function?
Forum Updated to NodeBB v4.3 + New Features

QSerialPort 5.2 and write function?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • C Offline
    C Offline
    CroCo
    wrote on last edited by
    #1

    I'm facing a problem with write function. Every time I send "Q" to Hyperterminal or putty, I receive "QQ". This is my code for this function.

    @if ( choice == 1 ){
    port->write("Q\r\n");

    if ( port->waitForBytesWritten(-1) && port->clear() )
    qDebug() << "Data has been send successfully...";
    else
    qDebug() << "Data hasn't been send successfully...";

    }@

    I've tested the code in Hyperterminal and putty, so I think the problem with Qt. I'm using Windows 7 and Qt 5,2. The compiler mingw32-make

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CroCo
      wrote on last edited by
      #2

      Never mind. The problem was HDD Virtual Serial Port. It has nothing to do with Qt or Hyperterminal

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

        You are sure that problem is in "HDD Virtual Serial Port." ? Can you repeat your code in non-blocking manner (without call of waitForBytesWritten(())?

        e.g.:

        [code]
        void YourClass::handleButtonClickedSlot()
        {
        port->write("Q\r\n");
        }
        [/code]

        ?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          CroCo
          wrote on last edited by
          #4

          I've tried this but I'm only able to send just one time after I can't send any more unless I use waitForBytesWritten(-1) or clear() . It seems that write() is in a blocking mode even though in the documentation "here":http://qt-project.org/doc/qt-5.1/qtserialport/blockingmaster.html it states that write() is in non blocking mode. I have no idea why this happens.

          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