Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pyvisa
from pyvisa import errors as visa_errors

rm = None
inst = None

try:
rm = pyvisa.ResourceManager()
inst = rm.open_resource("TCPIP0::192.168.0.50::hislip0::INSTR")

# Configure I/O *before* using the session
inst.write_termination = "\n"
inst.read_termination = "\n"
inst.send_end = True
inst.timeout = 10_000 # ms

# Best-effort clear
try:
inst.clear()
except visa_errors.VisaIOError as e:
print(f"Warning: clear() failed: {e}")

inst.write("login admin")
print(inst.query("*IDN?").strip())

inst.write("logout")

except visa_errors.VisaIOError as e:
print(f"VISA I/O error: {e}")
except visa_errors.InvalidSession as e:
print(f"Invalid session: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
finally:
# Always attempt to close resources if they were opened
if inst is not None:
try:
inst.clear()
inst.close()
except Exception as e:
print(f"Warning: inst.close() failed: {e}")
if rm is not None:
try:
rm.close()
except Exception as e:
print(f"Warning: rm.close() failed: {e}")

3 changes: 3 additions & 0 deletions Examples/Modular_Precision_Test_System/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The examples in this directory work with the [MP5103 Mainframe and supported mod
### **[Application Examples:](./Application_Examples/)**
Covers application focused code that may be applicable to any module or may involve more than one module type.

### **[HiSLIP Connect:](./HISLIP_Connect/)**
Brief intro and simple Python sample for login to password protected HiSLIP connection to MP5103.

### **[PSU Examples:](./PSU_Examples/)**
Examples using PSU functionality or applications.

Expand Down