Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Serial - Thread - GUI - Webkit ... need suggestion
QtWS25 Last Chance

[Solved] Serial - Thread - GUI - Webkit ... need suggestion

Scheduled Pinned Locked Moved Mobile and Embedded
serialthreadguiwebkit
3 Posts 1 Posters 1.6k Views
  • 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.
  • McLionM Offline
    McLionM Offline
    McLion
    wrote on last edited by McLion
    #1

    Hi

    I have an application that has a GUI, mainly consisting of a WebView, and that is getting commands by serial port. I currently have all in a single thread.
    I read a lot about using a separate thread to not have the serial port communication blocking the GUI. I have exactly the opposite issue. The GUI - namely the Webview is sometimes blocking and the serial port does not pick up incoming data fast enough ending in the ack sent too late.

    What is the correct approach here?
    Do I move all of the serial port functions (onComReadyRead(), protocolChecker(), SerialWrite() ... and everything related) to a separate thread and communicate to the rest of the application by slot/signals?

    I am using QextSerialPort on Qt 4.6.3 on eLinux with directFB.

    Thanks for any hint to step in the right direction.
    McL

    1 Reply Last reply
    0
    • McLionM Offline
      McLionM Offline
      McLion
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • McLionM Offline
        McLionM Offline
        McLion
        wrote on last edited by McLion
        #3

        I solved this.
        I moved everything related to the serial port into a separate class SerialWorker and moved it to a separate thread.

          QThread* serialthread = new QThread;
          SerialWorker* serialworker = new SerialWorker();
          serialworker->moveToThread(serialthread);
          connect(serialthread, SIGNAL(started()), serialworker, SLOT(InitSerialPort()));
          serialthread->start();
          connect(serialworker, SIGNAL(NewProto(QByteArray)), this, SLOT(ProtocolInterpreter(QByteArray)));
          connect(this, SIGNAL(SendRS(QByteArray)) , serialworker, SLOT(writeData(QByteArray)));
        

        This works as supposed. Serial port is now more or less very responsive.
        WebKit is still blocking the GUI thread sometimes but thats not as much an issue as the serial port not responding.

        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