Esempio n. 1
0
    def allocateInterrupts(self, watcher):
        """Allocate the interrupt

        :param watcher: True if the interrupt should be in synchronous mode
            where the user program will have to explicitly wait for the interrupt
            to occur.
        """
        if self.interrupt is not None:
            raise ValueError("The interrupt has already been allocated")
        self.isSynchronousInterrupt = watcher
        self._interrupt = hal.initializeInterrupts(watcher)
        self._interrupt_finalizer = weakref.finalize(self, hal.cleanInterrupts,
                                                     self._interrupt)
    def allocateInterrupts(self, watcher):
        """Allocate the interrupt

        :param watcher: True if the interrupt should be in synchronous mode
            where the user program will have to explicitly wait for the interrupt
            to occur.
        """
        if self.interrupt is not None:
            raise ValueError("The interrupt has already been allocated")

        self.isSynchronousInterrupt = watcher
        self._interrupt = hal.initializeInterrupts(watcher)
        self._interrupt_finalizer = weakref.finalize(self, hal.cleanInterrupts,
                                                     self._interrupt)
    def allocateInterrupts(self, watcher):
        """Allocate the interrupt

        :param watcher: True if the interrupt should be in synchronous mode
            where the user program will have to explicitly wait for the interrupt
            to occur.
        """
        if self.interrupt is not None:
            raise ValueError("The interrupt has already been allocated")

        try:
            self.interruptIndex = \
                    InterruptableSensorBase.interrupts.allocate(self)
        except IndexError as e:
            raise IndexError("No interrupts are left to be allocated") from e

        self.isSynchronousInterrupt = watcher
        self._interrupt = hal.initializeInterrupts(self.interruptIndex,
                                                   1 if watcher else 0)
        self._interrupt_finalizer = weakref.finalize(self, hal.cleanInterrupts,
                                                     self._interrupt)