Important: Please read the Qt Code of Conduct -

QIODevice read() losing bytes. (0x22 0x33 loses 0x33)

  • This might have to do something with an old Qt version.
    But I am still interested why this happens.

    The scenario:
    Using Qt Creator 2.0.1, based on Qt 4.7.0 (32 bit)
    Opening a serial port via Win_QextSerialPort. Set flowcontrol FLOW_OFF, parity PAR_NONE, data bits DATA_8, stop bits STOP_1.

    When performing a read on the serial port QIODevice, QByteArray read(qint64 maxlen), is used.
    The data expected to be read is {0x00, 0x55, 0x50, 0x11, 0x22, 0x33, 0x44, 0x05} (a LIN data frame)
    As seen this is 8 bytes long, and bytesAvailable() in WinQextSerialPort says that there is 8 bytes available to read. But read(bytesAvailable()) only returns {0x00, 0x55, 0x50, 0x11, 0x22, 0x44, 0x05}, only 7 bytes.

    read(char *data, qint64 maxlen) and readAll() also returns the same value.

    Checking with something else like Tera Term all bytes are received as expected.

    Is this something known? Something interesting behind the behavior? :)

Log in to reply