From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.jumo.net ([193.24.15.13]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mAWKQ-0001XJ-68 for rauc@pengutronix.de; Mon, 02 Aug 2021 13:41:55 +0200 In-Reply-To: Message-ID: From: Eugen.Wiens@JUMO.net Date: Mon, 2 Aug 2021 13:41:50 +0200 References: MIME-Version: 1.0 Subject: [RAUC] Antwort: D-Bus control Qt List-Id: RAUC Project - Discussion List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0174863336==" Errors-To: rauc-bounces@pengutronix.de Sender: "RAUC" To: "Stahl, Michael" Cc: "RAUC@pengutronix.de" --===============0174863336== Content-Type: multipart/alternative; boundary="=_alternative 0040418DC1258725_=" --=_alternative 0040418DC1258725_= Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi Michael, "RAUC" schrieb am 02.08.2021 08:15:26: > Von: "Stahl, Michael" > An: "RAUC@pengutronix.de" > Datum: 02.08.2021 08:15 > Betreff: [RAUC] D-Bus control Qt > Gesendet von: "RAUC" >=20 > Is there someone who implemented the DBus Property "Progress" into a > Qt-Application? The problem seems the return value isi (Integer,=20 > String, Integer).=20 > For all other properties with a single return value like "Operation" > or "LastError" the Qt DBus API works fine.=20 > I found an email from 28.Oct 2019 in the mailing list where Bastian=20 > Krause had the same issue. The answer was only that he had to=20 > cunsult the Qt DBus documentation on how a tuple is mapped to Qt types. >=20 > Thats a good hint but after hours of searching the web I didn't find > a solution. The return value for a property is QVariant in Qt.=20 >=20 > Trial 1 -> Read value by iface.property("Progress"): > This is the error message I got when I try to read the progress=20 property: > Cannot construct placeholder type QDBusRawType >=20 > Trial 2 -> Read value by iface.call("Get",...): > Not able to get any information. The arguments of the returned=20 > QDBusMessages are always empty! That is the way we implemented it: On Qt there are some pitfalls and you has to marshaling the data. 1. Create a Data Class #include #include #include class MyProgress { public: [...] int m=5FProgress; QString m=5FMessage; int m=5FAdditional; }; // this is one of the magic statements=20 Q=5FDECLARE=5FMETATYPE(MyProgress) QDBusArgument &operator<<(QDBusArgument &argument, const MyProgress&=20 parameterProgress); const QDBusArgument &operator>>(const QDBusArgument &argument, MyProgress& = parameterProgress); }; You has to register the metatype and implement the operators. In the=20 Constructor you has to add two register Methods=20 qRegisterMetaType(); qDBusRegisterMetaType(); After this tree registrations your Class MyProgress is known by Qt=20 Metatype System. Now you has to implement operators QDBusArgument &operator<<(QDBusArgument &argument, const MyProgress&=20 parameterProgress) { argument.beginStructure(); argument << parameterProgress.m=5FProgress; argument << parameterProgress.m=5FMessage; argument << parameterProgress.m=5FAdditional; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, MyProgress& = parameterProgress) { argument.beginStructure(); argument >> parameterProgress.m=5FProgress; argument >> parameterProgress.m=5FMessage; argument >> parameterProgress.m=5FAdditional; argument.endStructure(); return argument; } Now you are finished with preparing how to use it. In the Qt Slot of the=20 D-Bus call your can pipe it in your class MyProgress parameterProgress; property.value() >> parameterProgress; This URL help you to map our code to the Qt example=20 https://doc.qt.io/qt-5/qdbusargument.html I hope it helps=20 >=20 > =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F > RAUC mailing list Diese E-Mail kann vertrauliche und/oder rechtlich gesch=FCtzte Informatione= n beinhalten und ist ausschlie=DFlich f=FCr die im Verteiler genannten Pers= onen bestimmt. Das unerlaubte Kopieren sowie die unbefugte Weitergabe diese= r Mail sind nicht gestattet. Bitte benachrichtigen Sie uns gegebenenfalls t= elefonisch oder mit Antwort-Mail, falls Sie nicht der richtige Adressat die= ser E-Mail sind. Bitte l=F6schen Sie diese Nachricht und alle Anh=E4nge daz= u unverz=FCglich. Falls nicht ausdr=FCcklich vermerkt, ist diese E-Mail kei= ne rechtlich bindende Vereinbarung.=20 Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda, Amtsgericht F= ulda HRA 302, Pers=F6nlich haftende Gesellschafterin: M. K. JUCHHEIM GmbH, = Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17, Gesch=E4ftsf=FChrer: Dipl.-Ing= . Bernhard Juchheim, Dipl.-Kfm. Michael Juchheim, Dipl.-Ing. Dimitrios Char= isiadis=20 Ust.-Id.-Nr.: DE 112411234 --=_alternative 0040418DC1258725_= Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi Michael,

"RAUC" <rauc-bounces@pengutronix.de> schrieb am 02.08.2021 08:15:26:

> Von: "Stahl, Michael"= <mstahl@moba.de>

> An: "RA= UC@pengutronix.de" <RAUC@pengutronix.de>
> Datum: 02.08.2021 08:15
&= gt; Betreff: [RAUC] D-Bus control Qt
>= Gesendet von: "RAUC" <rauc-bounces@pengutronix.de><= /tt>
>
> Is there someone who implemented t= he DBus Property "Progress" into a
> Qt-Application? The problem seems the return value isi (Inte= ger,
> String, Integer).

> For= all other properties with a single return value like "Operation"
> or "LastError" the Qt DB= us API works fine.

> I found an email= from 28.Oct 2019 in the mailing list where Bastian
> Krause had the same issue. The answer was only = that he had to
> cunsult the Qt DBus documentation on how a tuple is= mapped to Qt types.

>
> Thats = a good hint but after hours of searching the web I didn't find
> a so= lution. The return value for a property is QVariant in Qt.

= >
> Trial 1 -> Read value by iface.property= ("Progress"):

> This is the = error message I got when I try to read the progress property:
> Cannot c= onstruct placeholder type QDBusRawType
&g= t;
> Trial 2 -> Read value by iface.call("Get",...):

> Not able to get any information. The a= rguments of the returned
> QDBusMessages are always empty!

That is the way we implemented it:


<= font size=3D2>On Qt there are some pitfalls and you has to marshaling the data.


1. Create a Data Class

#include <QObject>
<= tt>#include <QDBusArgument>
#include <QString>

clas= s MyProgress
{
public:
[...]
=     int m=5FProgress;
    QString m=5FMessage;
=     int m=5FAdditional;
};

// this is one of the magic statements
Q=5FDECLARE=5FMETATYPE(MyProgress)<= /tt>
QDBusArgument &operator<<(QDBusArgument &argument, const MyProgress& parameterProgress);
const QDBusArgument &operator>>(const QDBusArgume= nt &argument, MyProgress& parameterProgress);

};


