From 91d1e20bc769cb66126ef1c727e918af29cc8421 Mon Sep 17 00:00:00 2001 From: Thorvald Larsen Date: Thu, 15 Sep 2022 10:21:43 -0700 Subject: [PATCH 1/7] first proposal for fix --- qcodes/instrument_drivers/Minicircuits/USB_SPDT.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py index d6a441f7394..4334d3b0432 100644 --- a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py +++ b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py @@ -68,8 +68,12 @@ def __init__(self, name: str, driver_path: Optional[str] = None, the dll to open properties and check the 'unblock' checkmark in the bottom. Check that your python installation is 64bit.""" ) - import mcl_RF_Switch_Controller64 # pyright: ignore[reportMissingImports] - self.switch = mcl_RF_Switch_Controller64.USB_RF_SwitchBox() + try: + import mcl_RF_Switch_Controller64 as mw_driver # pyright: ignore[reportMissingImports] + except: + import mcl_RF_Switch_Controller_NET45 as mw_driver # pyright: ignore[reportMissingImports] + + self.switch = mw_driver.USB_RF_SwitchBox() if not self.switch.Connect(serial_number): raise RuntimeError('Could not connect to device') From 2e89f82bacfb5e772be635c2e834ab3313f29309 Mon Sep 17 00:00:00 2001 From: Thorvald Larsen Date: Thu, 15 Sep 2022 10:24:47 -0700 Subject: [PATCH 2/7] update link --- ...des example with Minicircuits Switch boxes (USB-XSPDT).ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb b/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb index f94bdc8311b..81a5a1bf527 100644 --- a/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb +++ b/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb @@ -24,7 +24,7 @@ "\n", "The driver_path should specify the url of the dll for controlling the instrument. You can find it here:\n", "\n", - "https://ww2.minicircuits.com/softwaredownload/rfswitchcontroller.html\n", + "https://www.minicircuits.com/softwaredownload/rfswitchcontroller.html\n", "\n", "Download .NET dll and save somewhere. Unblock it (right click properties) and specify the path." ] From f1a8b1524c5f325486560cd7a01a02dfaaf5350d Mon Sep 17 00:00:00 2001 From: Thorvald Larsen Date: Wed, 9 Nov 2022 14:48:40 -0800 Subject: [PATCH 3/7] add error type --- qcodes/instrument_drivers/Minicircuits/USB_SPDT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py index 4334d3b0432..7049b67d9fb 100644 --- a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py +++ b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py @@ -70,7 +70,7 @@ def __init__(self, name: str, driver_path: Optional[str] = None, ) try: import mcl_RF_Switch_Controller64 as mw_driver # pyright: ignore[reportMissingImports] - except: + except ImportError: import mcl_RF_Switch_Controller_NET45 as mw_driver # pyright: ignore[reportMissingImports] self.switch = mw_driver.USB_RF_SwitchBox() From 1b56835ea866fb222de2d5878ed0dca8eda9b312 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 18 Jan 2023 13:50:19 +0100 Subject: [PATCH 4/7] ignore missing types from mcl_RF_Switch_Controller_NET45 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 4aa770cccf6..a0600f79934 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,6 +211,7 @@ module = [ "lomentum.tools", "matplotlib.*", "mcl_RF_Switch_Controller64", + "mcl_RF_Switch_Controller_NET45", "opencensus.ext.azure.*", "pythoncom", "pyqtgraph.*", From 5cd3d8b3a4544d1b38ae2adfa3c206774014555b Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 18 Jan 2023 13:56:22 +0100 Subject: [PATCH 5/7] Also try looking for .net 45 driver --- qcodes/instrument_drivers/Minicircuits/USB_SPDT.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py index 7049b67d9fb..8c4c7b1442b 100644 --- a/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py +++ b/qcodes/instrument_drivers/Minicircuits/USB_SPDT.py @@ -37,7 +37,8 @@ class USB_SPDT(SPDT_Base): """ CHANNEL_CLASS = SwitchChannelUSB - PATH_TO_DRIVER = r'mcl_RF_Switch_Controller64' + PATH_TO_DRIVER = r"mcl_RF_Switch_Controller64" + PATH_TO_DRIVER_45 = r"mcl_RF_Switch_Controller_NET45" def __init__(self, name: str, driver_path: Optional[str] = None, serial_number: Optional[str] = None, **kwargs: Any): @@ -57,15 +58,18 @@ def __init__(self, name: str, driver_path: Optional[str] = None, raise ImportError("""This driver only works in Windows.""") try: if driver_path is None: - clr.AddReference(self.PATH_TO_DRIVER) + try: + clr.AddReference(self.PATH_TO_DRIVER) + except FileNotFoundError: + clr.AddReference(self.PATH_TO_DRIVER_45) else: clr.AddReference(driver_path) except (ImportError, FileNotFoundException): raise ImportError( - """Load of mcl_RF_Switch_Controller64.dll not possible. Make sure - the dll file is not blocked by Windows. To unblock right-click - the dll to open properties and check the 'unblock' checkmark + """Load of mcl_RF_Switch_Controller64.dll or mcl_RF_Switch_Controller_NET45.dll + not possible. Make sure the dll file is not blocked by Windows. + To unblock right-click the dll to open properties and check the 'unblock' checkmark in the bottom. Check that your python installation is 64bit.""" ) try: From e8847627ea999d78eb84904b8735b784d38c18cb Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 18 Jan 2023 14:00:00 +0100 Subject: [PATCH 6/7] Add note about different .net versions --- ...inicircuits Switch boxes (USB-XSPDT).ipynb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb b/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb index 81a5a1bf527..84297557707 100644 --- a/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb +++ b/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb @@ -17,6 +17,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -26,12 +27,15 @@ "\n", "https://www.minicircuits.com/softwaredownload/rfswitchcontroller.html\n", "\n", - "Download .NET dll and save somewhere. Unblock it (right click properties) and specify the path." + "Download .NET dll and save somewhere. Unblock it (right click properties) and specify the path.\n", + "\n", + "The downloaded ZIP file contains two DLLs. We recommend using mcl_RF_Switch_Controller_NET45.dll\n", + "which supports the most recent .net versions. " ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -45,7 +49,7 @@ "source": [ "dev = USB_SPDT('test',\n", " serial_number='11703020018',\n", - " driver_path= r'C:\\Users\\a-dovoge\\Qcodes\\qcodes\\instrument_drivers\\Minicircuits\\mcl_RF_Switch_Controller64')" + " driver_path= r'C:\\Users\\a-dovoge\\Qcodes\\qcodes\\instrument_drivers\\Minicircuits\\mcl_RF_Switch_Controller_NET45')" ] }, { @@ -117,7 +121,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "qcodespip310", "language": "python", "name": "python3" }, @@ -131,10 +135,15 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]" }, "nbsphinx": { "execute": "never" + }, + "vscode": { + "interpreter": { + "hash": "2643ef1ecb4e72f15331668d402315679b29a004e65b7ec963f6cfe589581b49" + } } }, "nbformat": 4, From e091e3883d9624548ebbd00d74a10ecc198e0b13 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 18 Jan 2023 14:02:19 +0100 Subject: [PATCH 7/7] Add changelog for 4623 --- docs/changes/newsfragments/4623.improved_driver | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/newsfragments/4623.improved_driver diff --git a/docs/changes/newsfragments/4623.improved_driver b/docs/changes/newsfragments/4623.improved_driver new file mode 100644 index 00000000000..1f4fc44a0e0 --- /dev/null +++ b/docs/changes/newsfragments/4623.improved_driver @@ -0,0 +1 @@ +The Minicircuits USB SPDT driver now supports running with the more modern version of the driver DLL `mcl_RF_Switch_Controller_NET45.dll`