示例#1
0
def test_reg_config_get_antipoleregs(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    antipole = reg_config.get_antipole_regs("test_device1")
    assert antipole["INVERTED_REG"] == "INVERTED_REG_AP"

    antipole = reg_config.get_antipole_regs("test_device2")
    assert antipole["INVERTED_REG"] == "INVERTED_REG_AP"
示例#2
0
def test_reg_config_get_address(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    addr = reg_config.get_address("test_device1")
    assert addr == "0xA5A5_1234"

    addr = reg_config.get_address("test_device2", remove_underscore=True)
    assert addr == "0x40000000"
示例#3
0
def test_reg_config_get_latest_revision(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    rev = reg_config.get_latest_revision("test_device1")
    assert rev == "x1"

    rev = reg_config.get_latest_revision("test_device2")
    assert rev == "b0"
示例#4
0
def test_reg_config_get_revisions(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    revs = reg_config.get_revisions("test_device1")
    assert "x0" in revs
    assert "x1" in revs

    revs = reg_config.get_revisions("test_device2")
    assert "b0" in revs
示例#5
0
    def __init__(self, debug_probe: DebugProbe, config: RegConfig, device: str, revision: str = "latest") -> None:
        """Initialization of Shadow register class."""
        self._probe = debug_probe
        self.config = config
        self.device = device
        self.offset = int(self.config.get_address(self.device, remove_underscore=True), 16)

        self.regs = Registers(self.device)
        rev = revision if revision != "latest" else config.get_latest_revision(self.device)
        self.regs.load_registers_from_xml(config.get_data_file(self.device, rev))
示例#6
0
def test_reg_config_get_data_file(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    data_file = reg_config.get_data_file("test_device1", "x0")
    assert os.path.join(data_dir, "test_device1_x0.xml") == data_file

    data_file = reg_config.get_data_file("test_device1", "x1")
    assert os.path.join(data_dir, "test_device1_x1.xml") == data_file

    data_file = reg_config.get_data_file("test_device2", "b0")
    assert os.path.join(data_dir, "test_device2_b0.xml") == data_file
示例#7
0
def test_reg_config_get_computed_fields(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))

    computed_fields = reg_config.get_computed_fields("test_device1")
    assert computed_fields["COMPUTED_REG"][
        "TEST_FIELD1"] == "computed_reg_test_field1"
    assert computed_fields["COMPUTED_REG"][
        "TEST_FIELD2"] == "computed_reg_test_field2"
    assert computed_fields["COMPUTED_REG2"][
        "TEST_FIELD1"] == "computed_reg2_test_field1"
    assert computed_fields["COMPUTED_REG2"][
        "TEST_FIELD2"] == "computed_reg2_test_field2"
示例#8
0
def _open_registers(pass_obj: Dict) -> ShadowRegisters:
    """Method opens Registers object based on input arguments.

    :param pass_obj: Input dictionary with arguments.
    :return: Active Registers object.
    :raise SPSDKError: Raised with any kind of problems with debug probe.
    """
    config_file = pass_obj['config_file']
    interface = pass_obj['interface']
    serial_no = pass_obj['serial_no']
    debug_probe_params = pass_obj['debug_probe_params']
    device = pass_obj['device']

    if device not in RegConfig.devices(config_file):
        raise SPSDKError("Invalid or none device parameter(-dev). Use 'listdevs' command to get supported devices.")

    regs_cfg = RegConfig(config_file)

    try:
        debug_probes = DebugProbeUtils.get_connected_probes(interface=interface,
                                                            hardware_id=serial_no,
                                                            user_params=debug_probe_params)
        selected_probe = debug_probes.select_probe()
        debug_probe = selected_probe.get_probe(debug_probe_params)
        debug_probe.open()
        if not enable_debug(debug_probe):
            raise SPSDKError("Cannot enable debug interface")

        debug_probe.enable_memory_interface()
    except SPSDKError as exc:
        raise SPSDKError(f"Error with opening debug probe: ({str(exc)})")

    return ShadowRegisters(
        debug_probe=debug_probe,
        config=regs_cfg,
        device=device
        )
示例#9
0
def test_reg_config_get_devices_class(data_dir):
    devices = RegConfig.devices(os.path.join(data_dir, "reg_config.json"))

    assert "test_device1" in devices
    assert "test_device2" in devices
示例#10
0
def test_reg_config_get_devices(data_dir):
    reg_config = RegConfig(os.path.join(data_dir, "reg_config.json"))
    devices = reg_config.get_devices()

    assert "test_device1" in devices
    assert "test_device2" in devices
示例#11
0
def listdevs(pass_obj: dict) -> None:
    """The command prints a list of supported devices."""
    config_filename = pass_obj['config_file']
    for ix, device in enumerate(RegConfig.devices(config_filename)):
        click.echo(f"{ix:03}: {device}")