You has to register the = metatype and implement the operators. In the Constructor you has to add two register Methods

qRegisterMetaType<MyProgress>();=
qDBusRegisterMetaType<MyProgress>();

After this tree registrations your Class = MyProgress is known by Qt Metatype System. Now you has to implement operators

QDBusArgument &operator<<(QDBusArgu= ment &argument, const MyProgress& parameterProgress)
= {
    argument.b= eginStructure();
    argument &= lt;< parameterProgress.m=5FProgress;
&= nbsp;   argument << parameterProgress.m=5FMessage;    argument << parameterProgress.m=5F= Additional;
    argument.endStr= ucture();
    return argument;<= /font>
}
const= QDBusArgument &operator>>(const QDBusArgument &argument, MyProgress& parameterProgress)
{
    argument.beginSt= ructure();
    argument >>= ; parameterProgress.m=5FProgress;
  =   argument >> parameterProgress.m=5FMessage;
=     argument >> parameterProgress.m=5FAdditi= onal;
    argument.endStructure= ();
    return argument;=
}

Now you= are finished with preparing how to use it. In the Qt Slot of the D-Bus call your can pipe it in your class=

MyProgress parameterProgress;
property.value<QDBusArgument>() >> parameterPro= gress;



This URL help you to map o= ur code to the Qt example https://doc.qt.io/qt-5/qdbusargument.html


I hope it helps


>
> =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F
> RAUC mailing list

Diese E-Mail kann ver= trauliche und/oder rechtlich gesch=FCtzte Informationen beinhalten und ist = ausschlie=DFlich f=FCr die im Verteiler genannten Personen bestimmt. Das un= erlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht ges= tattet. Bitte benachrichtigen Sie uns gegebenenfalls telefonisch oder mit A= ntwort-Mail, falls Sie nicht der richtige Adressat dieser E-Mail sind. Bitt= e l=F6schen Sie diese Nachricht und alle Anh=E4nge dazu unverz=FCglich. Fal= ls nicht ausdr=FCcklich vermerkt, ist diese E-Mail keine rechtlich bindende= Vereinbarung.

Kommanditgesellschaft: JUMO GmbH & Co. KG, Sitz: 36039 Fulda, Amtsgeric= ht Fulda HRA 302, Pers=F6nlich haftende Gesellschafterin: M. K. JUCHHEIM Gm= bH, Sitz: 36039 Fulda, Amtsgericht Fulda HRB 17, Gesch=E4ftsf=FChrer: Dipl.= -Ing. Bernhard Juchheim, Dipl.-Kfm. Michael Juchheim, Dipl.-Ing. Dimitrios = Charisiadis
Ust.-Id.-Nr.: DE 112411234

--=_alternative 0040418DC1258725_=-- --===============0174863336== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ RAUC mailing list --===============0174863336==--