Need Help in Dbus

10 messages Options
Embed this post
Permalink
matzehuber

Need Help in Dbus

Reply Threaded More More options
Print post
Permalink

Hello List,

for my minimoko, i want to implement the battery status and network
status and therefore i want to listen on the dbus.

for not consuming too much resources, i'd like to do this in "pure c"
and with the lowlevel routines.

i found an example here: http://dbus.freedesktop.org/doc/dbus/dbus-example.c

in this example is a section "receive", which i want to use.

now i tried :

  // add a rule for which messages we want to see
   dbus_bus_add_match(conn,
"type='Event',interface='org.freesmartphone.Device.Input'", &err); //
see signals from the given interface
   dbus_connection_flush(conn);
   if (dbus_error_is_set(&err)) {
      fprintf(stderr, "Match Error (%s)\n", err.message);
      exit(1);
   }
   printf("Match rule sent\n");

but i only got:

Match rule sent
Got Signal with value :1.6
Got Signal with value org.freesmartphone.ousaged


What am i doing wrong ?


_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
Michael 'Mickey' Lauer-2

Re: Need Help in Dbus

Reply Threaded More More options
Print post
Permalink
Hi Matthias,

sorry I can't help you there since I never interfaced with DBus on this
level, but let me seriously recommend to use Vala for things like this.
It's hardly adding any runtime penalty and will increase your
productivity by orders of a magnitude.

:M:



_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
matzehuber

Re: Need Help in Dbus

Reply Threaded More More options
Print post
Permalink
Michael 'Mickey' Lauer schrieb:

> Hi Matthias,
>
> sorry I can't help you there since I never interfaced with DBus on this
> level, but let me seriously recommend to use Vala for things like this.
> It's hardly adding any runtime penalty and will increase your
> productivity by orders of a magnitude.
>
> :M:
>
>
>  
Ill give that a try.
How do i setup vala ?

_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
Michael 'Mickey' Lauer-2

Re: Need Help in Dbus

Reply Threaded More More options
Print post
Permalink
Am Mittwoch, den 21.10.2009, 13:14 +0200 schrieb Matthias Huber:
> Ill give that a try.
> How do i setup vala ?

Download it -- e.g. from
http://www.freesmartphone.org/sources/vala-0.7.7+fso5.tar.bz2 -- compile
and install.

A sample DBus client is found in
http://live.gnome.org/Vala/DBusClientSamples

Good speed!

:M:



_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
Michael 'Mickey' Lauer-2

Re: Need Help in Dbus

