mail archive of the rauc mailing list
 help / color / mirror / Atom feed
From: "Stahl, Michael" <mstahl@moba.de>
To: "Eugen.Wiens@JUMO.net" <Eugen.Wiens@JUMO.net>
Cc: RAUC <rauc-bounces@pengutronix.de>,
	"RAUC@pengutronix.de" <RAUC@pengutronix.de>
Subject: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt
Date: Tue, 3 Aug 2021 13:27:32 +0000	[thread overview]
Message-ID: <AM9PR09MB4756A4BADFF38BF3E31E19B3DBF09@AM9PR09MB4756.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <OF04F87260.04422217-ONC1258726.003DB81E-C1258726.003DC6AD@JUMO.DE>


[-- Attachment #1.1: Type: text/plain, Size: 12891 bytes --]

I solved my problems. Now I want to share my solution. Many thanks to Eugen Wiens who gave the most important input.

Summary:
1. Create a Data Class
2. Register the Data Class
3. Implement operators for marshalling
4. Install signal notification for PropertyChange signal
5. Pip the DBus data into the data class

1. Data Class
raucprogress.cpp
#include "raucprogress.h"


QDBusArgument &operator<<(QDBusArgument &argument, const RaucProgress& parameterProgress)

{

    argument.beginStructure();

    argument << parameterProgress.m_Progress;

    argument << parameterProgress.m_Message;

    argument << parameterProgress.m_Additional;

    argument.endStructure();

    return argument;

}


const QDBusArgument &operator>>(const QDBusArgument &argument, RaucProgress& parameterProgress)

{

    argument.beginStructure();

    argument >> parameterProgress.m_Progress;

    argument >> parameterProgress.m_Message;

    argument >> parameterProgress.m_Additional;

    argument.endStructure();

    return argument;

}


raucprogress.h

#ifndef RAUCPROGRESS_H


#define RAUCPROGRESS_H

#include <QObject>

#include <QDBusArgument>

#include <QMetaType>

#include <QDBusMetaType>

class RaucProgress

{

public:

    int m_Progress;

    QString m_Message;

    int m_Additional;

};

QDBusArgument &operator<<(QDBusArgument &argument, const RaucProgress &parameterProgress);

const QDBusArgument &operator>>(const QDBusArgument &argument, RaucProgress &parameterProgress);

#endif // RAUCPROGRESS_H


2. Register the Data Class

notifier.cpp:

// this is one of the magic statements

Q_DECLARE_METATYPE(RaucProgress)


3. Register the Data Class

notifier.cpp:

Notifier::Notifier()

{

    qRegisterMetaType<RaucProgress>();

  qDBusRegisterMetaType<RaucProgress>();

}



4. Install signal notification for PropertyChange signal

notifier.cpp:

int Notifier::Init()


{

    if (!QDBusConnection::sessionBus().isConnected()) {

         fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"

                 "To start it, run:\n"

                 "\teval `dbus-launch --auto-syntax`\n");

         return 1;

     }

    dbus_iface = new QDBusInterface ( "de.pengutronix.rauc",

                                      "/",

                                      "de.pengutronix.rauc.Installer",

                                      QDBusConnection::systemBus() );

    if (dbus_iface->isValid() == false)

    {

        return 1;

    }


    connect(dbus_iface, SIGNAL(Completed(int)),this,SLOT(UpdateFinished(int)));


    if (QDBusConnection::systemBus().connect("de.pengutronix.rauc",             //Service

                                             "/",                               //Path

                                             "org.freedesktop.DBus.Properties", //Interface

                                             "PropertiesChanged",

                                             this,

                                             SLOT(propertyChanged(const QString& ,

                                                                  const QMap<QString, QVariant>& ,

                                                                  const QStringList& )))) {

        qDebug() << "PropertiesChanged signal connected successfully to slot";

        } else {

         qDebug() << "PropertiesChanged signal connection was not successful";

         return 1;

        }

    return 0;

}


5. Pip the DBus data into the data class

notifier.cpp


void Notifier::propertyChanged(const QString text , const QMap<QString, QVariant> map, const QStringList list){


    RaucProgress parameterProgress;

    map["Progress"].value<QDBusArgument>() >> parameterProgress;

    qDebug() << parameterProgress.m_Progress;

    qDebug() << parameterProgress.m_Message;

}


I hope it can be useful for people who have similar problems as I.


Kind Regards


Michael


________________________________
Von: Eugen.Wiens@JUMO.net <Eugen.Wiens@JUMO.net>
Gesendet: Dienstag, 3. August 2021 13:14
An: Stahl, Michael <mstahl@moba.de>
Cc: RAUC@pengutronix.de <RAUC@pengutronix.de>; RAUC <rauc-bounces@pengutronix.de>
Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

sounds good.



Von:        "Stahl, Michael" <mstahl@moba.de>
An:        "RAUC@pengutronix.de" <RAUC@pengutronix.de>
Kopie:        RAUC <rauc-bounces@pengutronix.de>
Datum:        03.08.2021 13:00
Betreff:        Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt
Gesendet von:        "RAUC" <rauc-bounces@pengutronix.de>
________________________________



