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. How to change QSerialPort baud rate if device is connected?
Forum Updated to NodeBB v4.3 + New Features

How to change QSerialPort baud rate if device is connected?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.1k Views 2 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.
  • E Offline
    E Offline
    erytcg
    wrote on last edited by
    #1

    Hello my device has option to change baudrate it always start with 9600.
    I try:

    serialPort->write("commandtochangebaud");
    serialPort->setBaudRate(QSerialPort::Baud19200);
    

    I lost connection and device don't answer.

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

      hi
      so it sounds like
      serialPort->write("commandtochangebaud");
      dont make it change baud and when you switch to
      Baud19200, they can no longer talk.

      1 Reply Last reply
      2
      • E Offline
        E Offline
        erytcg
        wrote on last edited by
        #3

        But comand is from datasheet. Maybe I have to close and open again or change in windows Device manager->COM/LPT->baudrate

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Can you give more information about that device ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kuzulis
            Qt Champions 2020
            wrote on last edited by kuzulis
            #5

            Maybe you need to wait a bit between write() and setBaudRate(). You need to call the setBaudRate() only when the wtite() completes. e.g. it can be done after bytesWritten(qint64 bytes) signal + some delay with QTimer.

            1 Reply Last reply
            2

            • Login

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