diff --git a/CHANGES b/CHANGES index 611a4031..6960f9a6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,13 +1,14 @@ PyVISA-py Changelog =================== -0.5.1 (unreleased) +0.5.1 (30-09-2020) ------------------ - fix GPIB commands used in control_ren implementation PR #276 +- list serial resources under Windows without the COM prefix #269 - fix writing to serial resources PR #277 - fix return value of USB close method PR #265 -- fix pyvisa version contraint PR #268 +- fix pyvisa version constraint PR #268 0.5.0 (16-09-2020) ------------------ diff --git a/pyvisa_py/serial.py b/pyvisa_py/serial.py index 0f986a81..f0570163 100644 --- a/pyvisa_py/serial.py +++ b/pyvisa_py/serial.py @@ -6,6 +6,7 @@ :license: MIT, see LICENSE for more details. """ +import sys from typing import Any, List, Optional, Tuple from pyvisa import attributes, constants, logger, rname @@ -30,6 +31,8 @@ ) raise +IS_WIN = sys.platform == "win32" + def iter_bytes(data: bytes, mask: Optional[int] = None, send_end: bool = False): if send_end and mask is None: @@ -66,7 +69,10 @@ class SerialSession(Session): @staticmethod def list_resources() -> List[str]: - return ["ASRL%s::INSTR" % port[0] for port in comports()] + return [ + "ASRL%s::INSTR" % (port[0][3:] if IS_WIN else port[0]) + for port in comports() + ] @classmethod def get_low_level_info(cls) -> str: @@ -81,7 +87,9 @@ def after_parsing(self) -> None: cls = serial.Serial self.interface = cls( - port=self.parsed.board, timeout=self.timeout, write_timeout=self.timeout + port=("COM" if IS_WIN else "") + self.parsed.board, + timeout=self.timeout, + write_timeout=self.timeout, ) for name in ( diff --git a/pyvisa_py/testsuite/test_highlevel.py b/pyvisa_py/testsuite/test_highlevel.py index 2465a23d..ac798a09 100644 --- a/pyvisa_py/testsuite/test_highlevel.py +++ b/pyvisa_py/testsuite/test_highlevel.py @@ -6,6 +6,7 @@ :license: MIT, see LICENSE for more details. """ +from pyvisa.highlevel import list_backends from pyvisa.testsuite import BaseTestCase from pyvisa_py import highlevel @@ -14,6 +15,10 @@ class TestPyVisaLibrary(BaseTestCase): """Test generic property of PyVisaLibrary.""" + def test_list_backends(self): + """Test listing backends.""" + assert "py" in list_backends() + def test_debug_info(self): """Test generating debug infos for PyVISA-py.""" infos = highlevel.PyVisaLibrary.get_debug_info()