Results 1 to 5 of 5

Thread: XON/XOFF connection with QtSerialPort

  1. #1
    Join Date
    Feb 2014
    Posts
    15
    Thanks
    3

    Default XON/XOFF connection with QtSerialPort

    Hi,

    Wanted to know how I should approach a serial port connection with XON/XOFF flow control.

    Before I read/write from/to serial port, what should I do?

    The process is something like this:

    I send data to my serial port, the receiver sends me XOFF after he receives it, now I should wait until he sends me XON, then I can send again. How I translate that to code? The waiting part (which should be passive, no?) is the difficult one for me.

    The purpose is to send a hex file by lines.
    Last edited by oldFox64; 6th February 2014 at 08:01.

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: XON/XOFF connection with QtSerialPort

    Hi.

    We didn't check the modes "Software/Hardware" flow control for QtSerialPort. I.e. it isn't known as this set of modes will behave with the Qt event-loop and so forth.
    In the theory, for you (as transmitter role) is not necessary cares of existence of XON/XOFF bytes that received from the receiver. Because it does by hardware, at the level of the driver of the serial port.
    So, your task consists in that simply to send all data to the receiver, like Transmitter::write(/all data/). And just watch for the bytesWritten() signal to know how many data are transferred in reality, IMHO.

  3. #3
    Join Date
    Feb 2014
    Posts
    15
    Thanks
    3

    Default Re: XON/XOFF connection with QtSerialPort

    Thank you, kuzulis.

    I tell my results later.

    EDIT: Success Was easier than I thought.

    while(!in.atEnd()){
    QString line = in.getLine();
    serial->write(line.toLocalBits8());
    serial->waitForBytesWritten(250);
    }

    That is enough.
    Last edited by oldFox64; 6th February 2014 at 12:32.

  4. #4
    Join Date
    Feb 2014
    Posts
    15
    Thanks
    3

    Default Re: XON/XOFF connection with QtSerialPort

    Hmm, if I don't use waitForBytesWritten after write and waitForReadyRead before read, the communication doesn't work properly. That means that these functions are checking the control chars XON/XOFF (as I said, my firmware, the receiver, sends me XON's and XOFF's chars) ? If so, I think it would be a good idea to specify it in the documentation, don't you?
    Last edited by oldFox64; 11th February 2014 at 08:41.

  5. #5
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: XON/XOFF connection with QtSerialPort

    Please show your complete code to reproduce a problem.

Similar Threads

  1. QtSerialport Inconsistant Connection Issue
    By awpitt13 in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2013, 07:14
  2. QtSerialport windows problem
    By danics in forum Qt Programming
    Replies: 15
    Last Post: 12th September 2013, 20:25
  3. XON/XOFF flowcontrol with QextSerialPort
    By lindamissak in forum Newbie
    Replies: 1
    Last Post: 16th August 2012, 23:53
  4. cannot build qtserialport
    By banlinhtienphong in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2011, 05:56
  5. Replies: 0
    Last Post: 11th November 2011, 19:18

Tags for this Thread

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.