【问题标题】:Pass Structure Data To Dbus将结构数据传递给 Dbus
【发布时间】:2020-10-12 15:01:16
【问题描述】:

我有一个正在运行的进程,它有一个采用结构的 DBUS 端点。这是使用 qt 和 q-dbus 开发的。

在 dfeet 中,我看到了端点方法的详细信息

setScreen (Struct of (Int32, Struct of (String), Boolean, Struct of (Int32, UInt32, Byte, Boolean, Byte, Int32, String, String, String, String, String, String, String, String, String), Struct of (Int32, UInt32, Byte, Boolean, Byte, Int32, String, String, String, String, String, String, String, String, String)) screenUi) ↦ (Boolean arg_0)

我试图弄清楚如何以这种格式发送一些示例数据。有什么指点吗?

我尝试通过以下方式使用 dbus-send,但出现格式错误

    gdbus call --session --dest com.semanect.S8Displayd  --object-path /com/semanect/S8Displayd --method com.semanect.S8Displayd.SetScreen "(0,('JBN1'),true,(2,0,0,true,0,0,'','','','','abc','def','ghi','mmm'),(2,0,0,true,0,0,'','','','','abc','def','ghi','mmm')"
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method 'SetScreen' in interface 'com.semaconnect.S8Displayd' at object path '/com/semaconnect/S8Displayd' (signature 's')

使用 d-feet introspect 我得到的方法 dbus 格式为

 '    <method name="setScreen">\n'
 '      <arg type="b" direction="out"/>\n'
 '      <arg name="screenUi" type="(i(s)b(iuybyisssssssss)(iuybyisssssssss))" '
 'direction="in"/>\n'
 '      <annotation name="org.qtproject.QtDBus.QtTypeName.In0" '
 'value="screen_ui_t"/>\n'
 '    </method>\n'

如果有人对如何使用 python 有建议/指示,我也愿意使用 python

更新:

我能够使用 dbus-send 发送数据

gdbus call --session --dest com.semanect.S8Displayd  --object-path /com/semanect/S8Displayd --method com.semanect.S8Displayd.setScreen "(0,('JBN1',),true,(2,0,0,true,0,0,'','','','','abc','def','ghi','mmm','kkk'),(2,0,0,true,0,0,'','','','','abc','def','ghi','mmm','kkk'))"
(true,)

如何使用 python 脚本/C 程序做到这一点?

【问题讨论】:

  • 你使用什么语言?
  • @Barmar 我没想到会这样,我也没有要求有人为我编写程序。我只是向了解 dbus 的人寻求语法帮助。添加了我使用 dbus-send 尝试过的内容

标签: linux shell dbus


【解决方案1】:

不是真正的答案,而是更多信息的呼吁,但由于格式方面的挑战,更容易在此处发布...

我个人觉得busctl 的方法签名更容易阅读。您能否在您的问题中发布以下命令的输出:

busctl introspect com.semanect.S8Displayd  /com/semanect/S8Displayd

正如你提到的 Python。我发现pydbus 非常适合 D-Bus。您能否也发布以下输出:

import pydbus
adapter = pydbus.SessionBus().get('com.semanect.S8Displayd', '/com/semanect/S8Displayd')
help(adapter.SetScreen)

【讨论】:

  • 帮助模块 pydbus.proxy_method 中的方法 setScreen: setScreen(screenUi:(i(s)b(iuybyissssssss)(iuybyisssssssss))) -> DBUS 的 b 方法。 实例
  • 谢谢!@ukBaz。查看内省输出给了我关于如何格式化输入的线索。现在可以使用 dbus-send 进行通信
猜你喜欢
  • 2016-12-15
  • 2017-11-17
  • 1970-01-01
  • 2012-05-09
  • 2021-06-30
  • 1970-01-01
相关资源
最近更新 更多