I found the issue

You have to connect to the systemBus not to the sessionBus!

if(QDBusConnection::systemBus().connect("de.pengutronix.rauc",                                        //Service
                                 "/",                              //Path
                                 "org.freedesktop.DBus.Properties",//Interface
                                 "PropertiesChanged",
                                 this,
                                 SLOT(propertyChanged(constQString&,
                                                      constQMap<QString,QVariant>&,
                                                      constQStringList&)))){

        qDebug()<<"PropertiesChangedsignalconnectedsuccessfullytoslot";
        }else{
        qDebug()<<"PropertiesChangedsignalconnectionwasnotsuccessful";
        }

Now I my function propertyChanged is called every time the property changes.

If you use
export QDBUS_DEBUG=1
you get a lot of debug output. It is very useful.

The next step is to extract the informations of the QMap.


________________________________

Von: Stahl, Michael <mstahl@moba.de>
Gesendet: Dienstag, 3. August 2021 10:27
An: Eugen.Wiens@JUMO.net <Eugen.Wiens@JUMO.net>
Cc: RAUC@pengutronix.de <RAUC@pengutronix.de>; RAUC <rauc-bounces@pengutronix.de>
Betreff: AW: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Euen,

I know but I am stucking. I am polling the propery "Operation". Just when it changes from "idle" to "installing" I subscribe the PropertiesChanged signal but without success. I tried several connect strings but all without success.


if(QDBusConnection::sessionBus().connect("de.pengutronix.rauc",
                                 "/",
                                 "org.freedesktop.DBus.Properties",
                                 "PropertiesChanged",
                                 this,
                                 SLOT(propertyChanged(constQString&,
                                                      constQMap<QString,QVariant>&,
                                                      constQStringList&))))
{
    qDebug()<<"PropertiesChangedsignalconnectedsuccessfullytoslot";
}else{
    qDebug()<<"PropertiesChangedsignalconnectionwasnotsuccessful";
}

Please can you tell me how to subcribe the PropertiesChanged signal?

________________________________

Von: Eugen.Wiens@JUMO.net <Eugen.Wiens@JUMO.net>
Gesendet: Dienstag, 3. August 2021 08:27
An: Stahl, Michael <mstahl@moba.de>
Cc: RAUC@pengutronix.de <RAUC@pengutronix.de>; RAUC <rauc-bounces@pengutronix.de>
Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: Re: Antwort: D-Bus control Qt

Hi Michael,

you can connect to a property change on dbus level. That is the way we do it.


"RAUC" <rauc-bounces@pengutronix.de> schrieb am 03.08.2021 08:21:32:

> Von: "Stahl, Michael" <mstahl@moba.de>
> An: "Eugen.Wiens@JUMO.net" <Eugen.Wiens@JUMO.net>
> Kopie: "RAUC" <rauc-bounces@pengutronix.de>, "RAUC@pengutronix.de"
> <RAUC@pengutronix.de>
> Datum: 03.08.2021 08:21
> Betreff: Re: [RAUC] Antwort: Re:  Antwort: Re:  Antwort:  D-Bus control Qt
> Gesendet von: "RAUC" <rauc-bounces@pengutronix.de>
>
> Hi Eugen,
>
> thanks again. I implemented the signal and now I get the signal that
> the update is finished.
> But thats the only signal that rauc is provided, isn't it? To get
> the progress I have to poll the property, or are there general
> signals on the dbus that I can connect to?
>
> Do you read the property "Progress" like
> QDBusInterface iface( "de.pengutronix.rauc",
>                  "/",
>                  "de.pengutronix.rauc.Installer",
>                  QDBusConnection::systemBus() );
> QVariant property = iface.property("Progress");
> MyProgress parameterProgress;
> property.value<QDBusArgument>() >> parameterProgress;
>
> or did you use another possibility?
> If I use the above I get a message five times and the marshaled data (
> m_Progress, m_Message, ..) are always empty.
> QDBusArgument: read from a write-only object

