Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
35 changes: 30 additions & 5 deletions pyvisa_py/gpib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)


Expand Down
Loading