Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPort - send error

QSerialPort - send error

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michelson
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Maybe try with
      http://doc.qt.io/qt-5/qtserialport-terminal-example.html
      (its ready to compile in Creator in the example tab)

      and see if it works better.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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->write(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?

        Greetings,

        Markus

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mawh1960
          wrote on last edited by
          #4

          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.

          Mike

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved