何时hal属性更新

时间:2008-09-16 06:15:12

标签: dbus hal

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

当我在属性添加期间调用GetProperty时,我得到一个org.freedesktop.Hal.NoSuchProperty异常。我也担心在变化期间,我会得到旧的价值观。

我什么时候应该拨打GetProperty?涉及哪些竞争条件?

1 个答案:

答案 0 :(得分: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