From 9794b7167fca3db72bbe04381a699478e8521f66 Mon Sep 17 00:00:00 2001 From: Steven Casagrande Date: Sat, 10 Jun 2017 20:03:49 -0400 Subject: [PATCH] Fix timeout and terminator for USBTMC --- .../abstract_instruments/comm/usbtmc_communicator.py | 4 ++-- instruments/tests/test_comm/test_usbtmc.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/instruments/abstract_instruments/comm/usbtmc_communicator.py b/instruments/abstract_instruments/comm/usbtmc_communicator.py index f465abba7..88855d4e5 100644 --- a/instruments/abstract_instruments/comm/usbtmc_communicator.py +++ b/instruments/abstract_instruments/comm/usbtmc_communicator.py @@ -54,7 +54,7 @@ def terminator(self): :type: `str` """ - return self._filelike.term_char + return chr(self._filelike.term_char) @terminator.setter def terminator(self, newval): @@ -78,7 +78,7 @@ def timeout(self): @timeout.setter def timeout(self, newval): - newval = assume_units(newval, pq.second).rescale(pq.ms).magnitude + newval = assume_units(newval, pq.second).rescale(pq.s).magnitude self._filelike.timeout = newval # FILE-LIKE METHODS # diff --git a/instruments/tests/test_comm/test_usbtmc.py b/instruments/tests/test_comm/test_usbtmc.py index 18e2ebcf7..da56749af 100644 --- a/instruments/tests/test_comm/test_usbtmc.py +++ b/instruments/tests/test_comm/test_usbtmc.py @@ -40,7 +40,7 @@ def test_usbtmccomm_init_missing_module(): def test_usbtmccomm_terminator_getter(mock_usbtmc): comm = USBTMCCommunicator() - term_char = mock.PropertyMock(return_value="\n") + term_char = mock.PropertyMock(return_value=10) type(comm._filelike).term_char = term_char eq_(comm.terminator, "\n") @@ -74,10 +74,10 @@ def test_usbtmccomm_timeout(mock_usbtmc): timeout.assert_called_with() comm.timeout = 10 - timeout.assert_called_with(array(10000.0)) + timeout.assert_called_with(array(10.0)) comm.timeout = 1000 * pq.millisecond - timeout.assert_called_with(array(1000.0)) + timeout.assert_called_with(array(1.0)) @mock.patch(patch_path)