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. Serial synchronous communication
Qt 6.11 is out! See what's new in the release blog

Serial synchronous communication

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 342 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.
  • D Offline
    D Offline
    Damian7546
    wrote on last edited by Damian7546
    #1

    Hi,
    I used an example Blocking Master Example to my serial request-response communication . I send request in thread and I get response by emit signal to slot in my main thread.

    My example reqest is below:
    void SerialParser::req_SimpleTest()
    and response is in a slot:
    void SerialParser::showResponse(const QByteArray &response, const QByteArray &request, const quint8 typeRequest)

    This request recive all devices addresses on serial bus.

    I would like to realize function that can be return recived data. Analogously to the above function the new function should be like:
    QByteArray SerialParser::SimpleTest()
    This function should send request , wait for read, parse data and return result...
    How realize this functionality for example in while loop?
    Thanks for any tips.

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      This function should send request , wait for read, parse data and return result...

      that's not how event programming works. you don't "wait" for anything in a function. you'll stall the event loop.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      3
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        The Blocking Master and Blocking Slave examples (from Qt 5) show how to achieve an entire conversation using blocking IO calls in a worker thread to maintain a responsive GUI.

        If you execute an endless or long-running while() loop in the main thread you will break your GUI responsiveness (as @Kent-Dorfman implies) and negate the effort put into the examples to avoid this.

        You will have to explain which part of this example pair you do not understand and/or better describe the conversation you are trying to have over the serial line.

        1 Reply Last reply
        1

        • Login

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