【问题标题】:When do hal properties get updatedhal 属性什么时候更新
【发布时间】:2010-09-09 08:15:02
【问题描述】:

我在 PropertyNotified 信号期间从我的处理程序调用 org.freedesktop.Hal.Device 上的 GetProperty。我只对已添加或更改的属性调用 GetProperty。

当我在属性添加期间调用 GetProperty 时,我收到 org.freedesktop.Hal.NoSuchProperty 异常。我还担心在更改期间,我会得到旧值。

我应该什么时候调用 GetProperty?涉及哪些竞态条件?

【问题讨论】:

    标签: dbus hal


    【解决方案1】:

    DeviceExists 方法怎么样(比如here):

        if device.PropertyExists('info.product'):
            return device.GetProperty('info.product')
        return "unknown"
    

    PropertyModified 信号,(ex from real world):

     #
     # _CBHalDeviceConnected
     #
     # INTERNAL
     #
     # Callback triggered when a device is connected through Hal.
     #
    
     def _CBHalDeviceConnected(self, obj_path): 
    ...
     self.device.connect_to_signal("PropertyModified", 
       self._CBHalDeviceAuthStateChanged) 
    ...
    
    #
    # _CBHalDeviceAuthStateChanged
    #
    # INTERNAL
    #
    # Callback triggered when a Hal device property is changed, 
    # for checking authorization state changes
    #
    
    def _CBHalDeviceAuthStateChanged(self,num_changes,properties):
     for property in properties:
     property_name, added, removed = property
     if property_name == "pda.pocketpc.password":
     self.logger.info("_CBHalDeviceAuthStateChanged: 
         device authorization state changed: reauthorizing")
     self._ProcessAuth() 
    

    HAL 0.5.10 Specification
    D-Bus Specification
    D-Bus Tutorial

    【讨论】:

      猜你喜欢
      • 2011-06-15
      • 1970-01-01
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      • 2010-12-18
      • 2010-10-09
      • 2016-02-28
      • 2010-09-22
      相关资源
      最近更新 更多