Results 1 to 5 of 5

Thread: Qserialdevice 2.0 waitForBytesWritten halfduplex question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Qserialdevice 2.0 waitForBytesWritten halfduplex question

    I have a question, writing a Qt GUI and I have the RTS line connected to a RS-485 driver transmit/receive control signal. I am sending out x number of bytes, I use the setRts(1) to make it go high (start of transmisson) and setRts(0) when I finish (as direction control). Does the waitForBytesWritten method work? I want it to wait until all the bytes have been transmitted out of the serial port, so I can setRts low. I see that sometimes the RTS signal is going low before all the bytes have been transferred. Any one have any ideas?

    Do I have to set it up in unbuffered mode?

    Here is a snippet of my code. Thanks in advance.

    Qt Code:
    1. void TraceDialog::procSendButtonClick()
    2. {
    3. QByteArray data;
    4. data.append(ui->lineEdit->text());
    5. m_port->setRts(1);
    6. if (data.size() > 0) {
    7. m_port->write(data);
    8. printTrace(data, false);
    9. ui->lbError->setText(QString::number(m_port->error()));
    10. }
    11. // Add in sleep timer
    12.  
    13. while(m_port->waitForBytesWritten(15)); // Time out for 15 ms
    14.  
    15. m_port->setRts(0);
    16. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 12th February 2012 at 21:07. Reason: missing [code] tags

Similar Threads

  1. QSerialDevice enumerator deletion question
    By marcvanriet in forum Qt Programming
    Replies: 4
    Last Post: 28th December 2011, 01:48
  2. QSerialDevice on Symbian
    By hubbobubbo in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2011, 19:00
  3. QSerialDevice
    By clinisbut in forum Qt Programming
    Replies: 2
    Last Post: 23rd October 2009, 13:30
  4. question about QSerialDevice (baudrate)
    By mastupristi in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2009, 08:54
  5. waitForBytesWritten
    By smalls in forum Qt Programming
    Replies: 8
    Last Post: 1st March 2006, 16:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.