diff --git a/Examples/Modular_Precision_Test_System/HiSLIP_Connect/Connect over LAN to MP5103.pdf b/Examples/Modular_Precision_Test_System/HiSLIP_Connect/Connect over LAN to MP5103.pdf new file mode 100644 index 0000000..00ddbb2 Binary files /dev/null and b/Examples/Modular_Precision_Test_System/HiSLIP_Connect/Connect over LAN to MP5103.pdf differ diff --git a/Examples/Modular_Precision_Test_System/HiSLIP_Connect/connect_hislip.py b/Examples/Modular_Precision_Test_System/HiSLIP_Connect/connect_hislip.py new file mode 100644 index 0000000..ea1ca3f --- /dev/null +++ b/Examples/Modular_Precision_Test_System/HiSLIP_Connect/connect_hislip.py @@ -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}") + diff --git a/Examples/Modular_Precision_Test_System/README.md b/Examples/Modular_Precision_Test_System/README.md index 64e28aa..9488405 100644 --- a/Examples/Modular_Precision_Test_System/README.md +++ b/Examples/Modular_Precision_Test_System/README.md @@ -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.