>
> Von: Eugen.Wiens@JUMO.net <Eugen.Wiens@JUMO.net>
> Gesendet: Montag, 2. August 2021 16:53
> An: Stahl, Michael <mstahl@moba.de>
> Cc: RAUC@pengutronix.de <RAUC@pengutronix.de>; RAUC <rauc-
> bounces@pengutronix.de>
> Betreff: Antwort: Re: [RAUC] Antwort: Re: Antwort: D-Bus control Qt
>
> Hi Michael,
>
> "RAUC" <rauc-bounces@pengutronix.de> schrieb am 02.08.2021 16:29:18:
>
> > Von: "Stahl, Michael" <mstahl@moba.de>
> > An: "Eugen.Wiens@JUMO.net" <Eugen.Wiens@JUMO.net>
> > Kopie: RAUC <rauc-bounces@pengutronix.de>, "RAUC@pengutronix.de"
> > <RAUC@pengutronix.de>
> > Datum: 02.08.2021 16:29
> > Betreff: Re: [RAUC] Antwort: Re:  Antwort:  D-Bus control Qt
> > Gesendet von: "RAUC" <rauc-bounces@pengutronix.de>
> >
> > Okay, thanks a lot.
> >
> > A last question. Is it correct that I have to poll the "Progress"
> > property or is there any signal system where I can subcribe to get a
> > notification at every change of progress status?
>
> We are using a dbus signal. You can connect to it with Qt.
>
> Best regards,
> Eugen
> Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte
> Informationen beinhalten und ist ausschlie?lich f?r die im Verteiler
> genannten Personen bestimmt. Das unerlaubte Kopieren sowie die
> unbefugte Weitergabe dieser Mail sind nicht gestattet. Bitte
> benachrichtigen Sie uns gegebenenfalls telefonisch oder mit Antwort-
> Mail, falls Sie nicht der richtige Adressat dieser E-Mail sind.
> Bitte l?schen Sie diese Nachricht und alle Anh?nge dazu unverz?
> glich. Falls nicht ausdr?cklich vermerkt, ist diese E-Mail keine
> rechtlich bindende Vereinbarung.
>
> Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda,
> Amtsgericht Fulda HRA 302, Pers?nlich haftende Gesellschafterin: M.
> K. JUCHHEIM GmbH, Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17,
> Gesch?ftsf?hrer: Dipl.-Ing. Bernhard Juchheim, Dipl.-Kfm. Michael
> Juchheim, Dipl.-Ing. Dimitrios Charisiadis
> Ust.-Id.-Nr.: DE 112411234_______________________________________________
> RAUC mailing list
Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte Informationen beinhalten und ist ausschlie?lich f?r die im Verteiler genannten Personen bestimmt. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet. Bitte benachrichtigen Sie uns gegebenenfalls telefonisch oder mit Antwort-Mail, falls Sie nicht der richtige Adressat dieser E-Mail sind. Bitte l?schen Sie diese Nachricht und alle Anh?nge dazu unverz?glich. Falls nicht ausdr?cklich vermerkt, ist diese E-Mail keine rechtlich bindende Vereinbarung.

Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda, Amtsgericht Fulda HRA 302, Pers?nlich haftende Gesellschafterin: M. K. JUCHHEIM GmbH, Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17, Gesch?ftsf?hrer: Dipl.-Ing. Bernhard Juchheim, Dipl.-Kfm. Michael Juchheim, Dipl.-Ing. Dimitrios Charisiadis
Ust.-Id.-Nr.: DE 112411234_______________________________________________
RAUC mailing list



Diese E-Mail kann vertrauliche und/oder rechtlich gesch?tzte Informationen beinhalten und ist ausschlie?lich f?r die im Verteiler genannten Personen bestimmt. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet. Bitte benachrichtigen Sie uns gegebenenfalls telefonisch oder mit Antwort-Mail, falls Sie nicht der richtige Adressat dieser E-Mail sind. Bitte l?schen Sie diese Nachricht und alle Anh?nge dazu unverz?glich. Falls nicht ausdr?cklich vermerkt, ist diese E-Mail keine rechtlich bindende Vereinbarung.

Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda, Amtsgericht Fulda HRA 302, Pers?nlich haftende Gesellschafterin: M. K. JUCHHEIM GmbH, Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17, Gesch?ftsf?hrer: Dipl.-Ing. Bernhard Juchheim, Dipl.-Kfm. Michael Juchheim, Dipl.-Ing. Dimitrios Charisiadis
Ust.-Id.-Nr.: DE 112411234

[-- Attachment #1.2: Type: text/html, Size: 57834 bytes --]

[-- Attachment #2: Type: text/plain, Size: 66 bytes --]

_______________________________________________
RAUC mailing list

      reply	other threads:[~2021-08-03 13:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02  6:15 [RAUC] " Stahl, Michael
2021-08-02  8:14 ` Bastian Krause
2021-08-02  8:53   ` Wolk, Steffen
2021-08-02 11:41 ` [RAUC] Antwort: " Eugen.Wiens
2021-08-02 12:45   ` Stahl, Michael
2021-08-02 13:20     ` Stahl, Michael
2021-08-02 13:36       ` [RAUC] Antwort: " Eugen.Wiens
2021-08-02 14:29         ` Stahl, Michael
2021-08-02 14:53           ` [RAUC] Antwort: " Eugen.Wiens
2021-08-03  6:21             ` Stahl, Michael
2021-08-03  6:27               ` [RAUC] Antwort: " Eugen.Wiens
2021-08-03  8:27                 ` Stahl, Michael
2021-08-03 10:57                   ` Stahl, Michael
2021-08-03 11:00                   ` Stahl, Michael
2021-08-03 11:14                     ` [RAUC] Antwort: " Eugen.Wiens
2021-08-03 13:27                       ` Stahl, Michael [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB4756A4BADFF38BF3E31E19B3DBF09@AM9PR09MB4756.eurprd09.prod.outlook.com \
    --to=mstahl@moba.de \
    --cc=Eugen.Wiens@JUMO.net \
    --cc=RAUC@pengutronix.de \
    --cc=rauc-bounces@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox