herosdevices.core.bus.visa - Heros Devices 0.11.1 documentation

Skip to content
Back to top
View this page

# herosdevices.core.bus.visa

Primitive functions and classes representing visa connections.

## Module Contents

herosdevices.core.bus.visa.pyvisa = None

class herosdevices.core.bus.visa.VisaConnection(resource: str, keep_alive: bool = True, **kwargs)

  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]

    Context manager for handling visa connection operations.

    Ensures the visa connection is open before performing operations and closes it afterward if `self.keep_alive` is False.

    Yields:

      Yields control back to the caller for performing operations within the context.

  read() → str | None

    Do device read query.

    Returns:

      The decoded data as string, or None if an error occurs.

  write(message: str, read_echo: bool = False, *args, **kwargs) → str | None

    Write to the visa connection.

    Parameters:

      - message – The message to be written to the serial connection.

      - read_echo – If True, reads back the echo after writing. Defaults to False.