def postStart(self): '''Checking the current state of the listening GPIO's and do the configured actions''' Module.postStart(self) # Init listen GPIO's in poststart # We need to be sure that listen isn't triggered until all the modules was started for name, item in self._cfg.get('listen', {}).iteritems(): log.info("Attaching GPIO listener %s to pin %d" % (name, item['pin'])) self._pin_map[item['pin']] = name gpio.setup(item['pin'], gpio.IN) while self.isActive(): # Sometimes event detection is can't be set up - so need retries try: gpio.add_event_detect(item['pin'], gpio.BOTH, callback=self._listenTrigger) except RuntimeError: log.error( 'Detected unable to set event detection for GPIO %s, retrying...' % item['pin']) self.waitActive(1.0) continue break for pin in self._pin_map: self._listenTrigger(pin)
def postStart(self): Module.postStart(self)