Skip to content

Rigol DS1104z oscilloscope

This example uses the Rigol DS1104z oscilloscope attached to the gateway to take a screenshot of the waveform during a test. It uses the VISAScopeDS1104Z interface defined by the HIL SDK and creates a fixture, which the test_screenshot.py then uses to take a screenshot and return it to either the developer calling the HIL, or to a pipeline if it's running in CI.

It consists of two files:

conftest.py - This imports the VISAScopeDS1104Z interface and creates the fixture

test_screenshot.py - Contains a test that sends uses the take_screenshot function to grab a screenshot and store it in screenshot.png that is returned at the end of the test because it's stored in the hil_results_get_path location.

import os
import pytest
import logging
import time

from hil_sdk.version import __version__
from hil_sdk.interfaces.jlink_interface import JLinkInterface
from hil_sdk.interfaces.nrfjprog_interface import nrfjprog_flash
from hil_sdk.interfaces.visa.oscilloscope.visa_scope_ds1104z import VISAScopeDS1104Z

@pytest.fixture(autouse=True, scope="session")
def hil_version_fixture():
    logging.info(f"HIL SDK version {__version__}")

@pytest.fixture(autouse=True, scope="session")
def jlink_fixture(hil_version_fixture):

    logging.info("Creating J-Link interface...")
    return JLinkInterface("nRF5340_xxAA_APP")

@pytest.fixture(autouse=True, scope="session")
def flash_fixture(jlink_fixture, hil_extras_get_path):

    logging.info("Flashing target...")
    assert nrfjprog_flash(hil_extras_get_path("build/zephyr/merged_domains.hex"), "NRF53") == 0

    logging.info("Resetting target...")
    assert jlink_fixture.reset_and_go()

    time.sleep(2)  # Sleep for a couple of seconds to let the target device start up


@pytest.fixture
def visa_scope_ds1104z_fixture():
    return VISAScopeDS1104Z()
import pyvisa
import os


def test_scope_screenshot(visa_scope_ds1104z_fixture, hil_results_get_path):

    try:
    # use the hil_results_get_path to get the path to the directory that will
    # be returned at the end of the test
        my_file_name = hil_results_get_path('screenshot.png')
        visa_scope_ds1104z_fixture.take_screenshot(my_file_name)

    except Exception as err:
        print('Exception: ' + str(err))
        assert(False)