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. Delay between characters write to serial port
Forum Updated to NodeBB v4.3 + New Features

Delay between characters write to serial port

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 2.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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Hi,

    I want to send printable ascii characters from 32 to 126 (converted to string) to the serial port with a delay between each character. when start button is pressed the SendHandle () function is called. I want to send the ascii characters continuously with delay between each character. I have written a code as below but it hangs when i click the start button. Please help me in this regard.

    void Widget::SendHandle ()
    {
    if(start==1)
    {
    for(i=32;i<=126;i++)
    {

          QString str1= QChar(i);
          asc =str1.toUtf8();
         Sleeper::msleep(delay);
    
        serial->write(asc); //writing data to serial port
    
        ui->display->moveCursor (QTextCursor::End);
        ui->display->insertPlainText (asc);
        ui->display->moveCursor (QTextCursor::End);
    
      ui->bitslcd->display(nchar);
      nchar++;
    
    }
    

    }
    }

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kqt-mr-nv6
      wrote on last edited by
      #2

      if you sleep in the GUI code
      complete event engine is not called
      so the GUI freezes
      you can implement code by using signals & slots

      or

      you can call event engine using
      QCoreApplication::processEvents
      to process the events

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        Thank you so much. QCoreApplication::processEvents(); worked ....

        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