linux - 将结构数据传递给 Dbus
问题描述
我有一个正在运行的进程,它有一个采用结构的 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
更新 :
我能够使用 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 程序执行此操作?
解决方案
不是真正的答案,而是更多信息的呼吁,但由于格式方面的挑战,更容易在此处发布......
我个人发现方法签名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)
推荐阅读
- html - Bootstrap 和 Angular 未捕获的 TypeError
- c++ - 打印出浮点数的内部十六进制
- spring-boot - spring boot @Autowired 来自另一个模块的 bean
- sql-server - 输入到 SQL Server 后日期时间更改
- astronomy - 将拟合文件数据和/或标题复制到新的拟合文件中
- docker - 在 Docker 容器中启动 Windows 服务
- tsql - 操作数类型冲突:日期与 int / NOT IN 子查询不兼容
- c# - Naudio C#:如何准确地将秒表与音频播放进度同步?
- javascript - 浏览器重新加载选项卡关闭区分调用事件
- oracle - 我有运行时错误任何机构都可以检查功能以及缺少什么