Re: [FSO] problem connect Dbus signals with Qt4
Hi, On Tue, Nov 25, 2008 at 06:33:49PM +0100, macebre wrote: > i declared a new Metatype GPSSatellite with << and >> operators. > > struct GPSSatellite > { > int ID; > bool InUse; > unsigned int Elevation; > unsigned int Azimuth; > unsigned int SNR; > }; ID needs to be of type unsigned int (never trust the gypsy online docs ;)) Greetings, Sascha ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
On Wednesday 26 November 2008 15:00:08 arne anka wrote: > did you ever try QDBusArgument, as mickey lauer suggested? yes, tried quite many Types, thats why I'm asking here.. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
> I've implemented all Gypsy get-methods and signals except the > SatelliteChanged-singal so far.. did you ever try QDBusArgument, as mickey lauer suggested? > is there a Wiki to put this functions as an example? is OM-Wiki the right > place? i'd think fso is the better place for this kind of information. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
On Wednesday 26 November 2008 13:44:01 arne anka wrote: > please post your .h and .cpp -- that might help, to get a clue, where to > look. Hi, here they are.. I've implemented all Gypsy get-methods and signals except the SatelliteChanged-singal so far.. is there a Wiki to put this functions as an example? is OM-Wiki the right place? #include "MokoGPS.h" #include #include #include #include #include #include / * << and >> Operators declaration for DBus metatypes */ // Marshall the GPSSatellite data into a D-BUS argument QDBusArgument &operator<<(QDBusArgument &argument, const GPSSatellite &sat) { argument.beginStructure(); argument << sat.ID << sat.InUse << sat.Elevation << sat.Azimuth << sat.SNR; argument.endStructure(); return argument; } // Retrieve the GPSSatellite data from the D-BUS argument const QDBusArgument &operator>>(const QDBusArgument &argument, GPSSatellite &sat) { argument.beginStructure(); argument >> sat.ID >> sat.InUse >> sat.Elevation >> sat.Azimuth >> sat.SNR; argument.endStructure(); return argument; } const QDebug operator<<(QDebug debug, const GPSSatellite &sat) { debug << sat.ID << sat.InUse << sat.Elevation << sat.Azimuth << sat.SNR; return debug; } const QDebug operator<<(QDebug debug, const QList &lsat) { foreach(GPSSatellite sat, lsat) debug << sat; return debug; } /* * MokoGPS class */ MokoGPS::MokoGPS(){ ///*** ///* Connection to system bus ///*** //register GPSSatellite metatype qDBusRegisterMetaType(); qDBusRegisterMetaType >(); QDBusConnection GPSConnection = QDBusConnection::systemBus(); /// check connection if (GPSConnection.isConnected()) qDebug() << "successfully connected to system bus \n"; else qFatal("Failed to connect to session bus"); /// create a proxy object for method calls QString ServiceBusName = "org.freedesktop.Gypsy"; QString ObjectPath = "/org/freedesktop/Gypsy" ; GPSInterface = new QDBusInterface( ServiceBusName, ObjectPath, ///method path = "" search recursive in ///all subfolders for the called method "", QDBusConnection::systemBus() ); connect(GPSInterface, SIGNAL( FixStatusChanged(int) ),this, SLOT( handleFixStatusChanged(int) ) ); //next line is to try types to connect to Signal connect(GPSInterface, SIGNAL( SatellitesChanged(QDBusMessage) ) ,this, SLOT( handleSatellitesChanged(QDBusMessage) ) ); } ///* destructor MokoGPS::~MokoGPS(){ ///close on prog.exit logPosition.close(); logAccuracy.close(); logCourse.close(); //logSatellites.close(); } /* * Slots to interact with GUI */ /// enable GPS void MokoGPS::StartDevice() { GPSInterface->call("Enable"); qDebug()<<"device started \n"; emit sendOutput("device started ", 1); } /// disable GPS void MokoGPS::StopDevice() { GPSInterface->call("Disable"); qDebug()<<"device stopped \n"; emit sendOutput("device stopped ", 1); } void MokoGPS::StartLog() { qDebug()<<"start logging"; emit sendOutput("start logging", 1); /// timestamp to prepend to Logfile name QDateTime *thisDay = new QDateTime(); QString thisDate = thisDay->currentDateTime().toString("-MM-dd_hh.mm.ss"); ///open logfiles QString positionlog = "GPSPosition.log"; QString accuracylog = "GPSAccuracy.log"; QString courselog = "GPSCourse.log"; QString satelliteslog = "GPSSatellites.log"; positionlog.prepend(thisDate); accuracylog.prepend(thisDate); courselog.prepend(thisDate); satelliteslog.prepend(thisDate); logPosition.open(positionlog.toLatin1() ); logAccuracy.open(accuracylog.toLatin1() ); logCourse.open(courselog.toLatin1() ); //logSatellites.open(satelliteslog.toLatin1() ); /// connect dbus signals connect(GPSInterface, SIGNAL( PositionChanged(int,int,double,double,double) ),this, SLOT( handlePositionChanged(int,int,double,double,double) ) ); connect(GPSInterface, SIGNAL( TimeChanged(int) ),this, SLOT( handleTimeChanged(int) ) ); connect(GPSInterface, SIGNAL( ConnectionStatusChanged(bool) ),this, SLOT( handleConnectionStatusChanged(bool) ) ); /// due to display this without logging in Gui it is connected in the constructor //connect(GPSInterface, SIGNAL( FixStatusChanged(int) ),this, SLOT( handleFixStatusChanged(int) ) ); connect(GPSInterface, SIGNAL( CourseChanged(int,int,double,double,double) ),this, SLOT( handleCourseChanged(int,int,double,double,double) ) ); connect(GPSInterface, SIGNAL( AccuracyChanged(int,double,double,double) ),this, SLOT( handleAccuracyChanged(int,double,double,double) ) ); /// not jet possible to set the right parameter //connect(GPSInterface, SIGNAL( SatellitesChanged(QDBusArgument) ),this, SLOT( handleSatellitesChanged(QDBusArgument) )
Re: [FSO] problem connect Dbus signals with Qt4
please, always answer to the list. > On Wednesday 26 November 2008 11:35:26 you wrote: >> > FR# mdbus -s org.freedesktop.Gypsy /org/freedesktop/Gypsy >> > says: >> > [SIGNAL]org.freedesktop.Gypsy.Satellite.SatellitesChanged( >> > a(ubuuu):satellites ) >> >> that's no, what i meant. >> the signal has to be declared in some .h file you are using -- what does >> it look like? > yes, if i "made" this signal. but its a Gypsy-signal which is part of > FSOframework and comes over the dbus. > > so it isn't declared in my files... anyway, you need to include some headers where the signal is declared > I don't know where it is declared, > maybe it is declared in the Gypsy source files but it is written in gtk > so it > wouldn't help me much, i think, or does it? that's deep water, my Qt is a bit rusty. but i think, somewhere there should be the declaration you are trying to use. > I tried to find out which signal is sends via QSignalSpy, but even this > class > needs to know the exact parameters of SatellitesChanged signal.. > > is there a way to accept/connect the Signal without knowing the exact > parameter? none, that i know of. please post your .h and .cpp -- that might help, to get a clue, where to look. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
> FR# mdbus -s org.freedesktop.Gypsy /org/freedesktop/Gypsy > says: > [SIGNAL]org.freedesktop.Gypsy.Satellite.SatellitesChanged( > a(ubuuu):satellites ) that's no, what i meant. the signal has to be declared in some .h file you are using -- what does it look like? ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
On Tuesday 25 November 2008 18:48:21 arne anka wrote: > > Object::connect: No such signal > > local::Merged::SatellitesChanged(QDBusMessage) > > where is SatellitesChanged declared and how? its a signal from Gypsy (Dbus) org.freedesktop.Gypsy /org/freedesktop/Gypsy FR# mdbus -s org.freedesktop.Gypsy /org/freedesktop/Gypsy says: [SIGNAL]org.freedesktop.Gypsy.Satellite.SatellitesChanged( a(ubuuu):satellites ) an array of structs like my GPSSatellite. Whats the Type wich Qt s "connect" is waiting for? > > ___ > Openmoko community mailing list > community@lists.openmoko.org > http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
> Object::connect: No such signal > local::Merged::SatellitesChanged(QDBusMessage) where is SatellitesChanged declared and how? ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
thanks, i declared a new Metatype GPSSatellite with << and >> operators. struct GPSSatellite { int ID; bool InUse; unsigned int Elevation; unsigned int Azimuth; unsigned int SNR; }; Q_DECLARE_METATYPE(GPSSatellite); Q_DECLARE_METATYPE(QList); They work fine with the dBus method GetSatellites(). QDBusMessage SatelliteReply; SatelliteReply = GPSInterface->call("GetSatellites"); QList satList = qdbus_cast >(SatelliteReply.arguments()[0]); my problem is that i can not connect to the SatellitesChanged signal like: connect(GPSInterface, SIGNAL( SatellitesChanged(QDBusMessage) ) ,this, SLOT( handleSatellitesChanged(QDBusMessage) ) ); I have tried many Types and every time there's the error like: Object::connect: No such signal local::Merged::SatellitesChanged(QDBusMessage) which Type / Metatype shoud i use here?? ( On Sunday 23 November 2008 22:41:39 Michael 'Mickey' Lauer wrote: > Am Sunday 23 November 2008 22:24:18 schrieb macebre: > > Does somebody know which type I have to use there or where I could find > > more information about this? > > Is there a command to find out which Qt type is send by a signal? > > Please consult the Qt DBus documentation, e.g. > http://doc.trolltech.com/4.2/qdbusargument.html > > IIRC it says there that you have to use the >> operator to extract > arguments out of arrays and structs. *** for Interested the my GPSSatellite operators: QDBusArgument &operator<<(QDBusArgument &argument, const GPSSatellite &sat) { argument.beginStructure(); argument << sat.ID << sat.InUse << sat.Elevation << sat.Azimuth << sat.SNR; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, GPSSatellite &sat) { argument.beginStructure(); argument >> sat.ID >> sat.InUse >> sat.Elevation >> sat.Azimuth >> sat.SNR; argument.endStructure(); return argument; } and somewhere in code: qDBusRegisterMetaType(); qDBusRegisterMetaType >(); ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [FSO] problem connect Dbus signals with Qt4
Am Sunday 23 November 2008 22:24:18 schrieb macebre: > Does somebody know which type I have to use there or where I could find > more information about this? > Is there a command to find out which Qt type is send by a signal? Please consult the Qt DBus documentation, e.g. http://doc.trolltech.com/4.2/qdbusargument.html IIRC it says there that you have to use the >> operator to extract arguments out of arrays and structs. -- :M: ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
[FSO] problem connect Dbus signals with Qt4
Hi there, i'm developing another small GPS-class which shoud handle the Gypsy signals. After connecting to bus i can easily connect SIGNALS to my slots like that: connect(GPSInterface, SIGNAL( PositionChanged(int,int,double,double,double) ),this, SLOT( handlePositionChanged(int,int,double,double,double) ) ); connect(GPSInterface, SIGNAL( TimeChanged(int) ),this, SLOT( handleTimeChanged(int) ) ); connect(GPSInterface, SIGNAL( CourseChanged(int,int,double,double,double) ),this, SLOT( handleCourseChanged(int,int,double,double,double) ) ); but for "SatellitesChanged" mdbus says: [SIGNAL]org.freedesktop.Gypsy.Satellite.SatellitesChanged( a(ubuuu):satellites ) i can't figure out which parameter I shoud use in Qt to connect this Signal.. Does somebody know which type I have to use there or where I could find more information about this? Is there a command to find out which Qt type is send by a signal? Thanks, mat ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community