Skip to content

Commit

Permalink
Add timeouts to instrument
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed May 15, 2024
1 parent 832a89f commit 67cc970
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions bench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
class Common:
def __del__(self):
"""Close the instrument on object deletion"""
self._instr.close()
if hasattr(self, "_instr"):
self._instr.close()
self.address = None
self._rm.close()
if hasattr(self, "_rm"):
self._rm.close()

def _find_dev_ind(self, rm):
all_resources = rm.list_resources()
Expand All @@ -23,6 +25,7 @@ def _find_dev_ind(self, rm):
common_log.info(f"Found {self.id} at {res}")
self.address = res
self._instr = rm.open_resource(self.address)
self._instr.timeout = 15000
return True

return False
Expand Down
8 changes: 6 additions & 2 deletions bench/keysight/e36233a.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ def __init__(self, address: str = None) -> None:
else:
self.address = address
self._instr = pyvisa.ResourceManager().open_resource(self.address)
if self._instr.query("*IDN?") != self.id:
raise Exception(f"Device at {self.address} is not a {self.id}")
self._instr.timeout = 15000
q_id = self._instr.query("*IDN?")
if self.id not in q_id:
raise Exception(
f"Device at {self.address} is not a {self.id}. Got {q_id}"
)

self.ch1 = channel(self, 1)
self.ch2 = channel(self, 2)
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ myst-parser
sphinxcontrib-mermaid
pillow
furo
sphinx-remove-toctrees
sphinx-remove-toctrees

0 comments on commit 67cc970

Please sign in to comment.