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. DBus async response. Correct way.
Forum Updated to NodeBB v4.3 + New Features

DBus async response. Correct way.

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 138 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.
  • P Offline
    P Offline
    Pavel Romankov
    wrote on last edited by
    #1

    Hello.
    I have module UartGateway, which is wrapper on uart interface. It send messages via uart. This module has dbus interface to communicate with other modules.
    Also I have module UartClient which can use UartGateway interface to get some data via uart.
    In my UartClient I can call something like this:

    auto pendingCall =  UartGatewayInterface->getVoltage();
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *call){
            QDBusPendingReply<quint32> reply = *call;
            if (reply.isError()) {
                qWarning() << "Error occured";
            } else {
                processResult(reply.argumentAt<0>());
            }
    }
    

    in UartGateway method getVoltage() is called (by adapter)

    quint32 UartGateway::getVoltage(){
    // need to send request by uart and return result
    }
    

    Method getVoltage() works syncrounosly.
    As I need to send request via uart and process responce asyncrounosly, what is correct way to do it?

    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