For dbus-send, how to send a struct param?

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Wed Sep 18 07:40:30 UTC 2019


On Tue, 17 Sep 2019 12:08:42 +0000, 刘铁罡 wrote:

> In fact, I want to send "(qqay)" via dbus-send.
> I can’t find a struct sample of dbus-send.

Sorry, I forgot that my own DBussy examples
<https://github.com/ldo/dbussy_examples> probably already had most of an
answer. I have just done some quick mods to a couple of the example
scripts. As a demo, you can now run the “tagged_listener” as follows:

    ./tagged_listener --bus=session --register=carservice.McuAdapterService.v1_0_McuAdapterService type=method_call \
        "%(typestr)s from %(sender)s to %(destination)s: %(interface)s.%(member)s[%(path)s]%(args)s"

And the “call” script already had the --json option, but now it can
also be invoked as

    ./call --json --signature=qqay session carservice.McuAdapterService.v1_0_McuAdapterService \
        /McuAdapterService carservice.McuAdapterService.v1_0 request 1015 1016 '[1,2,3]'

The ability to specify an explicit signature is needed because
tagged_listener doesn’t do introspection. tagged_listener is also not
set up to reply to the message, but at least the above command will
display the args to the method call, so you can see they get through OK.

Replace tagged_listener with your own actual server app, and the “call”
script should work similarly with that, and also return an answer!
Presumably introspection works with your server, in which case the
--signature option can be omitted.


More information about the dbus mailing list