diff --git a/CHANGES b/CHANGES index b11452fe..505bc0f2 100644 --- a/CHANGES +++ b/CHANGES @@ -23,7 +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 -- Pass termchar information to USBTMC devices when reading. PR#598 +- 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) ------------------ diff --git a/pyvisa_py/gpib.py b/pyvisa_py/gpib.py index 727c0c4d..3c9b696b 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)