Wrong data from qextserialport

  • using Qt4.7 on Windows, I have created and opened the serial port in event mode. when the device sends its data, I don't get the same values as sent.

    Device sends:
    0x5A 0xF2 0x01 0x04 0xb3

    I receive:
    0x5A 0xF2 0x40 0x41 0xF6

    If I receive the data into Hyperterminal and save it to a file, I get the correct data. I don't see what I am doing wrong.

    Any ideas?

    Many thanks,

  • Try flushing the port and clearing any buffers when necessary so none of the data is being mixed up.

    Could you give a sample code of what your trying to do?

    Also, how are you reading the data?

  • creating the port:

        serialPort = new QextSerialPort(port, QextSerialPort::EventDriven);


    where port is "COM26"

    after the port is created, I set the baud, parity, stop_bits, flow control, etc.

    opening the port:
    serialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);

    I have tried it with Unbuffered and without

    in the OnDataAvailable SLOT:

    int avail = serialPort->bytesAvailable();
    if(avail < 1) return;
    QByteArray usbdata;
    int read = serialPort->read(usbdata.data(), usbdata.size());
    if(read<1) return;
    for(i=0; i<usbdata.size(); i++)
        rx_char = usbdata[i];


    process rx_char...

    I have looked at usbdata (which is a QByteArray) and it has the data as I posted previously as the receive data. Also, rx_char of course gets the same data, just on char at a time.

  • Try using QSerialDevice 2.0.
    Read this "thread":http://developer.qt.nokia.com/forums/viewthread/11634/#67246

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.