We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Migrating Prologix / AR488 from 0.10. to 0.11. VI_ERROR_RSRC_NFOUND 
Hi, I'm having an issue after updating to 0.11, I understand that the implementation of the PrologixAdapter has changed, previously I was creating an adapter with this code:

`adapter = PrologixAdapter(port='/dev/cu.usbserial-AC008NYI',baudrate=115200,serial_timeout=1)`
now this doesn't work anymore and as far as I understand from the tutorial it should be updated to:
`adapter = PrologixAdapter('/dev/cu.usbserial-AC008NYI')`

This doesn't work and cannot find a solution, this is the error that I get:
`---------------------------------------------------------------------------
VisaIOError                               Traceback (most recent call last)
/var/folders/s_/k_qsdmpn09ng7xgzq1lrkjbm0000gn/T/ipykernel_13441/652802221.py in <module>
      6 import math
      7 import time
----> 8 adapter = PrologixAdapter('/dev/cu.usbserial-AC008NYI')
      9 #adapter = PrologixAdapter(port='/dev/cu.usbserial-AC008NYI',baudrate=115200,serial_timeout=1)
     10 sourcemeter = Keithley2000(adapter.gpib(16))

~/opt/anaconda3/lib/python3.9/site-packages/pymeasure/adapters/prologix.py in __init__(self, resource_name, address, rw_delay, serial_timeout, preprocess_reply, **kwargs)
     82             warn("Use 'timeout' in ms instead", FutureWarning)
     83             kwargs['timeout'] = serial_timeout
---> 84         super().__init__(resource_name,
     85                          asrl={
     86                              'timeout': 500,

~/opt/anaconda3/lib/python3.9/site-packages/pymeasure/adapters/visa.py in __init__(self, resource_name, visa_library, preprocess_reply, query_delay, log, **kwargs)
    106 
    107         # Clean up kwargs considering the interface type matching resource_name
--> 108         if_type = self.manager.resource_info(self.resource_name).interface_type
    109         for key in list(kwargs.keys()):  # iterate over a copy of the keys as we modify kwargs
    110             # Remove all interface-specific kwargs:

~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/highlevel.py in resource_info(self, resource_name, extended)
   3172 
   3173         if extended:
-> 3174             ret, err = self.visalib.parse_resource_extended(self.session, resource_name)
   3175         else:
   3176             ret, err = self.visalib.parse_resource(self.session, resource_name)

~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/ctwrapper/functions.py in parse_resource_extended(library, session, resource_name)
   2075     # [ViSession, ViRsrc, ViPUInt16, ViPUInt16, ViAChar, ViAChar, ViAChar]
   2076     # ViRsrc converts from (str, unicode, bytes) to bytes
-> 2077     ret = library.viParseRsrcEx(
   2078         session,
   2079         resource_name,

~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/ctwrapper/highlevel.py in _return_handler(self, ret_value, func, arguments)
    224                 session = None
    225 
--> 226         return self.handle_return_value(session, ret_value)  # type: ignore
    227 
    228     def list_resources(

~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/highlevel.py in handle_return_value(self, session, status_code)
    249 
    250         if rv < 0:
--> 251             raise errors.VisaIOError(rv)
    252 
    253         if rv in self.issue_warning_on:

VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system.`

