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"
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"
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"
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
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
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"
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 )
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