Reply Threaded More More options
Print post
Permalink
(NOTE: Please don't forget to cc the list)

>root@om-gta02 ~ # ./valadbusclient
>Using **pending_return in dbus_connection_send_with_reply_setup()
>without pending_setup is deprecated and strongly discouraged
>Error: Too many arguments in reply; expected 0, got 1

That's expected as the signature of your signal handler

private void discovery_started (dynamic DBus.Object bluez, string
address_, string name_)

has been copied from the sample and not been adjusted.
org.freesmartphone.GSM.Device.SignalStrength( i ) has a different
signature, hence you would need to change it to
 
private void discovery_started (dynamic DBus.Object bluez, int
strength )

Hope this helps,

:M:



_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
matzehuber

Re: Need Help in Dbus

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Michael 'Mickey' Lauer schrieb:
(NOTE: Please don't forget to cc the list)

  
root@om-gta02 ~ # ./valadbusclient
Using **pending_return in dbus_connection_send_with_reply_setup() 
without pending_setup is deprecated and strongly discouraged
Error: Too many arguments in reply; expected 0, got 1
    

That's expected as the signature of your signal handler

private void discovery_started (dynamic DBus.Object bluez, string 
address_, string name_)

has been copied from the sample and not been adjusted.
org.freesmartphone.GSM.Device.SignalStrength( i ) has a different
signature, hence you would need to change it to
 
private void discovery_started (dynamic DBus.Object bluez, int
strength )

Hope this helps,

:M:
  
Now it works, thank you!


_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
matzehuber

Vala-Problem with stdout and pipe

Reply Threaded More More options
Print post
Permalink
In reply to this post by Michael 'Mickey' Lauer-2

Sorry when i am nervy, but i don't find a documentation about vala's stdout:

when i pipe my program (because i don't want to rewrite my c-code
completele with vala)
into my program, or even into tail, the prog doesn't show any output with my

stdout.printf("sonemting")

is there a stdout.flush() ?
yes there is one.

but that doesn't help me.

Any Idea ?

_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
Michael 'Mickey' Lauer-2

Re: Vala-Problem with stdout and pipe

Reply Threaded More More options
Print post
Permalink
Am Mittwoch, den 21.10.2009, 16:33 +0200 schrieb Matthias Huber:

> Sorry when i am nervy, but i don't find a documentation about vala's stdout:
>
> when i pipe my program (because i don't want to rewrite my c-code
> completele with vala)
> into my program, or even into tail, the prog doesn't show any output with my
>
> stdout.printf("sonemting")
>
> is there a stdout.flush() ?
> yes there is one.
>
> but that doesn't help me.
>
> Any Idea ?

Try appending \n. This is not Vala-specific though, it's plain old posix
stdout.

:M:



_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
matzehuber

Re: Vala-Problem with ??? array variables

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Michael 'Mickey' Lauer schrieb:
Am Mittwoch, den 21.10.2009, 16:33 +0200 schrieb Matthias Huber:
  
Sorry when i am nervy, but i don't find a documentation about vala's stdout:

when i pipe my program (because i don't want to rewrite my c-code 
completele with vala)
into my program, or even into tail, the prog doesn't show any output with my

stdout.printf("sonemting")

is there a stdout.flush() ?
yes there is one.

but that doesn't help me.

Any Idea ?
    

Try appending \n. This is not Vala-specific though, it's plain old posix
stdout.


  
Thank you, now it is working so far.

But for initially getting the provider from dbus, i need to do a call, but i can not find out, how the function prototype has to be declared and also after that, howto get the provider itself, i.e: (this doesn't work):

        // async dbus call
       this.device.GetStatus( reply_handler );

what type is here given back ?


   private void reply_handler (string[] ids, GLib.Error e) {
        // callback for async dbus call
        if (e != null) {
            critical ("%s", e.message);
            return;
        }
        try {
            foreach (string id in ids)
                message ("Answer: %s", id);
        }
        catch (GLib.Error err) {
            critical ("%s", err.message);
        }
    }


_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel
Frederik Sdun

Re: Vala-Problem with ??? array variables

Reply Threaded More More options
Print post
Permalink
* Matthias Huber <[hidden email]> [21.10.2009 18:28]:

>    Michael 'Mickey' Lauer schrieb:
>
>  Am Mittwoch, den 21.10.2009, 16:33 +0200 schrieb Matthias Huber:
>  
>
>  Sorry when i am nervy, but i don't find a documentation about vala's stdout:
>
>  when i pipe my program (because i don't want to rewrite my c-code
>  completele with vala)
>  into my program, or even into tail, the prog doesn't show any output with my
>
>  stdout.printf("sonemting")
>
>  is there a stdout.flush() ?
>  yes there is one.
>
>  but that doesn't help me.
>
>  Any Idea ?
>    
>
>  Try appending \n. This is not Vala-specific though, it's plain old posix
>  stdout.
>
>
>  
>
>    Thank you, now it is working so far.
>
>    But for initially getting the provider from dbus, i need to do a call, but
>    i can not find out, how the function prototype has to be declared and also
>    after that, howto get the provider itself, i.e: (this doesn't work):
>
>            // async dbus call
>           this.device.GetStatus( reply_handler );
>
>    what type is here given back ?
>
>       private void reply_handler (string[] ids, GLib.Error e) {
>            // callback for async dbus call
>            if (e != null) {
>                critical ("%s", e.message);
>                return;
>            }
>            try {
>                foreach (string id in ids)
>                    message ("Answer: %s", id);
>            }
>            catch (GLib.Error err) {
>                critical ("%s", err.message);
>            }
>        }
You can use libfso-glib which is available on [1]. it is generated from
the docs and you get errors on compiletime if you use wrong signatures.

To uses it you only have to use:

var obj = DBus.Bus.get( DBus.BusType.SYSTEM)
            .get_object("org.freesmartphone.GSM.Device",
                "/org/freesmartphone/GSM/Device" ) as
            FreeSmartphone.GSM.Device;
        obj.get_state(reply_handler);

Frederik

[1] http://git.freesmartphone.org/?p=libfso-glib.git;a=summary
> _______________________________________________
> devel mailing list
> [hidden email]
> https://lists.openmoko.org/mailman/listinfo/devel


--
IRC: playya @ Freenode, Gimpnet
xmpp: [hidden email]


_______________________________________________
devel mailing list
[hidden email]
https://lists.openmoko.org/mailman/listinfo/devel

signature.asc (204 bytes) Download Attachment