Skip to content

Commit

Permalink
Merge pull request #780 from pyvisa/vicp-rname
Browse files Browse the repository at this point in the history
rname: fix VICP resource name normalization
  • Loading branch information
MatthieuDartiailh committed Oct 25, 2023
2 parents a9507e5 + 1034c72 commit fc1cb89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions pyvisa/rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if TYPE_CHECKING:
from .resources import Resource # noqa # pragma: no cover

#: Interface types for which a subclass of ResourName exists
#: Interface types for which a subclass of ResourceName exists
_INTERFACE_TYPES: Set[str] = set()

#: Resource Class for Interface type
Expand Down Expand Up @@ -428,12 +428,13 @@ class VICPInstr(ResourceName):
"""VICP INSTR
The syntax is:
VICP[board]::host address[::INSTR]
VICP::host address[::INSTR]
"""

#: Board to use.
board: str = "0"
#: VICP resource do not support a board index. But it is the only resource
#: in this case so we allow parsing one but set a default of ""
_unused: None = None

#: Host address of the device (IPv4 or host name)
host_address: str = ""
Expand Down
20 changes: 10 additions & 10 deletions pyvisa/testsuite/test_rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,35 +300,35 @@ def test_vicp_intr(self):
interface_type="VICP",
resource_class="INSTR",
host_address="192.168.134.102",
board="0",
canonical_resource_name="VICP0::192.168.134.102::INSTR",
_unused=None,
canonical_resource_name="VICP::192.168.134.102::INSTR",
)

self._parse_test(
"VICP::dev.company.com::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="dev.company.com",
board="0",
canonical_resource_name="VICP0::dev.company.com::INSTR",
_unused=None,
canonical_resource_name="VICP::dev.company.com::INSTR",
)

self._parse_test(
"VICP3::dev.company.com::INSTR",
"VICP::dev.company.com::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="dev.company.com",
board="3",
canonical_resource_name="VICP3::dev.company.com::INSTR",
_unused=None,
canonical_resource_name="VICP::dev.company.com::INSTR",
)

self._parse_test(
"VICP3::1.2.3.4::INSTR",
"VICP::1.2.3.4::INSTR",
interface_type="VICP",
resource_class="INSTR",
host_address="1.2.3.4",
board="3",
canonical_resource_name="VICP3::1.2.3.4::INSTR",
_unused=None,
canonical_resource_name="VICP::1.2.3.4::INSTR",
)

def test_tcpip_socket(self):
Expand Down

0 comments on commit fc1cb89

Please sign in to comment.