Qt World Summit: Register Today!

Manually send XON/XOFF characters

  • I have a measuring instrument that works this way:

    • I have to send the XON Character
    • After it receives the XON Character it begin to send continuously the measured value
    • When I have enough data, I send the XOFF Character.

    How can I implement this in QT?
    I don't understand how to manually send over serial port the XON and XOFF character.

    Any suggestion?
    Thank you very much

  • @syndrome
    Hi and welcome to devnet

    XON and XOFF characters are defined in the ASCII table.

    You do not give details on the interface, but the only explanation would be that you are communicating to a fairly old device which uses only displayable characters in its communication otherwise.

    You are right it sounds odd nowadays.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Isn't that handle for you when setting the flow control to QSerialPort::SoftwareControl ?

  • @koahnig thank you very much for your answer.
    Yes, it is a very old device. Is it possible with the QSerialPort to send an ascii character? How? I'm sorry if maybe it is "stupid" question.

    @SGaist thank you for your answer too. I have to set it manually, so no, I can't set the flowcontrol to QSerialPort::SoftwareControl. I can use it if the device send the XON / XOFF Character, but in my case I have to send it.

  • @syndrome

    QSerialPort serial;
    // some stuff for initialisation and more 
    char xon ( 17 );   
    char xoff ( 19 );
    serial.writeData ( &xon, 1 );  // will send XON 
    serial.writeData ( &xoff, 1 );  // will send XOFF

    Check out writeData . Do you know how send the rest?

Log in to reply