From 1cae96bec78ee61bdfd8c2bfc5ad669a66274975 Mon Sep 17 00:00:00 2001 From: Dave Platt Date: Thu, 25 Jun 2026 14:53:24 -0700 Subject: [PATCH 1/4] Implement EOS processing for GPIB interface Add code in GPIBsession _get_attribute and _set_attribute to map the TERMCHAR and TERMCHAR_EN attributes into the proper GPIB configuration settings. This allows GPIB reads to work correctly, when directed at older GPIB devices which do not signal EOI at the end of their talk output, but depend on EOS character matching. --- pyvisa_py/gpib.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/pyvisa_py/gpib.py b/pyvisa_py/gpib.py index 727c0c4d..deaed31d 100644 --- a/pyvisa_py/gpib.py +++ b/pyvisa_py/gpib.py @@ -371,15 +371,19 @@ def after_parsing(self) -> None: # Bus wide operation self.controller = Gpib(name=minor) - # Force timeout setting to interface + # Force timeout and termchar settings to interface self.set_attribute( constants.ResourceAttribute.timeout_value, attributes.AttributesByID[constants.VI_ATTR_TMO_VALUE].default, ) - - for name in ("TERMCHAR", "TERMCHAR_EN"): - attribute = getattr(constants, "VI_ATTR_" + name) - self.attrs[attribute] = attributes.AttributesByID[attribute].default + self.set_attribute( + constants.ResourceAttribute.termchar, + attributes.AttributesByID[constants.VI_ATTR_TERMCHAR].default, + ) + self.set_attribute( + constants.ResourceAttribute.termchar_enabled, + attributes.AttributesByID[constants.VI_ATTR_TERMCHAR_EN].default, + ) def _get_timeout( self, attribute: constants.ResourceAttribute @@ -630,6 +634,12 @@ def _get_attribute(self, attribute: ResourceAttribute) -> Tuple[Any, StatusCode] elif attribute == ResourceAttribute.interface_type: return constants.InterfaceType.gpib, StatusCode.success + elif attribute == ResourceAttribute.termchar: + return ifc.ask(0x0F), StatusCode.success + + elif attribute == ResourceAttribute.termchar_enabled: + return ifc.ask(0x0C), StatusCode.success + raise UnknownAttribute(attribute) def _set_attribute( @@ -708,6 +718,21 @@ def _set_attribute( else: return StatusCode.error_nonsupported_attribute_state + elif attribute == ResourceAttribute.termchar: + if isinstance(attribute_state, int): + ifc.config(0x0F, attribute_state) ## IbcEOSchar + ifc.config(0x0E, 1) ## IbcEOScmp + return StatusCode.success + else: + return StatusCode.error_nonsupported_attribute_state + + elif attribute == ResourceAttribute.termchar_enabled: + if isinstance(attribute_state, int): + ifc.config(0x0C, attribute_state) ## IbcEOSrd + return StatusCode.success + else: + return StatusCode.error_nonsupported_attribute_state + raise UnknownAttribute(attribute) From 5b519fd3e7277b134be1496c0b270d86dba25bb8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 22:04:35 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyvisa_py/gpib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyvisa_py/gpib.py b/pyvisa_py/gpib.py index deaed31d..3c9b696b 100644 --- a/pyvisa_py/gpib.py +++ b/pyvisa_py/gpib.py @@ -721,7 +721,7 @@ def _set_attribute( elif attribute == ResourceAttribute.termchar: if isinstance(attribute_state, int): ifc.config(0x0F, attribute_state) ## IbcEOSchar - ifc.config(0x0E, 1) ## IbcEOScmp + ifc.config(0x0E, 1) ## IbcEOScmp return StatusCode.success else: return StatusCode.error_nonsupported_attribute_state From babcb0a1fbb93dccbe567ecd90dc1ed5ed416ec9 Mon Sep 17 00:00:00 2001 From: Dave Platt Date: Thu, 25 Jun 2026 15:07:23 -0700 Subject: [PATCH 3/4] Document change to implement EOS processing --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 35798ba1..172f0578 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,8 @@ PyVISA-py Changelog server to receive VXI-11 `DEVICE_INTR_SRQ` callbacks. This also fixes the `create_intr_chan` XDR packer in `protocols/vxi11.py`. Other transports (GPIB, USBTMC, HiSLIP, Serial) remain unsupported for now. PR #577 +- Fix read timeouts when accessing older GPIB devices which do not signal EOI. + Implemented for USBTMC (#598) and GPIB (#599) 0.8.1 (04-09-2025) ------------------ From 48bf487ef9044059223e5108d59789231b11fad6 Mon Sep 17 00:00:00 2001 From: Matthieu Dartiailh Date: Fri, 26 Jun 2026 13:43:32 +0200 Subject: [PATCH 4/4] Update CHANGES --- CHANGES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 172f0578..505bc0f2 100644 --- a/CHANGES +++ b/CHANGES @@ -23,8 +23,8 @@ PyVISA-py Changelog server to receive VXI-11 `DEVICE_INTR_SRQ` callbacks. This also fixes the `create_intr_chan` XDR packer in `protocols/vxi11.py`. Other transports (GPIB, USBTMC, HiSLIP, Serial) remain unsupported for now. PR #577 -- Fix read timeouts when accessing older GPIB devices which do not signal EOI. - Implemented for USBTMC (#598) and GPIB (#599) +- Pass termchar information to USBTMC devices when reading PR #598 +- Properly configure termchar on GPIB devices. This fix timeout issues for old GPIB devices which do not signal EOI PR #599 0.8.1 (04-09-2025) ------------------