Thanks for the help! 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pymeasure/adapters/prologix.py`
Content:
```
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2022 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 import time
25 from warnings import warn
26 
27 from pymeasure.adapters import VISAAdapter
28 
29 
30 class PrologixAdapter(VISAAdapter):
31     """ Encapsulates the additional commands necessary
32     to communicate over a Prologix GPIB-USB Adapter,
33     using the :class:`VISAAdapter`.
34 
35     Each PrologixAdapter is constructed based on a serial port or
36     connection and the GPIB address to be communicated to.
37     Serial connection sharing is achieved by using the :meth:`.gpib`
38     method to spawn new PrologixAdapters for different GPIB addresses.
39 
40     :param port: The Serial port name or a connection object
41     :param address: Integer GPIB address of the desired instrument
42     :param rw_delay: An optional delay to set between a write and read call for
43         slow to respond instruments.
44 
45         .. deprecated:: 0.11
46             Implement it in the instrument's `wait_until_read` method instead.
47 
48     :param preprocess_reply: optional callable used to preprocess
49         strings received from the instrument. The callable returns the
50         processed string.
51 
52         .. deprecated:: 0.11
53             Implement it in the instrument's `read` method instead.
54 
55     :param kwargs: Key-word arguments if constructing a new serial object
56 
57     :ivar address: Integer GPIB address of the desired instrument
58 
59     To allow user access to the Prologix adapter in Linux, create the file:
60     :code:`/etc/udev/rules.d/51-prologix.rules`, with contents:
61 
62     .. code-block:: bash
63 
64         SUBSYSTEMS=="usb",ATTRS{idVendor}=="0403",ATTRS{idProduct}=="6001",MODE="0666"
65 
66     Then reload the udev rules with:
67 
68     .. code-block:: bash
69 
70         sudo udevadm control --reload-rules
71         sudo udevadm trigger
72 
73     """
74 
75     def __init__(self, resource_name, address=None, rw_delay=0, serial_timeout=None,
76                  preprocess_reply=None, **kwargs):
77         # for legacy rw_delay: prefer new style over old one.
78         if rw_delay:
79             warn("Implement in Instrument's 'wait_until_read' instead.", FutureWarning)
80             kwargs['query_delay'] = rw_delay
81         if serial_timeout:
82             warn("Use 'timeout' in ms instead", FutureWarning)
83             kwargs['timeout'] = serial_timeout
84         super().__init__(resource_name,
85                          asrl={
86                              'timeout': 500,
87                              'write_termination': "\n",
88                          },
89                          preprocess_reply=preprocess_reply,
90                          **kwargs)
91         self.address = address
92         if not isinstance(resource_name, PrologixAdapter):
93             self.set_defaults()
94 
95     def set_defaults(self):
96         """ Set up the default behavior of the Prologix-GPIB
97         adapter
98         """
99         self.write("++auto 0")  # Turn off auto read-after-write
100         self.write("++eoi 1")  # Append end-of-line to commands
101         self.write("++eos 2")  # Append line-feed to commands
102 
103     def ask(self, command):
104         """ Ask the Prologix controller.
105 
106         .. deprecated:: 0.11
107            Call `Instrument.ask` instead.
108 
109         :param command: SCPI command string to be sent to instrument
110         """
111         warn("Do not call `Adapter.ask`, but `Instrument.ask` instead.",
112              FutureWarning)
113         self.write(command)
114         return self.read()
115 
116     def write(self, command, **kwargs):
117         """Write a string command to the instrument appending `write_termination`.
118 
119         If the GPIB address in :attr:`.address` is defined, it is sent first.
120 
121         :param str command: Command string to be sent to the instrument
122             (without termination).
123         :param kwargs: Keyword arguments for the connection itself.
124         """
125         # Overrides write instead of _write in order to ensure proper logging
126         if self.address is not None and not command.startswith("++"):
127             super().write("++addr %d" % self.address, **kwargs)
128         super().write(command, **kwargs)
129 
130     def _format_binary_values(self, values, datatype='f', is_big_endian=False, header_fmt="ieee"):
131         """Format values in binary format, used internally in :meth:`.write_binary_values`.
132 
133         :param values: data to be writen to the device.
134         :param datatype: the format string for a single element. See struct module.
135         :param is_big_endian: boolean indicating endianess.
136         :param header_fmt: Format of the header prefixing the data ("ieee", "hp", "empty").
137         :return: binary string.
138         :rtype: bytes
139         """
140         block = super()._format_binary_values(values, datatype, is_big_endian, header_fmt)
141         # Prologix needs certian characters to be escaped.
142         # Special care must be taken when sending binary data to instruments. If any of the
143         # following characters occur in the binary data -- CR (ASCII 13), LF (ASCII 10), ESC
144         # (ASCII 27), '+' (ASCII 43) - they must be escaped by preceding them with an ESC
145         # character.
146         special_chars = b'\x0d\x0a\x1b\x2b'
147         new_block = b''
148         for b in block:
149             escape = b''
150             if b in special_chars:
151                 escape = b'\x1b'
152             new_block += (escape + bytes((b,)))
153 
154         return new_block
155 
156     def write_binary_values(self, command, values, **kwargs):
157         """ Write binary data to the instrument, e.g. waveform for signal generators.
158 
159         values are encoded in a binary format according to
160         IEEE 488.2 Definite Length Arbitrary Block Response Data block.
161 
162         :param command: SCPI command to be sent to the instrument
163         :param values: iterable representing the binary values
164         :param kwargs: Key-word arguments to pass onto :meth:`._format_binary_values`
165         :returns: number of bytes written
166         """
167         if self.address is not None:
168             address_command = "++addr %d\n" % self.address
169             self.write(address_command)
170         super().write_binary_values(command, values, "\n", **kwargs)
171 
172     def _read(self, **kwargs):
173         """Read up to (excluding) `read_termination` or the whole read buffer.
174 
175         :param kwargs: Keyword arguments for the connection itself.
176         :returns str: ASCII response of the instrument (excluding read_termination).
177         """
178         self.write("++read eoi")
179         return super()._read()
180 
181     def gpib(self, address, **kwargs):
182         """ Return a PrologixAdapter object that references the GPIB
183         address specified, while sharing the Serial connection with other
184         calls of this function
185 
186         :param address: Integer GPIB address of the desired instrument
187         :param kwargs: Arguments for the initialization
188         :returns: PrologixAdapter for specific GPIB address
189         """
190         return PrologixAdapter(self, address, **kwargs)
191 
192     def _check_for_srq(self):
193         # it was int(self.ask("++srq"))
194         self.write("++srq")
195         return int(self.read())
196 
197     def wait_for_srq(self, timeout=25, delay=0.1):
198         """ Blocks until a SRQ, and leaves the bit high
199 
200         :param timeout: Timeout duration in seconds.
201         :param delay: Time delay between checking SRQ in seconds.
202         :raises TimeoutError: "Waiting for SRQ timed out."
203         """
204         stop = time.perf_counter() + timeout
205         while self._check_for_srq() != 1:
206             if time.perf_counter() > stop:
207                 raise TimeoutError("Waiting for SRQ timed out.")
208             time.sleep(delay)
209 
210     def __repr__(self):
211         if self.address is not None:
212             return (f"<PrologixAdapter(resource_name='{self.connection.resource_name}', "
213                     f"address={self.address:d})>")
214         else:
215             return f"<PrologixAdapter(resource_name='{self.connection.resource_name}')>"
216
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pymeasure/adapters/prologix.py b/pymeasure/adapters/prologix.py
--- a/pymeasure/adapters/prologix.py
+++ b/pymeasure/adapters/prologix.py
@@ -32,13 +32,16 @@
     to communicate over a Prologix GPIB-USB Adapter,
     using the :class:`VISAAdapter`.
 
