示例#1
0
def main():
    """
    Main program function
    """

    passed = True

    iopi = IOPi(0x20, False)  # new iopi object without initialisation

    for a in range(1, 65536):
        iopi.invert_bus(a)
        x = iopi.get_bus_polarity()
        if x != a:
            passed = False
            break
        iopi.invert_bus(a)
        x = iopi.get_bus_polarity()
        if x != a:
            passed = False
            break

    if passed is False:
        print("Test Failed")
    else:
        print("Test Passed")
def main():
    """
    Main program function
    """

    passed = True

    iopi = IOPi(0x20, False)  # new iopi object without initialisation

    # Check invert_bus value for low out of bounds
    try:
        iopi.invert_bus(-1)
        pass
    except ValueError:
        print("value low boundary check: PASSED")
        pass
    except IOError:
        passed = False
        print("I2C IOError")
    else:
        passed = False
        print("value low boundary check: FAILED")
        pass

    # Check invert_bus value for high out of bounds
    try:
        iopi.invert_bus(65536)
        pass
    except ValueError:
        print("value high boundary check: PASSED")
        pass
    except IOError:
        passed = False
        print("I2C IOError")
    else:
        passed = False
        print("value high boundary check: FAILED")
        pass

    # Logic Analyser Check
    print("Logic output Started")

    for x in range(0, 65536):
        iopi.invert_bus(x)

    print("Logic output Ended")

    if passed is False:
        print("Test Failed")