Exemplo n.º 1
0
from pynq.tests.util import get_interface_id


__author__ = "Giuseppe Natale, Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ = "*****@*****.**"


try:
    _ = Overlay('base.bit', download=False)
    flag0 = True
except IOError:
    flag0 = False
flag1 = user_answer_yes("\nPmod OLED attached to the board?")
if flag1:
    oled_id = eval(get_interface_id('Pmod OLED', options=['PMODA', 'PMODB']))
flag = flag0 and flag1


@pytest.mark.skipif(not flag, 
                    reason="need OLED attached to the base overlay")
def test_write_string():
    """Test for the OLED Pmod.
    
    Writes on the OLED the string 'Welcome to PYNQ.' and asks the user to 
    confirm if it is shown on the OLED. After that, it clears the screen. 
    This test can be skipped.
    
    """
    Overlay('base.bit').download()
    oled = Pmod_OLED(oled_id)
from pynq.lib.pmod import PMODB
from pynq.tests.util import user_answer_yes
from pynq.tests.util import get_interface_id

__author__ = "Naveen Purushotham, Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ = "*****@*****.**"

try:
    _ = Overlay('base.bit', download=False)
    flag0 = True
except IOError:
    flag0 = False
flag1 = user_answer_yes("\nPmod TMP2 attached to the board?")
if flag1:
    tmp2_id = eval(get_interface_id('Pmod TMP2', options=['PMODA', 'PMODB']))
flag = flag0 and flag1


@pytest.mark.skipif(not flag,
                    reason="need Pmod TMP2 attached to the base overlay")
def test_read_temp():
    """Test for the TMP2 class.
    
    Reads the TMP2 and asks the user if the temperature is displayed.
    
    """
    Overlay('base.bit').download()
    tmp2 = Pmod_TMP2(tmp2_id)

    n = tmp2.read()
from pynq.lib.pmod import PMODB
from pynq.tests.util import user_answer_yes
from pynq.tests.util import get_interface_id

__author__ = "Giuseppe Natale, Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ = "*****@*****.**"

try:
    _ = Overlay('base.bit', download=False)
    flag0 = True
except IOError:
    flag0 = False
flag1 = user_answer_yes("\nPmod ADC and DAC attached (straight cable)?")
if flag1:
    dac_id = eval(get_interface_id('Pmod DAC', options=['PMODA', 'PMODB']))
    adc_id = eval(get_interface_id('Pmod ADC', options=['PMODA', 'PMODB']))
flag = flag0 and flag1


@pytest.mark.skipif(not flag,
                    reason="need ADC and DAC attached to the base overlay")
def test_dac_adc_loop():
    """Test for writing a single value via the loop.
    
    First check whether read() correctly returns a string. Then ask the users 
    to write a voltage on the DAC, read from the ADC, and compares the two 
    voltages.
    
    The exception is raised when the difference is more than 10% and more than
    0.1V.
Exemplo n.º 4
0
from pynq.lib.pmod import PMODB
from pynq.tests.util import user_answer_yes
from pynq.tests.util import get_interface_id

__author__ = "Naveen Purushotham, Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ = "*****@*****.**"

try:
    _ = Overlay('base.bit', download=False)
    flag0 = True
except IOError:
    flag0 = False
flag1 = user_answer_yes("\nPmod ALS attached to the board?")
if flag1:
    als_id = eval(get_interface_id('Pmod ALS', options=['PMODA', 'PMODB']))
flag = flag0 and flag1


@pytest.mark.skipif(not flag,
                    reason="need Pmod ALS attached to the base overlay")
def test_readlight():
    """Test for the ALS class.
    
    This test reads the ALS and asks the user to dim light manually. Then
    verify that a lower reading is displayed.
    
    """
    Overlay('base.bit').download()
    als = Pmod_ALS(als_id)
from pynq.lib.pmod import PMODB
from pynq.tests.util import user_answer_yes
from pynq.tests.util import get_interface_id

__author__ = "Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ = "*****@*****.**"

try:
    _ = Overlay('base.bit', download=False)
    flag0 = True
except IOError:
    flag0 = False
flag1 = user_answer_yes("\nTwo Pmod interfaces connected by a cable?")
if flag1:
    send_id = eval(get_interface_id('sender', options=['PMODA', 'PMODB']))
    recv_id = eval(get_interface_id('receiver', options=['PMODA', 'PMODB']))
flag = flag0 and flag1


@pytest.mark.skipif(not flag,
                    reason="need Pmod cable attached to the base overlay")
def test_pmod_cable():
    """Tests for the Pmod cable.

    The following tests are involved here:

    1. Test the Pmod cable type.

    2. Test for right shifting the bit "1". The sender will send patterns 
    with the bit "1" right shifted each time.