-    Each PrologixAdapter is constructed based on a serial port or
-    connection and the GPIB address to be communicated to.
-    Serial connection sharing is achieved by using the :meth:`.gpib`
+    Each PrologixAdapter is constructed based on a connection to the Prologix device
+    itself and the GPIB address of the instrument to be communicated to.
+    Connection sharing is achieved by using the :meth:`.gpib`
     method to spawn new PrologixAdapters for different GPIB addresses.
 
-    :param port: The Serial port name or a connection object
-    :param address: Integer GPIB address of the desired instrument
+    :param resource_name: A
+        `VISA resource string <https://pyvisa.readthedocs.io/en/latest/introduction/names.html>`__
+        that identifies the connection to the Prologix device itself, for example
+        "ASRL5" for the 5th COM port.
+    :param address: Integer GPIB address of the desired instrument.
     :param rw_delay: An optional delay to set between a write and read call for
         slow to respond instruments.
 
@@ -54,7 +57,18 @@
 
     :param kwargs: Key-word arguments if constructing a new serial object
 
-    :ivar address: Integer GPIB address of the desired instrument
+    :ivar address: Integer GPIB address of the desired instrument.
+
+    Usage example:
+
+    .. code::
+
+        adapter = PrologixAdapter("ASRL5::INSTR", 7)
+        sourcemeter = Keithley2400(adapter)  # at GPIB address 7
+        # generate another instance with a different GPIB address:
+        adapter2 = adapter.gpib(9)
+        multimeter = Keithley2000(adapter2)  # at GPIB address 9
+
 
     To allow user access to the Prologix adapter in Linux, create the file:
     :code:`/etc/udev/rules.d/51-prologix.rules`, with contents:

