QSerialPort - send error

  • Hello,
    I am trying hard to communicate with my measurment device via Bluetooth using QSerialPort (Windows 7). It has a bunch of 1Byte commands on which it reacts properly (like on 0x02 - state your name - the name it states). However when i try some multibyte commands i can see that it catches only part of it, sometimes nothing. I have checked the device with external program and it reacts properly. I dont have source to this program (which is kind of pity) so i cant check the solutions there. What i mean is can QSerialPort send some rubbish or incomplete transmition?

  • Qt Champions 2016

    If baud, parity,stopbits etc are set correctly,
    i have not seen it send rubbish.

    Maybe try with
    (its ready to compile in Creator in the example tab)

    and see if it works better.

  • Hello michelson,

    I recently experienced problems with QSerialPort on embedded linux, when writing to the internal write buffer while data was actually sent to the interface. This resulted in data loss up to 90%...
    In my case, the problem was to use the flush() method manually (see https://forum.qt.io/topic/60329/when-does-qserialport-send-data-from-the-buffer-to-the-serial-interface):

    void MainWindow::writeData(const QByteArray &data)
        //serial->flush(); //caused problems, when calling writeData() in a loop
        serial->waitForBytesWritten(1000); // instead of the flush() - worked as a 'first' solution

    Maybe there's some similar problem in your case?



  • Does the device you are communicating with have an internal buffer? Try inserting a small delay between bytes for the multi byte commands to see if that helps.


Log in to reply

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