qtserial-portqiodevice

QIODevice::ReadWrite | QIODevice::Unbuffered - Unsupported open mode


http://doc.qt.io/qt-5/qserialport.html#open

Warning: The mode has to be QIODevice::ReadOnly, QIODevice::WriteOnly, or QIODevice::ReadWrite. Other modes are unsupported.

Following code does not open the serial port.

if(serialPort.open (QIODevice::ReadWrite | QIODevice::Unbuffered))
    {
        qDebug() << "asdasdas";
        serialPort.setDataBits(QSerialPort::Data8);
        serialPort.setParity(QSerialPort::NoParity);
        serialPort.setStopBits(QSerialPort::OneStop);
    }
    else
    {
        qDebug() << "QSerialPort::SerialPortError: " << serialPort.errorString();
    }

what is the way to use the unbuffered flag?


Solution

  • what is the way to use the unbuffered flag?

    There is none. QSerialPort doesn't support it.

    Alas, your assumption about the buffering slowing you down is unfounded unless you have measurements that demonstrate the issue. My bet is that you don't and won't have such measurements. You have other problems. Serial ports are usually of comparatively slow bandwidth, single megabits/second aren't an issue when it comes to buffering unless you're doing something that causes the buffering to have quadratic cost, and not the linear cost with very low proportionality constant it normally has.