How to Pass a structure as a parameter in a dbus signal?

坚强是说给别人听的谎言 提交于 2019-12-23 04:34:45

问题


How to pass a structure as a parameter to a dbus signal through command line?

Dbus-send --system --type=signal / com.example.signal_name string:"hello"

In the place of string, I want to pass structure foo.

typedef enum {MODE1, MODE2, MODE3} MODE;
typedef enum {TYPE1, TYPE2} TYPE;

struct foo
{
    MODE mode;
    TYPE type;
};

回答1:


Firstly, you need to work out how to represent that structure as a D-Bus value. Its most likely representation would be as a value of type (uu) where the first u is the mode (using some well-defined and stable mapping of C enum values to integers) and the second u is the type.

Secondly, you need to work out how to write that on the command line. However, dbus-send doesn’t currently support structs, so it’s not possible using dbus-send. I suggest using gdbus instead, as per this StackOverflow question.



来源:https://stackoverflow.com/questions/57506251/how-to-pass-a-structure-as-a-parameter-in-a-dbus-signal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!