【问题标题】:Understanding HAL DBus Events?了解 HAL DBus 事件?
【发布时间】:2012-08-18 21:32:55
【问题描述】:

我正在 DBus 上观看 HAL 事件,观察交流适配器何时被移除/插入。

通过dbus-montior,这两个事件看起来完全一样:

拔出事件

signal sender=:1.85 -> dest=(null destination) serial=3698 path=/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC0; interface=org.freedesktop.Hal.Device; member=PropertyModified
   int32 1
   array [
      struct {
         string "ac_adapter.present"
         boolean false
         boolean false
      }
   ]

插件事件

signal sender=:1.85 -> dest=(null destination) serial=3701 path=/org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_AC0; interface=org.freedesktop.Hal.Device; member=PropertyModified
   int32 1
   array [
      struct {
         string "ac_adapter.present"
         boolean false
         boolean false
      }
   ]

但是,显式查询 org.freedesktop.Hal 中的 ac_adapter.present 属性确实会正确返回设备状态。

问题:在 PropertyModified 事件中发送的布尔值是什么?是否存在我可以过滤的事件,该事件将包含有关适配器存在的信息,或者我是否必须在收到更模糊的“发生某事”消息后明确查询?

HAL DBus documentation 不是特别有用,或者我找错地方了。

【问题讨论】:

    标签: dbus hal


    【解决方案1】:

    在收到更模糊的“发生了什么事”消息后,我是否必须明确查询?

    是的。如果你使用d-feet之类的DBus浏览器,你会看到AC适配器对象上的org.freedesktop.Hal.Device接口有方法

    • GetProperty(String property) -> Variant
    • GetPropertyBoolean(String property) -> Boolean - 可能对 ac_adapter.present 有用

    【讨论】:

      猜你喜欢
      • 2011-04-09
      • 1970-01-01
      • 2017-01-26
      • 2022-01-24
      • 2013-01-07
      相关资源
      最近更新 更多