herosdevices.core.bus.visa¶
Primitive functions and classes representing visa connections.
Module Contents¶
- herosdevices.core.bus.visa.pyvisa = None¶
- herosdevices.core.bus.visa.usb = None¶
- class herosdevices.core.bus.visa.VisaConnection(resource: str, keep_alive: bool = True, **kwargs)[source]¶
A class to manage VISA communication connections.
This class provides functionality to handle visa connections including opening/closing connections, reading data, and writing data.
- Parameters:
resource – The resource name of the visa instrument (e.g.
TCPIP::my_device_hostname::INSTR).keep_alive – Flag indicating whether to keep the connection open between operations.
**kwargs – Keyword arguments passed to
pyvisa.open_resource
- resource: str¶
- connection: pyvisa.resources.MessageBasedResource | None = None¶
- keep_alive = True¶
- operation() collections.abc.Iterator[None][source]¶
Context manager for handling visa connection operations.
Ensures the visa connection is open before performing operations and closes it afterward if
self.keep_aliveis False.- Yields:
Yields control back to the caller for performing operations within the context.
- close() None[source]¶
Close the visa connection if it is open.
The connection is reopened automatically on the next read or write operation.
- goto_local() None[source]¶
Set the device back to local mode by sending the USB488 GO_TO_LOCAL request.
pyvisa-py asserts the remote enable line of USBTMC devices when opening a connection but never releases it, leaving the device in remote mode (e.g. with a locked front panel) even after the connection is closed. Sending this request sets the device back to local mode.
This is a no-op if the connection is not a pyvisa-py USBTMC connection whose device supports the request. Errors are logged instead of raised, as this is a best effort cleanup operation.