Ejemplo n.º 1
0
    def test_OpenWithInvalidTimeout_ShowAssertion(self):
        invalid_timeouts = [-1, '', []]

        for invalid_timeout in invalid_timeouts:
            with self.assertRaises(AssertionError):
                AIIRQ(irq_channel, self.irq_handler, irq_number,
                      invalid_timeout, threshold, hysteresis, irq_type)
Ejemplo n.º 2
0
    def test_OpenWithInvalidIrqType_ShowAssertion(self):
        limits = {'min': 0, 'max': 1}
        invalid_irq_types = [limits['min'] - 1, limits['max'] + 1, '', []]

        for invalid_irq_type in invalid_irq_types:
            with self.assertRaises(AssertionError):
                AIIRQ(irq_channel, self.irq_handler, irq_number, timeout,
                      threshold, hysteresis, invalid_irq_type)
Ejemplo n.º 3
0
    def test_OpenWithFallingEdgeAndWaitForInterrupt_IrqNumberWasAsserted(self):
        irq_type = AIIRQType.FALLING

        irq_thread = threading.Thread(target=self.__reading_thread,
                                      args=(self.falling_array, ))

        with AIIRQ(AIIRQChannel.AI0, self.__irq_handler, irq_number, timeout,
                   threshold, hysteresis, irq_type) as AI_IRQ:

            irq_thread.start()

            AI_IRQ.wait()

        irq_thread.join()

        self.assertTrue(self.success)
Ejemplo n.º 4
0
# specify the identifier of the interrupt to register
irq_number = IRQNumber.IRQ1
# specify the amount of time, in milliseconds, to wait for an interrupt to
# occur before timing out
timeout = 6000
# specify the value, in volts, that the signal must cross for the interrupt to
# occur
threshold = 1
# specify a window, in volts, above or below threshold. This program uses
# hysteresis to prevent false interrupt registration
hysteresis = 0.05
# specify whether to register an interrupt on the falling edge or rising
# edge of the analog input signal
irq_type = AIIRQType.RISING
# configure an analog input interrupt session
with AIIRQ(irq_channel, irq_handler, irq_number, timeout, threshold,
           hysteresis, irq_type) as AI_IRQ:
    # open the LED session
    LED = LEDs()
    # specify the LED which you want to control
    led = Led.LED0
    # specify the LED status
    led_on_off = True

    # create a thread to wait for the interrupt
    irq_thread = threading.Thread(target=AI_IRQ.wait)
    irq_thread.start()

    # write values 50 times, which makes LED0 flash for 25 seconds
    for x in range(0, 50):
        # turn LED0 on or off
        LED.write(led, led_on_off)