【嵌入式基础】D-Bus - 常见名词进一步理解

本文主要基于之前的文章: 【嵌入式开发基础】 D-Bus入门 - 基础概念 进行常用概念的补充.

推荐学习网站: 基于Python-DBus学习D-Bus,dbus-python tutorial 这里对于DBus常见概念: ObjectPath,Interface、Proxy的解释相对DBus官网的解释更好理解.

  • Object Path

The object path. Applications can export many objects - for instance, Example Domain ’s word processor might provide an object representing the word processor application itself and an object for each document window opened, or it might also provide an object for each paragraph within a document.

To identify which one you want to interact with, you use an object path, a slash-separated string resembling a filename. For instance, Example Domain ’s word processor might provide an object at / representing the word processor itself, and objects at /documents/123 and /documents/345representing opened document windows.

原文很好的解释了,在这里就没有翻译成中文,从上面的说明可以将Object Path理解为Object的唯一标识符.

  • Proxy

Python中的解释: To interact with a remote object, you use a proxy object. This is a Python object which acts as a proxy or “stand-in” for the remote object - when you call a method on a proxy object, this causes dbus-python to make a method call on the remote object, passing back any return values from the remote object’s method as the return values of the proxy method call.

可以理解为 可以通过Proxy 进行远程object的调用.

在GDBus中,通过g_dbus_proxy_new_for_bus_sync创建proxy,参数可以看到需要传递service name、object path、interfacename. 这样就间接说明了Porxy是暴露了操作远程Method的方式.

  • Interface

D-Bus uses interfaces to provide a namespacing mechanism for methods. An interface is a group of related methods and signals (more on signals later), identified by a name which is a series of dot-separated components starting with a reversed domain name. For instance, each NetworkManagerobject representing a network interface implements the interfaceorg.freedesktop.NetworkManager.Devices, which has methods like getProperties.

To call a method, call the method of the same name on the proxy object, passing in the interface name via the dbus_interface keyword argumen

类似于C++中的命名空间。将Object中的Method管理起来了,调用Method时需要传入Interface.

总结

后续还会补充关于D-Bus Client的实现,通过实际的代码相信能够进一步的加深对于D-Bus的理解. 另外从当前掌握的知识点来看,D-Bus提供了面向对象的方式,通过Object这一概念展开,类似于C++中的类.主要不好理解是实现了跨进程调的机制.

参考链接:
https://www.freedesktop.org/wiki/IntroductionToDBus/
https://dbus.freedesktop.org/doc/dbus-python/tutorial.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值