{"golden_diff": "diff --git a/pymeasure/adapters/prologix.py b/pymeasure/adapters/prologix.py\n--- a/pymeasure/adapters/prologix.py\n+++ b/pymeasure/adapters/prologix.py\n@@ -32,13 +32,16 @@\n     to communicate over a Prologix GPIB-USB Adapter,\n     using the :class:`VISAAdapter`.\n \n-    Each PrologixAdapter is constructed based on a serial port or\n-    connection and the GPIB address to be communicated to.\n-    Serial connection sharing is achieved by using the :meth:`.gpib`\n+    Each PrologixAdapter is constructed based on a connection to the Prologix device\n+    itself and the GPIB address of the instrument to be communicated to.\n+    Connection sharing is achieved by using the :meth:`.gpib`\n     method to spawn new PrologixAdapters for different GPIB addresses.\n \n-    :param port: The Serial port name or a connection object\n-    :param address: Integer GPIB address of the desired instrument\n+    :param resource_name: A\n+        `VISA resource string <https://pyvisa.readthedocs.io/en/latest/introduction/names.html>`__\n+        that identifies the connection to the Prologix device itself, for example\n+        \"ASRL5\" for the 5th COM port.\n+    :param address: Integer GPIB address of the desired instrument.\n     :param rw_delay: An optional delay to set between a write and read call for\n         slow to respond instruments.\n \n@@ -54,7 +57,18 @@\n \n     :param kwargs: Key-word arguments if constructing a new serial object\n \n-    :ivar address: Integer GPIB address of the desired instrument\n+    :ivar address: Integer GPIB address of the desired instrument.\n+\n+    Usage example:\n+\n+    .. code::\n+\n+        adapter = PrologixAdapter(\"ASRL5::INSTR\", 7)\n+        sourcemeter = Keithley2400(adapter)  # at GPIB address 7\n+        # generate another instance with a different GPIB address:\n+        adapter2 = adapter.gpib(9)\n+        multimeter = Keithley2000(adapter2)  # at GPIB address 9\n+\n \n     To allow user access to the Prologix adapter in Linux, create the file:\n     :code:`/etc/udev/rules.d/51-prologix.rules`, with contents:\n", "issue": "Migrating Prologix / AR488 from 0.10. to 0.11. VI_ERROR_RSRC_NFOUND \nHi, I'm having an issue after updating to 0.11, I understand that the implementation of the PrologixAdapter has changed, previously I was creating an adapter with this code:\r\n\r\n`adapter = PrologixAdapter(port='/dev/cu.usbserial-AC008NYI',baudrate=115200,serial_timeout=1)`\r\nnow this doesn't work anymore and as far as I understand from the tutorial it should be updated to:\r\n`adapter = PrologixAdapter('/dev/cu.usbserial-AC008NYI')`\r\n\r\nThis doesn't work and cannot find a solution, this is the error that I get:\r\n`---------------------------------------------------------------------------\r\nVisaIOError                               Traceback (most recent call last)\r\n/var/folders/s_/k_qsdmpn09ng7xgzq1lrkjbm0000gn/T/ipykernel_13441/652802221.py in <module>\r\n      6 import math\r\n      7 import time\r\n----> 8 adapter = PrologixAdapter('/dev/cu.usbserial-AC008NYI')\r\n      9 #adapter = PrologixAdapter(port='/dev/cu.usbserial-AC008NYI',baudrate=115200,serial_timeout=1)\r\n     10 sourcemeter = Keithley2000(adapter.gpib(16))\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pymeasure/adapters/prologix.py in __init__(self, resource_name, address, rw_delay, serial_timeout, preprocess_reply, **kwargs)\r\n     82             warn(\"Use 'timeout' in ms instead\", FutureWarning)\r\n     83             kwargs['timeout'] = serial_timeout\r\n---> 84         super().__init__(resource_name,\r\n     85                          asrl={\r\n     86                              'timeout': 500,\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pymeasure/adapters/visa.py in __init__(self, resource_name, visa_library, preprocess_reply, query_delay, log, **kwargs)\r\n    106 \r\n    107         # Clean up kwargs considering the interface type matching resource_name\r\n--> 108         if_type = self.manager.resource_info(self.resource_name).interface_type\r\n    109         for key in list(kwargs.keys()):  # iterate over a copy of the keys as we modify kwargs\r\n    110             # Remove all interface-specific kwargs:\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/highlevel.py in resource_info(self, resource_name, extended)\r\n   3172 \r\n   3173         if extended:\r\n-> 3174             ret, err = self.visalib.parse_resource_extended(self.session, resource_name)\r\n   3175         else:\r\n   3176             ret, err = self.visalib.parse_resource(self.session, resource_name)\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/ctwrapper/functions.py in parse_resource_extended(library, session, resource_name)\r\n   2075     # [ViSession, ViRsrc, ViPUInt16, ViPUInt16, ViAChar, ViAChar, ViAChar]\r\n   2076     # ViRsrc converts from (str, unicode, bytes) to bytes\r\n-> 2077     ret = library.viParseRsrcEx(\r\n   2078         session,\r\n   2079         resource_name,\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/ctwrapper/highlevel.py in _return_handler(self, ret_value, func, arguments)\r\n    224                 session = None\r\n    225 \r\n--> 226         return self.handle_return_value(session, ret_value)  # type: ignore\r\n    227 \r\n    228     def list_resources(\r\n\r\n~/opt/anaconda3/lib/python3.9/site-packages/pyvisa/highlevel.py in handle_return_value(self, session, status_code)\r\n    249 \r\n    250         if rv < 0:\r\n--> 251             raise errors.VisaIOError(rv)\r\n    252 \r\n    253         if rv in self.issue_warning_on:\r\n\r\nVisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system.`\r\n\r\nThanks for the help! \n", "before_files": [{"content": "#\n# This file is part of the PyMeasure package.\n#\n# Copyright (c) 2013-2022 PyMeasure Developers\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\n#\nimport time\nfrom warnings import warn\n\nfrom pymeasure.adapters import VISAAdapter\n\n\nclass PrologixAdapter(VISAAdapter):\n    \"\"\" Encapsulates the additional commands necessary\n    to communicate over a Prologix GPIB-USB Adapter,\n    using the :class:`VISAAdapter`.\n\n    Each PrologixAdapter is constructed based on a serial port or\n    connection and the GPIB address to be communicated to.\n    Serial connection sharing is achieved by using the :meth:`.gpib`\n    method to spawn new PrologixAdapters for different GPIB addresses.\n\n    :param port: The Serial port name or a connection object\n    :param address: Integer GPIB address of the desired instrument\n    :param rw_delay: An optional delay to set between a write and read call for\n        slow to respond instruments.\n\n        .. deprecated:: 0.11\n            Implement it in the instrument's `wait_until_read` method instead.\n\n    :param preprocess_reply: optional callable used to preprocess\n        strings received from the instrument. The callable returns the\n        processed string.\n\n        .. deprecated:: 0.11\n            Implement it in the instrument's `read` method instead.\n\n    :param kwargs: Key-word arguments if constructing a new serial object\n\n    :ivar address: Integer GPIB address of the desired instrument\n\n    To allow user access to the Prologix adapter in Linux, create the file:\n    :code:`/etc/udev/rules.d/51-prologix.rules`, with contents:\n\n    .. code-block:: bash\n\n        SUBSYSTEMS==\"usb\",ATTRS{idVendor}==\"0403\",ATTRS{idProduct}==\"6001\",MODE=\"0666\"\n\n    Then reload the udev rules with:\n\n    .. code-block:: bash\n\n        sudo udevadm control --reload-rules\n        sudo udevadm trigger\n\n    \"\"\"\n\n    def __init__(self, resource_name, address=None, rw_delay=0, serial_timeout=None,\n                 preprocess_reply=None, **kwargs):\n        # for legacy rw_delay: prefer new style over old one.\n        if rw_delay:\n            warn(\"Implement in Instrument's 'wait_until_read' instead.\", FutureWarning)\n            kwargs['query_delay'] = rw_delay\n        if serial_timeout:\n            warn(\"Use 'timeout' in ms instead\", FutureWarning)\n            kwargs['timeout'] = serial_timeout\n        super().__init__(resource_name,\n                         asrl={\n                             'timeout': 500,\n                             'write_termination': \"\\n\",\n                         },\n                         preprocess_reply=preprocess_reply,\n                         **kwargs)\n        self.address = address\n        if not isinstance(resource_name, PrologixAdapter):\n            self.set_defaults()\n\n    def set_defaults(self):\n        \"\"\" Set up the default behavior of the Prologix-GPIB\n        adapter\n        \"\"\"\n        self.write(\"++auto 0\")  # Turn off auto read-after-write\n        self.write(\"++eoi 1\")  # Append end-of-line to commands\n        self.write(\"++eos 2\")  # Append line-feed to commands\n\n    def ask(self, command):\n        \"\"\" Ask the Prologix controller.\n\n        .. deprecated:: 0.11\n           Call `Instrument.ask` instead.\n\n        :param command: SCPI command string to be sent to instrument\n        \"\"\"\n        warn(\"Do not call `Adapter.ask`, but `Instrument.ask` instead.\",\n             FutureWarning)\n        self.write(command)\n        return self.read()\n\n    def write(self, command, **kwargs):\n        \"\"\"Write a string command to the instrument appending `write_termination`.\n\n        If the GPIB address in :attr:`.address` is defined, it is sent first.\n\n        :param str command: Command string to be sent to the instrument\n            (without termination).\n        :param kwargs: Keyword arguments for the connection itself.\n        \"\"\"\n        # Overrides write instead of _write in order to ensure proper logging\n        if self.address is not None and not command.startswith(\"++\"):\n            super().write(\"++addr %d\" % self.address, **kwargs)\n        super().write(command, **kwargs)\n\n    def _format_binary_values(self, values, datatype='f', is_big_endian=False, header_fmt=\"ieee\"):\n        \"\"\"Format values in binary format, used internally in :meth:`.write_binary_values`.\n\n        :param values: data to be writen to the device.\n        :param datatype: the format string for a single element. See struct module.\n        :param is_big_endian: boolean indicating endianess.\n        :param header_fmt: Format of the header prefixing the data (\"ieee\", \"hp\", \"empty\").\n        :return: binary string.\n        :rtype: bytes\n        \"\"\"\n        block = super()._format_binary_values(values, datatype, is_big_endian, header_fmt)\n        # Prologix needs certian characters to be escaped.\n        # Special care must be taken when sending binary data to instruments. If any of the\n        # following characters occur in the binary data -- CR (ASCII 13), LF (ASCII 10), ESC\n        # (ASCII 27), '+' (ASCII 43) - they must be escaped by preceding them with an ESC\n        # character.\n        special_chars = b'\\x0d\\x0a\\x1b\\x2b'\n        new_block = b''\n        for b in block:\n            escape = b''\n            if b in special_chars:\n                escape = b'\\x1b'\n            new_block += (escape + bytes((b,)))\n\n        return new_block\n\n    def write_binary_values(self, command, values, **kwargs):\n        \"\"\" Write binary data to the instrument, e.g. waveform for signal generators.\n\n        values are encoded in a binary format according to\n        IEEE 488.2 Definite Length Arbitrary Block Response Data block.\n\n        :param command: SCPI command to be sent to the instrument\n        :param values: iterable representing the binary values\n        :param kwargs: Key-word arguments to pass onto :meth:`._format_binary_values`\n        :returns: number of bytes written\n        \"\"\"\n        if self.address is not None:\n            address_command = \"++addr %d\\n\" % self.address\n            self.write(address_command)\n        super().write_binary_values(command, values, \"\\n\", **kwargs)\n\n    def _read(self, **kwargs):\n        \"\"\"Read up to (excluding) `read_termination` or the whole read buffer.\n\n        :param kwargs: Keyword arguments for the connection itself.\n        :returns str: ASCII response of the instrument (excluding read_termination).\n        \"\"\"\n        self.write(\"++read eoi\")\n        return super()._read()\n\n    def gpib(self, address, **kwargs):\n        \"\"\" Return a PrologixAdapter object that references the GPIB\n        address specified, while sharing the Serial connection with other\n        calls of this function\n\n        :param address: Integer GPIB address of the desired instrument\n        :param kwargs: Arguments for the initialization\n        :returns: PrologixAdapter for specific GPIB address\n        \"\"\"\n        return PrologixAdapter(self, address, **kwargs)\n\n    def _check_for_srq(self):\n        # it was int(self.ask(\"++srq\"))\n        self.write(\"++srq\")\n        return int(self.read())\n\n    def wait_for_srq(self, timeout=25, delay=0.1):\n        \"\"\" Blocks until a SRQ, and leaves the bit high\n\n        :param timeout: Timeout duration in seconds.\n        :param delay: Time delay between checking SRQ in seconds.\n        :raises TimeoutError: \"Waiting for SRQ timed out.\"\n        \"\"\"\n        stop = time.perf_counter() + timeout\n        while self._check_for_srq() != 1:\n            if time.perf_counter() > stop:\n                raise TimeoutError(\"Waiting for SRQ timed out.\")\n            time.sleep(delay)\n\n    def __repr__(self):\n        if self.address is not None:\n            return (f\"<PrologixAdapter(resource_name='{self.connection.resource_name}', \"\n                    f\"address={self.address:d})>\")\n        else:\n            return f\"<PrologixAdapter(resource_name='{self.connection.resource_name}')>\"\n", "path": "pymeasure/adapters/prologix.py"}], "after_files": [{"content": "#\n# This file is part of the PyMeasure package.\n#\n# Copyright (c) 2013-2022 PyMeasure Developers\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\n#\nimport time\nfrom warnings import warn\n\nfrom pymeasure.adapters import VISAAdapter\n\n\nclass PrologixAdapter(VISAAdapter):\n    \"\"\" Encapsulates the additional commands necessary\n    to communicate over a Prologix GPIB-USB Adapter,\n    using the :class:`VISAAdapter`.\n\n    Each PrologixAdapter is constructed based on a connection to the Prologix device\n    itself and the GPIB address of the instrument to be communicated to.\n    Connection sharing is achieved by using the :meth:`.gpib`\n    method to spawn new PrologixAdapters for different GPIB addresses.\n\n    :param resource_name: A\n        `VISA resource string <https://pyvisa.readthedocs.io/en/latest/introduction/names.html>`__\n        that identifies the connection to the Prologix device itself, for example\n        \"ASRL5\" for the 5th COM port.\n    :param address: Integer GPIB address of the desired instrument.\n    :param rw_delay: An optional delay to set between a write and read call for\n        slow to respond instruments.\n\n        .. deprecated:: 0.11\n            Implement it in the instrument's `wait_until_read` method instead.\n\n    :param preprocess_reply: optional callable used to preprocess\n        strings received from the instrument. The callable returns the\n        processed string.\n\n        .. deprecated:: 0.11\n            Implement it in the instrument's `read` method instead.\n\n    :param kwargs: Key-word arguments if constructing a new serial object\n\n    :ivar address: Integer GPIB address of the desired instrument.\n\n    Usage example:\n\n    .. code::\n\n        adapter = PrologixAdapter(\"ASRL5::INSTR\", 7)\n        sourcemeter = Keithley2400(adapter)  # at GPIB address 7\n        # generate another instance with a different GPIB address:\n        adapter2 = adapter.gpib(9)\n        multimeter = Keithley2000(adapter2)  # at GPIB address 9\n\n\n    To allow user access to the Prologix adapter in Linux, create the file:\n    :code:`/etc/udev/rules.d/51-prologix.rules`, with contents:\n\n    .. code-block:: bash\n\n        SUBSYSTEMS==\"usb\",ATTRS{idVendor}==\"0403\",ATTRS{idProduct}==\"6001\",MODE=\"0666\"\n\n    Then reload the udev rules with:\n\n    .. code-block:: bash\n\n        sudo udevadm control --reload-rules\n        sudo udevadm trigger\n\n    \"\"\"\n\n    def __init__(self, resource_name, address=None, rw_delay=0, serial_timeout=None,\n                 preprocess_reply=None, **kwargs):\n        # for legacy rw_delay: prefer new style over old one.\n        if rw_delay:\n            warn(\"Implement in Instrument's 'wait_until_read' instead.\", FutureWarning)\n            kwargs['query_delay'] = rw_delay\n        if serial_timeout:\n            warn(\"Use 'timeout' in ms instead\", FutureWarning)\n            kwargs['timeout'] = serial_timeout\n        super().__init__(resource_name,\n                         asrl={\n                             'timeout': 500,\n                             'write_termination': \"\\n\",\n                         },\n                         preprocess_reply=preprocess_reply,\n                         **kwargs)\n        self.address = address\n        if not isinstance(resource_name, PrologixAdapter):\n            self.set_defaults()\n\n    def set_defaults(self):\n        \"\"\" Set up the default behavior of the Prologix-GPIB\n        adapter\n        \"\"\"\n        self.write(\"++auto 0\")  # Turn off auto read-after-write\n        self.write(\"++eoi 1\")  # Append end-of-line to commands\n        self.write(\"++eos 2\")  # Append line-feed to commands\n\n    def ask(self, command):\n        \"\"\" Ask the Prologix controller.\n\n        .. deprecated:: 0.11\n           Call `Instrument.ask` instead.\n\n        :param command: SCPI command string to be sent to instrument\n        \"\"\"\n        warn(\"Do not call `Adapter.ask`, but `Instrument.ask` instead.\",\n             FutureWarning)\n        self.write(command)\n        return self.read()\n\n    def write(self, command, **kwargs):\n        \"\"\"Write a string command to the instrument appending `write_termination`.\n\n        If the GPIB address in :attr:`.address` is defined, it is sent first.\n\n        :param str command: Command string to be sent to the instrument\n            (without termination).\n        :param kwargs: Keyword arguments for the connection itself.\n        \"\"\"\n        # Overrides write instead of _write in order to ensure proper logging\n        if self.address is not None and not command.startswith(\"++\"):\n            super().write(\"++addr %d\" % self.address, **kwargs)\n        super().write(command, **kwargs)\n\n    def _format_binary_values(self, values, datatype='f', is_big_endian=False, header_fmt=\"ieee\"):\n        \"\"\"Format values in binary format, used internally in :meth:`.write_binary_values`.\n\n        :param values: data to be writen to the device.\n        :param datatype: the format string for a single element. See struct module.\n        :param is_big_endian: boolean indicating endianess.\n        :param header_fmt: Format of the header prefixing the data (\"ieee\", \"hp\", \"empty\").\n        :return: binary string.\n        :rtype: bytes\n        \"\"\"\n        block = super()._format_binary_values(values, datatype, is_big_endian, header_fmt)\n        # Prologix needs certian characters to be escaped.\n        # Special care must be taken when sending binary data to instruments. If any of the\n        # following characters occur in the binary data -- CR (ASCII 13), LF (ASCII 10), ESC\n        # (ASCII 27), '+' (ASCII 43) - they must be escaped by preceding them with an ESC\n        # character.\n        special_chars = b'\\x0d\\x0a\\x1b\\x2b'\n        new_block = b''\n        for b in block:\n            escape = b''\n            if b in special_chars:\n                escape = b'\\x1b'\n            new_block += (escape + bytes((b,)))\n\n        return new_block\n\n    def write_binary_values(self, command, values, **kwargs):\n        \"\"\" Write binary data to the instrument, e.g. waveform for signal generators.\n\n        values are encoded in a binary format according to\n        IEEE 488.2 Definite Length Arbitrary Block Response Data block.\n\n        :param command: SCPI command to be sent to the instrument\n        :param values: iterable representing the binary values\n        :param kwargs: Key-word arguments to pass onto :meth:`._format_binary_values`\n        :returns: number of bytes written\n        \"\"\"\n        if self.address is not None:\n            address_command = \"++addr %d\\n\" % self.address\n            self.write(address_command)\n        super().write_binary_values(command, values, \"\\n\", **kwargs)\n\n    def _read(self, **kwargs):\n        \"\"\"Read up to (excluding) `read_termination` or the whole read buffer.\n\n        :param kwargs: Keyword arguments for the connection itself.\n        :returns str: ASCII response of the instrument (excluding read_termination).\n        \"\"\"\n        self.write(\"++read eoi\")\n        return super()._read()\n\n    def gpib(self, address, **kwargs):\n        \"\"\" Return a PrologixAdapter object that references the GPIB\n        address specified, while sharing the Serial connection with other\n        calls of this function\n\n        :param address: Integer GPIB address of the desired instrument\n        :param kwargs: Arguments for the initialization\n        :returns: PrologixAdapter for specific GPIB address\n        \"\"\"\n        return PrologixAdapter(self, address, **kwargs)\n\n    def _check_for_srq(self):\n        # it was int(self.ask(\"++srq\"))\n        self.write(\"++srq\")\n        return int(self.read())\n\n    def wait_for_srq(self, timeout=25, delay=0.1):\n        \"\"\" Blocks until a SRQ, and leaves the bit high\n\n        :param timeout: Timeout duration in seconds.\n        :param delay: Time delay between checking SRQ in seconds.\n        :raises TimeoutError: \"Waiting for SRQ timed out.\"\n        \"\"\"\n        stop = time.perf_counter() + timeout\n        while self._check_for_srq() != 1:\n            if time.perf_counter() > stop:\n                raise TimeoutError(\"Waiting for SRQ timed out.\")\n            time.sleep(delay)\n\n    def __repr__(self):\n        if self.address is not None:\n            return (f\"<PrologixAdapter(resource_name='{self.connection.resource_name}', \"\n                    f\"address={self.address:d})>\")\n        else:\n            return f\"<PrologixAdapter(resource_name='{self.connection.resource_name}')>\"\n", "path": "pymeasure/adapters/prologix.py"}]}