QInstrument 2.3.2__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qinstrument-2.3.2 → qinstrument-2.4.0}/PKG-INFO +1 -1
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/PKG-INFO +1 -1
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QInstrumentWorker.py +8 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QSerialInstrument.py +0 -8
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QSerialInterface.py +31 -9
- {qinstrument-2.3.2 → qinstrument-2.4.0}/pyproject.toml +1 -1
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QInstrumentWorker.py +2 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QSR830Worker.py +2 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QSerialInterface.py +20 -27
- {qinstrument-2.3.2 → qinstrument-2.4.0}/LICENSE.md +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/SOURCES.txt +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/dependency_links.txt +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/entry_points.txt +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/requires.txt +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrument.egg-info/top_level.txt +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/QInstrumentRack.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/README.md +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/__main__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/IPGLaserWidget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/IPGLaser/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/IPGPhotonics/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/OpusWidget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus1064/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus1064/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus1064/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus1064/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus1064/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus532/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus532/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus532/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus532/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus532/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus660/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus660/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus660/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus660/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/Opus660/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Novanta/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/PDUS210Widget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/PDUS210/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PiezoDrive/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/ProscanWidget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/DS345Widget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/DS345/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/SR830Widget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR830/worker.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/SR844Widget.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/fake.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/tree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/widget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/SR844/worker.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/StanfordResearch/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Tektronix/TDS1000/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Tektronix/TDS1000/instrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/Tektronix/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/Configure.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QAbstractInstrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QFakeInstrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QInstrumentTree.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QInstrumentWidget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/QReconcileDialog.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/__init__.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/lib/lazy.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/setup.cfg +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_Configure.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QAbstractInstrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QDS345.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QFakeInstrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QIPGLaser.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QInstrumentRack.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QInstrumentWidget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QLedWidget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QOpus.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QPDUS210.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QProscan.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QRotaryEncoderSpinBox.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QSR830.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QSR844.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/tests/test_QSerialInstrument.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QJoystick.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QJoystickPad.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QLedWidget.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QRotaryEncoder.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QRotaryEncoderSpinBox.py +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/QRotaryEncoderSpinBox.ui +0 -0
- {qinstrument-2.3.2 → qinstrument-2.4.0}/widgets/__init__.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import warnings
|
|
4
5
|
from qtpy import QtCore
|
|
5
6
|
|
|
6
7
|
logger = logging.getLogger(__name__)
|
|
@@ -43,6 +44,13 @@ class QInstrumentWorker(QtCore.QObject):
|
|
|
43
44
|
'''
|
|
44
45
|
|
|
45
46
|
def __init__(self, instrument, parent=None) -> None:
|
|
47
|
+
warnings.warn(
|
|
48
|
+
'QInstrumentWorker is deprecated and will be removed in a future '
|
|
49
|
+
'release. QSerialInterface.receive() no longer blocks the event '
|
|
50
|
+
'loop, so instrument polling does not require a worker thread.',
|
|
51
|
+
DeprecationWarning,
|
|
52
|
+
stacklevel=2
|
|
53
|
+
)
|
|
46
54
|
super().__init__(parent)
|
|
47
55
|
self._instrument = instrument
|
|
48
56
|
self._thread = QtCore.QThread()
|
|
@@ -133,14 +133,6 @@ class QSerialInstrument(QAbstractInstrument):
|
|
|
133
133
|
The instance itself, whether or not a device was found.
|
|
134
134
|
Call :meth:`isOpen` to check the result.
|
|
135
135
|
'''
|
|
136
|
-
# TODO: On macOS, Qt emits "QSocketNotifier: current thread's event
|
|
137
|
-
# dispatcher has already been destroyed" for each port tried here.
|
|
138
|
-
# Root cause: QSerialPort's POSIX backend uses QSocketNotifier, which
|
|
139
|
-
# requires a running event loop, but waitForReadyRead() uses select()
|
|
140
|
-
# directly and tears down the macOS CF dispatcher context on return.
|
|
141
|
-
# Fix: replace waitForReadyRead() in QSerialInterface.receive() with
|
|
142
|
-
# a QEventLoop + QTimer approach so notifiers always have an active
|
|
143
|
-
# dispatcher. Deferred due to re-entrancy considerations.
|
|
144
136
|
for port in QSerialPortInfo.availablePorts():
|
|
145
137
|
portName = port.portName()
|
|
146
138
|
logger.debug(f'Trying {portName}')
|
|
@@ -193,9 +193,13 @@ class QSerialInterface(QSerialPort):
|
|
|
193
193
|
'''Read from the serial interface until the end-of-line sequence.
|
|
194
194
|
|
|
195
195
|
Reads available data into a buffer until :attr:`eol` is found or
|
|
196
|
-
the read times out.
|
|
196
|
+
the read times out. The EOL bytes are stripped from the returned
|
|
197
197
|
value.
|
|
198
198
|
|
|
199
|
+
Waiting is performed via a local ``QEventLoop`` driven by
|
|
200
|
+
``readyRead`` and a ``QTimer``, so the main event loop remains
|
|
201
|
+
alive during the wait and the GUI stays responsive.
|
|
202
|
+
|
|
199
203
|
Parameters
|
|
200
204
|
----------
|
|
201
205
|
eol : str | bytes | None
|
|
@@ -216,16 +220,25 @@ class QSerialInterface(QSerialPort):
|
|
|
216
220
|
eol = eol.encode() if isinstance(eol, str) else eol
|
|
217
221
|
else:
|
|
218
222
|
eol = self.eol
|
|
223
|
+
loop = QtCore.QEventLoop()
|
|
224
|
+
timer = QtCore.QTimer()
|
|
225
|
+
timer.setSingleShot(True)
|
|
226
|
+
timer.timeout.connect(loop.quit)
|
|
227
|
+
self.readyRead.connect(loop.quit)
|
|
219
228
|
buffer = b''
|
|
220
229
|
while True:
|
|
221
|
-
if
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
230
|
+
if not self.bytesAvailable():
|
|
231
|
+
timer.start(self.timeout)
|
|
232
|
+
loop.exec()
|
|
233
|
+
timer.stop()
|
|
234
|
+
if not self.bytesAvailable():
|
|
235
|
+
logger.debug('Timeout waiting for response')
|
|
236
|
+
break
|
|
225
237
|
buffer += bytes(self.readAll())
|
|
226
238
|
if eol and eol in buffer:
|
|
227
239
|
buffer = buffer[:buffer.index(eol)]
|
|
228
240
|
break
|
|
241
|
+
self.readyRead.disconnect(loop.quit)
|
|
229
242
|
return buffer if raw else buffer.decode()
|
|
230
243
|
|
|
231
244
|
def readn(self, n: int = 1) -> bytes:
|
|
@@ -245,13 +258,22 @@ class QSerialInterface(QSerialPort):
|
|
|
245
258
|
if not self.isOpen():
|
|
246
259
|
logger.warning('Cannot read data: device is not open.')
|
|
247
260
|
return b''
|
|
261
|
+
loop = QtCore.QEventLoop()
|
|
262
|
+
timer = QtCore.QTimer()
|
|
263
|
+
timer.setSingleShot(True)
|
|
264
|
+
timer.timeout.connect(loop.quit)
|
|
265
|
+
self.readyRead.connect(loop.quit)
|
|
248
266
|
buffer = b''
|
|
249
267
|
while len(buffer) < n:
|
|
250
|
-
if
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
268
|
+
if not self.bytesAvailable():
|
|
269
|
+
timer.start(self.timeout)
|
|
270
|
+
loop.exec()
|
|
271
|
+
timer.stop()
|
|
272
|
+
if not self.bytesAvailable():
|
|
273
|
+
logger.warning('Timeout waiting for response')
|
|
274
|
+
break
|
|
254
275
|
buffer += bytes(self.readAll())
|
|
276
|
+
self.readyRead.disconnect(loop.quit)
|
|
255
277
|
return buffer[:n]
|
|
256
278
|
|
|
257
279
|
def sendbreak(self, duration: int = 250) -> None:
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "QInstrument"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.4.0"
|
|
8
8
|
description = "Qt-based framework for controlling scientific instruments over serial ports"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE.md" }
|
|
@@ -3,6 +3,8 @@ from qtpy import QtCore
|
|
|
3
3
|
from lib.QFakeInstrument import QFakeInstrument
|
|
4
4
|
from lib.QInstrumentWorker import QInstrumentWorker
|
|
5
5
|
|
|
6
|
+
pytestmark = pytest.mark.filterwarnings('ignore::DeprecationWarning')
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
# ---------------------------------------------------------------------------
|
|
8
10
|
# Helpers
|
|
@@ -3,6 +3,8 @@ from qtpy import QtCore
|
|
|
3
3
|
from instruments.StanfordResearch.SR830.fake import QFakeSR830
|
|
4
4
|
from instruments.StanfordResearch.SR830.worker import QSR830Worker
|
|
5
5
|
from instruments.StanfordResearch.SR844.fake import QFakeSR844
|
|
6
|
+
|
|
7
|
+
pytestmark = pytest.mark.filterwarnings('ignore::DeprecationWarning')
|
|
6
8
|
from instruments.StanfordResearch.SR844.worker import QSR844Worker
|
|
7
9
|
|
|
8
10
|
|
|
@@ -22,6 +22,12 @@ def iface_crlf(qtbot):
|
|
|
22
22
|
return QSerialInterface(eol='\r\n')
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
@pytest.fixture
|
|
26
|
+
def iface_fast(qtbot):
|
|
27
|
+
'''QSerialInterface with 1 ms timeout for timeout tests.'''
|
|
28
|
+
return QSerialInterface(eol='\n', timeout=1)
|
|
29
|
+
|
|
30
|
+
|
|
25
31
|
# ---------------------------------------------------------------------------
|
|
26
32
|
# Initialization
|
|
27
33
|
# ---------------------------------------------------------------------------
|
|
@@ -117,52 +123,42 @@ class TestReceive:
|
|
|
117
123
|
|
|
118
124
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
119
125
|
@patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\n')
|
|
120
|
-
|
|
121
|
-
def test_strips_eol(self, mock_wait, mock_read, mock_avail, iface):
|
|
126
|
+
def test_strips_eol(self, mock_read, mock_avail, iface):
|
|
122
127
|
assert iface.receive() == 'HELLO'
|
|
123
128
|
|
|
124
129
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
125
130
|
@patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\r\n')
|
|
126
|
-
|
|
127
|
-
def test_multibyte_eol_stripped(
|
|
128
|
-
self, mock_wait, mock_read, mock_avail, iface_crlf):
|
|
131
|
+
def test_multibyte_eol_stripped(self, mock_read, mock_avail, iface_crlf):
|
|
129
132
|
assert iface_crlf.receive() == 'HELLO'
|
|
130
133
|
|
|
131
134
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
132
135
|
@patch.object(QSerialInterface, 'readAll', return_value=b'HELLO\n')
|
|
133
|
-
|
|
134
|
-
def test_raw_returns_bytes(self, mock_wait, mock_read, mock_avail, iface):
|
|
136
|
+
def test_raw_returns_bytes(self, mock_read, mock_avail, iface):
|
|
135
137
|
assert iface.receive(raw=True) == b'HELLO'
|
|
136
138
|
|
|
137
139
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=False)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
assert iface.receive() == ''
|
|
140
|
+
def test_timeout_returns_empty_string(self, mock_avail, iface_fast):
|
|
141
|
+
assert iface_fast.receive() == ''
|
|
141
142
|
|
|
142
143
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=False)
|
|
143
|
-
|
|
144
|
-
def test_timeout_logs(self, mock_wait, mock_avail, iface, caplog):
|
|
144
|
+
def test_timeout_logs(self, mock_avail, iface_fast, caplog):
|
|
145
145
|
with caplog.at_level(logging.DEBUG):
|
|
146
|
-
|
|
146
|
+
iface_fast.receive()
|
|
147
147
|
assert 'Timeout' in caplog.text
|
|
148
148
|
|
|
149
149
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
150
150
|
@patch.object(QSerialInterface, 'readAll', return_value=b'DATA\r')
|
|
151
|
-
|
|
152
|
-
def test_override_eol(self, mock_wait, mock_read, mock_avail, iface):
|
|
151
|
+
def test_override_eol(self, mock_read, mock_avail, iface):
|
|
153
152
|
assert iface.receive(eol='\r') == 'DATA'
|
|
154
153
|
|
|
155
154
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
156
155
|
@patch.object(QSerialInterface, 'readAll', return_value=b'DATA\r')
|
|
157
|
-
|
|
158
|
-
def test_override_eol_as_bytes(self, mock_wait, mock_read, mock_avail, iface):
|
|
156
|
+
def test_override_eol_as_bytes(self, mock_read, mock_avail, iface):
|
|
159
157
|
assert iface.receive(eol=b'\r') == 'DATA'
|
|
160
158
|
|
|
161
159
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
162
160
|
@patch.object(QSerialInterface, 'readAll', return_value=b'A\nB\nC')
|
|
163
|
-
|
|
164
|
-
def test_returns_up_to_first_eol(
|
|
165
|
-
self, mock_wait, mock_read, mock_avail, iface):
|
|
161
|
+
def test_returns_up_to_first_eol(self, mock_read, mock_avail, iface):
|
|
166
162
|
assert iface.receive() == 'A'
|
|
167
163
|
|
|
168
164
|
|
|
@@ -174,27 +170,24 @@ class TestReadn:
|
|
|
174
170
|
|
|
175
171
|
@patch.object(QSerialInterface, 'isOpen', return_value=True)
|
|
176
172
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
177
|
-
@patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
|
|
178
173
|
@patch.object(QSerialInterface, 'readAll', return_value=b'ABCDE')
|
|
179
|
-
def test_trims_to_n(self, mock_read,
|
|
174
|
+
def test_trims_to_n(self, mock_read, mock_avail, mock_open, iface):
|
|
180
175
|
assert iface.readn(3) == b'ABC'
|
|
181
176
|
|
|
182
177
|
@patch.object(QSerialInterface, 'isOpen', return_value=True)
|
|
183
178
|
@patch.object(QSerialInterface, 'bytesAvailable', return_value=True)
|
|
184
|
-
@patch.object(QSerialInterface, 'waitForReadyRead', return_value=True)
|
|
185
179
|
@patch.object(QSerialInterface, 'readAll', return_value=b'AB')
|
|
186
|
-
def test_exact_match(self, mock_read,
|
|
180
|
+
def test_exact_match(self, mock_read, mock_avail, mock_open, iface):
|
|
187
181
|
assert iface.readn(2) == b'AB'
|
|
188
182
|
|
|
189
183
|
@patch.object(QSerialInterface, 'isOpen', return_value=True)
|
|
190
184
|
@patch.object(QSerialInterface, 'bytesAvailable',
|
|
191
185
|
side_effect=[True, False, False])
|
|
192
|
-
@patch.object(QSerialInterface, 'waitForReadyRead', return_value=False)
|
|
193
186
|
@patch.object(QSerialInterface, 'readAll', return_value=b'AB')
|
|
194
187
|
def test_timeout_returns_partial(
|
|
195
|
-
self, mock_read,
|
|
188
|
+
self, mock_read, mock_avail, mock_open, iface_fast, caplog):
|
|
196
189
|
with caplog.at_level(logging.WARNING):
|
|
197
|
-
result =
|
|
190
|
+
result = iface_fast.readn(5)
|
|
198
191
|
assert result == b'AB'
|
|
199
192
|
assert 'Timeout' in caplog.text
|
|
200
193
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{qinstrument-2.3.2 → qinstrument-2.4.0}/instruments/PriorScientific/Proscan/ProscanWidget.ui
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|