smu2401

SMU Model 2401 device driver module.

SMU2401

SMU2401(
    config_entry: DeviceConfigEntry,
    verbose: bool,
    visa_resource: MessageBasedResource,
    default_visa_timeout: int,
)

Bases: SMU24xxStandard

flowchart LR tm_devices.drivers.source_measure_units.smu24xx.smu2401.SMU2401[SMU2401] tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard[SMU24xxStandard] tm_devices.driver_mixins.shared_implementations.common_pi_system_error_check_mixin.CommonPISystemErrorCheckMixin[CommonPISystemErrorCheckMixin] tm_devices.driver_mixins.device_control.pi_control.PIControl[PIControl] tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl[_AbstractDeviceVISAWriteQueryControl] tm_devices.drivers.source_measure_units.source_measure_unit.SourceMeasureUnit[SourceMeasureUnit] tm_devices.drivers.device.Device[Device] tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl[_AbstractDeviceControl] tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin[_ExtendableMixin] tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard --> tm_devices.drivers.source_measure_units.smu24xx.smu2401.SMU2401 tm_devices.driver_mixins.shared_implementations.common_pi_system_error_check_mixin.CommonPISystemErrorCheckMixin --> tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl --> tm_devices.driver_mixins.shared_implementations.common_pi_system_error_check_mixin.CommonPISystemErrorCheckMixin tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl --> tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl tm_devices.driver_mixins.device_control.pi_control.PIControl --> tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl --> tm_devices.driver_mixins.device_control.pi_control.PIControl tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl --> tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin --> tm_devices.driver_mixins.device_control.pi_control.PIControl tm_devices.drivers.source_measure_units.source_measure_unit.SourceMeasureUnit --> tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard tm_devices.drivers.device.Device --> tm_devices.drivers.source_measure_units.source_measure_unit.SourceMeasureUnit tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl --> tm_devices.drivers.device.Device tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin --> tm_devices.drivers.device.Device click tm_devices.drivers.source_measure_units.smu24xx.smu2401.SMU2401 href "" "tm_devices.drivers.source_measure_units.smu24xx.smu2401.SMU2401" click tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard href "" "tm_devices.drivers.source_measure_units.smu24xx.smu24xx_standard.SMU24xxStandard" click tm_devices.driver_mixins.shared_implementations.common_pi_system_error_check_mixin.CommonPISystemErrorCheckMixin href "" "tm_devices.driver_mixins.shared_implementations.common_pi_system_error_check_mixin.CommonPISystemErrorCheckMixin" click tm_devices.driver_mixins.device_control.pi_control.PIControl href "" "tm_devices.driver_mixins.device_control.pi_control.PIControl" click tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl href "" "tm_devices.driver_mixins.device_control._abstract_device_visa_write_query_control._AbstractDeviceVISAWriteQueryControl" click tm_devices.drivers.source_measure_units.source_measure_unit.SourceMeasureUnit href "" "tm_devices.drivers.source_measure_units.source_measure_unit.SourceMeasureUnit" click tm_devices.drivers.device.Device href "" "tm_devices.drivers.device.Device" click tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl href "" "tm_devices.driver_mixins.device_control._abstract_device_control._AbstractDeviceControl" click tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin href "" "tm_devices.driver_mixins.shared_implementations._extension_mixin._ExtendableMixin"

SMU2401 device driver.

Parameters:
  • config_entry (DeviceConfigEntry) –

    A config entry object parsed by the DMConfigParser.

  • verbose (bool) –

    A boolean indicating if verbose output should be printed. If True, communication printouts will be logged with a level of INFO. If False, communication printouts will be logged with a level of DEBUG.

  • visa_resource (MessageBasedResource) –

    The VISA resource object.

  • default_visa_timeout (int) –

    The default VISA timeout value in milliseconds.

address property

address: str

Return the device address as defined in the config_entry.

This could be an IP address, hostname, or USB device address.

alias cached property

alias: str

Return the alias if it exists, otherwise an empty string.

all_channel_names_list property

all_channel_names_list: tuple[str, ...]

Return a tuple containing all the channel names.

command_argument_constants cached property

command_argument_constants: Any

Return the device command argument constants.

command_syntax_enabled property

command_syntax_enabled: bool

Return a string containing the syntax of the command being accessed.

This property indicates when the syntax should be returned instead of writing/querying the device and returning the result.

command_verification_enabled property

command_verification_enabled: bool

Indicate if command verification is enabled.

This property only applies to commands sent using the .commands property of the device.

Notes
  • If .enable_verification is set to False, then no verification will happen at all.
  • If .enable_verification is set to True and this property is True, then verification will happen for commands sent using the .commands property of the device.
  • If .enable_verification is set to True and this property is False, then verification will not happen for commands sent using the .commands property of the device.

commands cached property

commands: Any

Return the device commands.

config_entry cached property

config_entry: DeviceConfigEntry

Return the device config.

connection_type property

connection_type: str

Return a string indicating the connection type.

default_visa_timeout property

default_visa_timeout: int

Return the default VISA timeout value in milliseconds.

device_number property

device_number: int

Return the device number, if it was not created by the DeviceManager it will be -1.

device_type cached property

device_type: str

Return a string representing the device type.

enable_verification property writable

enable_verification: bool

Return the boolean which indicates if verification checks should happen.

This can be disabled after developing a script in order to increase the speed of the script.

Notes
  • If .enable_verification is set to False, then no verification of any commands sent using the .set_and_check() method will occur (the “check” portion of “set” and “check” will be skipped).
  • If .enable_verification is set to True, then verification will happen for commands sent using the .set_and_check() method (both the “set” and “check” portions will be executed).

hostname cached property

hostname: str

Return the hostname of the device or an empty string if unable to fetch that.

idn_string cached property

idn_string: str

Return the string returned from the *IDN? query when the device was created.

ieee_cmds property

ieee_cmds: IEEE4882Commands

Return an internal class containing methods for the standard IEEE 488.2 command set.

ip_address cached property

ip_address: str

Return the IPv4 address of the device or an empty string if unable to fetch that.

is_open property

is_open: bool

Indicate if the connection to the device is currently open.

manufacturer cached property

manufacturer: str

Return the manufacturer of the device.

model cached property

model: str

Return the full model of the device.

name cached property

name: str

Return the device name.

Usually something like “SCOPE 1”

name_and_alias cached property

name_and_alias: str

Return string for easy ID of device in console output prints.

port property

port: int | None

Return the device port, or None if the device doesn’t have a port.

resource_expression property

resource_expression: str

Return the VISA resource expression.

serial cached property

serial: str

Return the serial number of the device.

series cached property

series: str

Return the series of the device.

Returns:
  • str

    The series of the device, e.g. MSO5, TSOVu, TEKSCOPE, AFG3K, AWG5200

sw_version cached property

sw_version: Version

Return the software version of the device.

total_channels cached property

total_channels: int

Return the total number of channels (all types).

verbose property

verbose: bool

Return the verbose attribute of the device.

visa_backend cached property

visa_backend: str

Return the VISA backend in use.

visa_resource property

visa_resource: MessageBasedResource

Return the VISA resource object.

This gives access to all the attributes and methods that PyVISA provides.

visa_timeout property writable

visa_timeout: float

Return the current VISA timeout of the device in milliseconds.

add_method classmethod

add_method(method: Callable[Concatenate[Self, _P], _T]) -> None

Add a method to the class.

This class method is best used as a decorator on functions in order to add them to a class.

Examples:

>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_method
... def print_hello(self: Device, var: str):
...     print("Hello World!")
...     print(f"I am a {self.__class__.__name__}!")
...     print(f"My var is {var}")
Parameters:

add_property classmethod

add_property(method: Callable[Concatenate[_EM, _P], _T]) -> None
add_property(
    method: None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[Concatenate[_EM, _P], _T]], None]
add_property(
    method: Callable[[Self], _T] | None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[[Self], _T]], None] | None

Add a property to the class.

This class method is best used as a decorator on functions in order to add them to a class.

Examples:

>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_property
... def foo(self: Device):
...     return "bar"
>>>
>>> @Device.add_property(is_cached=True)
... def foo(self: Device):
...     return self.name + self.address
Parameters:
  • method (Callable[[Self], _T] | None, default: None ) –

    The property to add to the class.

  • is_cached (bool, default: False ) –

    Whether the property is only evaluated once and cached.

check_network_connection

check_network_connection() -> tuple[bool, str]

Check the network connection to the device using an external ping command.

Wrapper function for check_network_connection.

Returns:
  • tuple[bool, str]

    A tuple containing a boolean indicating if there is a network connection and a string with the result of the ping command.

check_port_connection

check_port_connection(port: int, timeout_seconds: int = 5) -> bool

Check if the given port is open on the device.

Wrapper function for check_port_connection.

Parameters:
  • port (int) –

    The port to check.

  • timeout_seconds (int, default: 5 ) –

    The number of seconds to use as the socket timeout.

Returns:
  • bool

    A boolean indicating if the port is open.

check_visa_connection

check_visa_connection() -> bool

Check if a VISA connection can be made to the device.

Wrapper function for check_visa_connection.

cleanup

cleanup(verbose: bool = True) -> None

Perform the cleanup defined for the device.

Parameters:
  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

close

close() -> None

Close this device and all its used resources and components.

command_syntax

command_syntax() -> Generator[None, None, None]

Enable command syntax for the duration of this context manager.

This method is designed to be used as a context manager (with device.command_syntax():) around any blocks of code where the literal syntax of commands accessed using the .commands property is desired.

This is accomplished by setting the .command_syntax_enabled property to True for the duration of the context manager.

command_verification

command_verification() -> Generator[None, None, None]

Enable command verification for the duration of this context manager.

This method is designed to be used as a context manager (with device.command_verification():) around any blocks of code where verification of commands sent using the .commands property is desired.

This is accomplished by setting the .command_verification_enabled property to True for the duration of the context manager.

device_clear

device_clear() -> None

Clear the input and output buffers of the VISA device.

disable_srq_events

disable_srq_events() -> None

Disable the service request event for the device.

enable_srq_events

enable_srq_events() -> None

Enable the service request event for the device.

expect_esr

expect_esr(
    esr: int, error_messages: tuple[str, ...] = (), *, use_regex_match: bool = False
) -> bool

Checks for the expected esr value and queued error messages.

Parameters:
  • esr (int) –

    Expected *ESR? value as a decimal-weighted integer.

  • error_messages (tuple[str, ...], default: () ) –

    Expected error buffer messages in a tuple.

  • use_regex_match (bool, default: False ) –

    A boolean indicating if the messages should be compared using regular expressions. Does not affect the esr value comparison.

Returns:
  • bool

    Boolean True when all checks pass. False means the checks failed (however, failing a check will always result in an AssertionError being raised, so the result will not really be usable).

Raises:
  • AssertionError

    Indicating that the device’s error code and messages don’t match the expected values.

factory_reset

factory_reset() -> None

Send the FACTORY command followed by an *OPC? query.

This command is equivalent to pressing the DEFAULT SETUP button located on the instrument front panel or selected Default Setup from the File menu.

It recalls the instrument to factory default settings.

In addition to what *RST does, this command also performs the following operations:

  • Clears any pending OPC operations
  • Resets the following IEEE488.2 registers:
  • *ESR 0 (Event Status Enable Register)
  • *SRE 0 (Service Request Enable Register)
  • DESE 255 (Device Event Status Enable Register)
  • *PSC 1 (Power-on Status Clear Flag)
  • Deletes all defined aliases.
  • Enables command headers (:HEADer 1).

FACTORY only resets the programmable interface settings, it does not change the user interface settings.

get_errors

get_errors() -> tuple[int, tuple[str, ...]]

Get the current errors from the device.

Note

This method will clear out the error queue after reading the current errors.

Returns:
  • tuple[int, tuple[str, ...]]

    A tuple containing the current error code alongside a tuple of the current error messages.

get_visa_stb

get_visa_stb() -> int

Return the VISA status byte.

has_errors

has_errors() -> bool

Check if the device has any errors.

Note

This method will clear out the error queue after reading the current errors.

Returns:
  • bool

    A boolean indicating if any errors were found in the device. True means there were errors, False means no errors were found.

poll_query

poll_query(
    number_of_polls: int,
    query: str,
    wanted_val: float | str,
    sleep_time: float = 0.4,
    tolerance: float = 0,
    percentage: bool = False,
    invert_range: bool = False,
    invalid_values: list[float | str] | None = None,
) -> None

Poll the query until the wanted value appears.

Parameters:
  • number_of_polls (int) –

    The number of times to poll the query.

  • query (str) –

    The query to poll.

  • wanted_val (float | str) –

    The desired value to poll for.

  • sleep_time (float, default: 0.4 ) –

    The time to wait between polls (in seconds).

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values.

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • invert_range (bool, default: False ) –

    A boolean indicating when to stop polling. False means polling until the wanted value appears. True means polling until a different value from the wanted value appears.

  • invalid_values (list[float | str] | None, default: None ) –

    A list of values that should never be received when polling.

Raises:
  • AssertionError

    Indicating that the device never reached the wanted value.

query

query(
    query: str, *, verbose: bool = True, remove_quotes: bool = False, allow_empty: bool = False
) -> str

Send a query to the device and return the result.

Parameters:
  • query (str) –

    The query to send to the device.

  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

  • remove_quotes (bool, default: False ) –

    Set this to True to remove all double quotes from the returned value.

  • allow_empty (bool, default: False ) –

    Set this to True if an empty return string is permitted.

Returns:
  • str

    The results of the query.

Raises:
  • Error

    An error occurred while sending the command.

  • SystemError

    An empty string was returned from the device.

query_binary

query_binary(
    query: str,
    verbose: bool = True,
    datatype: BINARY_DATATYPES = "f",
    is_big_endian: bool = False,
    container: type[T] | Callable[[Iterable[Any]], T] = list,
    delay: float | None = None,
    header_fmt: BINARY_HEADERS = "ieee",
    expect_termination: bool = True,
    data_points: int = 0,
    chunk_size: int | None = None,
) -> T

Send a query to the device and return the binary values.

Parameters:
  • query (str) –

    The query to send to the device.

  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

  • datatype (BINARY_DATATYPES, default: 'f' ) –

    Format string for a single element. See struct module. ‘h’ by default.

  • is_big_endian (bool, default: False ) –

    Are the data in big or little endian order. Defaults to False.

  • container (type[T] | Callable[[Iterable[Any]], T], default: list ) –

    Container type to use for the output data. Possible values are: list, tuple, np.ndarray, etc. Default to list.

  • delay (float | None, default: None ) –

    Delay in seconds between write and read operations. If None, defaults to self.query_delay.

  • header_fmt (BINARY_HEADERS, default: 'ieee' ) –

    Format of the header prefixing the data. Defaults to ‘ieee’.

  • expect_termination (bool, default: True ) –

    When set to False, the expected length of the binary values block does not account for the final termination character (the read termination). Defaults to True.

  • data_points (int, default: 0 ) –

    Number of points expected in the block. This is used only if the instrument does not report it itself. This will be converted in a number of bytes based on the datatype. Defaults to 0.

  • chunk_size (int | None, default: None ) –

    Size of the chunks to read from the device. Using larger chunks may be faster for large amount of data.

Returns:
  • T

    The results of the query.

Raises:
  • Error

    An error occurred while sending the command.

  • SystemError

    An empty string was returned from the device.

query_expect_timeout

query_expect_timeout(invalid_command: str, timeout_ms: int = 200, verbose: bool = True) -> str

Send a query expecting it to time out and fail.

Parameters:
  • invalid_command (str) –

    The bad command to query.

  • timeout_ms (int, default: 200 ) –

    The VISA timeout duration for this function (in milliseconds).

  • verbose (bool, default: True ) –

    A flag to decide if we should print out a message indicating what query was sent.

Returns:
  • str

    The timeout error or the response to the query.

Raises:
  • Error

    Any non-timeout error will be re-raised.

query_less_than

query_less_than(
    query: str,
    value: float | str,
    tolerance: float = 0,
    percentage: bool = False,
    allow_equal: bool = False,
) -> bool

Send the given query and verify the result is less than the expected response.

Parameters:
  • query (str) –

    The command that is being checked.

  • value (float | str) –

    The expected value of the query.

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values.

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • allow_equal (bool, default: False ) –

    A boolean indicating if equal results should be allowed.

Returns:
  • bool

    Boolean indicating whether the check passed or failed.

query_raw_binary

query_raw_binary(query: str, verbose: bool = True) -> bytes

Send a command to the device and then read and return the raw binary values.

Parameters:
  • query (str) –

    The query to send to the device.

  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

Returns:
  • bytes

    The raw results of the query.

Raises:
  • Error

    An error occurred while sending the command.

  • SystemError

    An empty string was returned from the device.

query_response

query_response(
    query: str,
    value: str | float,
    tolerance: float = 0,
    percentage: bool = False,
    remove_quotes: bool = False,
    custom_message_prefix: str = "",
    allow_empty: bool = False,
) -> tuple[bool, str]

Query the device and verify the result.

Parameters:
  • query (str) –

    The query that is being checked.

  • value (str | float) –

    The expected value of the query.

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values.

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • remove_quotes (bool, default: False ) –

    Set this to True to remove all double quotes from the returned value.

  • custom_message_prefix (str, default: '' ) –

    A custom message to be prepended to the failure message.

  • allow_empty (bool, default: False ) –

    Set this to True if an empty return string is permitted.

Returns:
  • tuple[bool, str]

    Tuple containing the boolean verification result and the value returned from the query.

query_response_not

query_response_not(
    query: str, value: str, remove_quotes: bool = False, custom_message_prefix: str = ""
) -> tuple[bool, str]

Query the device and verify the result is not the given value.

Parameters:
  • query (str) –

    The query that is being checked.

  • value (str) –

    The value that the query should not return.

  • remove_quotes (bool, default: False ) –

    Set this to True to remove all double quotes from the returned value.

  • custom_message_prefix (str, default: '' ) –

    A custom message to be prepended to the failure message.

Returns:
  • tuple[bool, str]

    Tuple containing the boolean verification result and the value returned from the query.

read

read() -> str

Return the read results from the VISA resource.

read_raw

read_raw(size: int | None = None) -> bytes

Return the read_raw results from the VISA resource.

Parameters:
  • size (int | None, default: None ) –

    The chunk size to use to perform the reading. Defaults to None, meaning the resource wide set value is set.

Returns:
  • bytes

    The bytes read from the device.

reboot

reboot(quiet_period: int = 0) -> bool

Reboot the device and reconnect all its used resources and components.

Parameters:
  • quiet_period (int, default: 0 ) –

    Optional sleep after the reboot in seconds.

Returns:
  • bool

    A boolean representing the status of the reboot.

reset

reset() -> None

Send the *RST command followed by an *OPC? query.

*RST only resets the programmable interface settings, it does not change the user interface settings.

reset_visa_timeout

reset_visa_timeout() -> None

Reset the VISA timeout to the default value.

set_and_check

set_and_check(
    command: str,
    value: str | float,
    tolerance: float = 0,
    percentage: bool = False,
    remove_quotes: bool = False,
    custom_message_prefix: str = "",
    *,
    expected_value: str | float | None = None,
    opc: bool = False
) -> str

Send the given command with the given value and then verify the results.

Parameters:
  • command (str) –

    The command to send. For example: :AFG:FUNCTION

  • value (str | float) –

    The value being set by the command. For example: SINE

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values.

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • remove_quotes (bool, default: False ) –

    Set this to True to remove all double quotes from the returned value.

  • custom_message_prefix (str, default: '' ) –

    A custom message to be prepended to the failure message.

  • expected_value (str | float | None, default: None ) –

    An optional, alternative value expected to be returned.

  • opc (bool, default: False ) –

    Boolean indicating if *OPC? should be queried after sending the command.

Returns:
  • str

    The output of the query portion of the method.

set_if_needed

set_if_needed(
    command: str,
    value: str | float,
    tolerance: float = 0,
    percentage: bool = False,
    remove_quotes: bool = False,
    custom_message_prefix: str = "",
    *,
    expected_value: str | float | None = None,
    opc: bool = False,
    allow_empty: bool = False,
    verify_value: bool = False
) -> tuple[bool, str]

Query the command’s field and update it if the value does not match the input.

Parameters:
  • command (str) –

    The command to send. For example: :AFG:FUNCTION

  • value (str | float) –

    The value being set by the command. For example: SINE

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values.

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • remove_quotes (bool, default: False ) –

    Set this to True to remove all double quotes from the returned value.

  • custom_message_prefix (str, default: '' ) –

    A custom message to be prepended to the failure message.

  • expected_value (str | float | None, default: None ) –

    An optional, alternative value expected to be returned.

  • opc (bool, default: False ) –

    Boolean indicating if *OPC? should be queried after sending the command.

  • allow_empty (bool, default: False ) –

    Set this to True if an empty return string is permitted.

  • verify_value (bool, default: False ) –

    Boolean indicating to verify value after write.

Returns:
  • tuple[bool, str]

    Tuple containing the boolean value indicating if the command needed to be set and the value returned from the query.

temporary_enable_verification

temporary_enable_verification(temporary_enable_verification: bool) -> Generator[None, None, None]

Enable (or disable) all verification of communication for the duration of the context.

This will temporarily set the Device.enable_verification property to the specified value, and then reset it to the previous value when the context exits.

Parameters:
  • temporary_enable_verification (bool) –

    The temporary verification value (True or False).

temporary_verbose

temporary_verbose(temporary_verbose: bool) -> Generator[None, None, None]

Set a temporary console output verbosity for the duration of the context.

This will reset the verbosity to the previous value when the context exits.

Parameters:
  • temporary_verbose (bool) –

    The temporary verbosity value.

temporary_visa_timeout

temporary_visa_timeout(temporary_timeout_ms: float) -> Generator[None, None, None]

Set a temporary VISA timeout value for the duration of the context.

This will reset the VISA timeout to the previous value when the context exits.

Parameters:
  • temporary_timeout_ms (float) –

    The temporary VISA timeout value, in milliseconds.

wait_for_network_connection

wait_for_network_connection(
    wait_time: float, sleep_seconds: int = 2, accept_immediate_connection: bool = False
) -> bool

Wait for a network connection to the device.

Parameters:
  • wait_time (float) –

    The number of seconds to wait for the network connection.

  • sleep_seconds (int, default: 2 ) –

    The number of seconds to sleep in between connection attempts.

  • accept_immediate_connection (bool, default: False ) –

    A boolean indicating if a connection on the first attempt is a valid connection.

Returns:
  • bool

    A boolean indicating if a network connection was made within the given time limit.

Raises:
  • AssertionError

    Indicating that the device erroneously connected on the first try.

wait_for_port_connection

wait_for_port_connection(
    port: int, wait_time: float, sleep_seconds: int = 5, accept_immediate_connection: bool = False
) -> bool

Wait for a connection to be made to the given port on the device.

Parameters:
  • port (int) –

    The port to check.

  • wait_time (float) –

    The maximum time to wait in seconds.

  • sleep_seconds (int, default: 5 ) –

    The number of seconds to sleep in between connection attempts.

  • accept_immediate_connection (bool, default: False ) –

    A boolean indicating if a connection on the first attempt is a valid connection.

Returns:
  • bool

    A boolean indicating if a connection was made to the port within the given time limit.

Raises:
  • AssertionError

    Indicating that the device erroneously connected on the first try.

wait_for_srq_event

wait_for_srq_event(timeout: int) -> WaitResponse

Wait for the service request event to happen, up to the given timeout.

Parameters:
  • timeout (int) –

    Time to wait (in seconds).

Returns:
  • WaitResponse

    The WaitResponse for the SRQ event.

wait_for_visa_connection

wait_for_visa_connection(
    wait_time: float, sleep_seconds: int = 5, accept_immediate_connection: bool = False
) -> bool

Wait for a VISA connection to be made to the device.

Parameters:
  • wait_time (float) –

    The maximum time to wait in seconds.

  • sleep_seconds (int, default: 5 ) –

    The number of seconds to sleep in between connection attempts.

  • accept_immediate_connection (bool, default: False ) –

    A boolean indicating if a connection on the first attempt is a valid connection.

Returns:
  • bool

    A boolean indicating if a VISA connection was made within the given time limit.

Raises:
  • AssertionError

    Indicating that the device erroneously connected on the first try.

write

write(command: str, opc: bool = False, verbose: bool = True) -> None

Write a command to the device.

Parameters:
  • command (str) –

    The command to write to the device

  • opc (bool, default: False ) –

    Boolean indicating if *OPC? should be queried after sending the command.

  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

Raises:
  • Error

    An error occurred while sending the command.

  • SystemError

    *OPC? did not return “1” after sending the command.

write_raw

write_raw(command: bytes, verbose: bool = True) -> None

Write a raw command to the device.

Parameters:
  • command (bytes) –

    The command to write to the device

  • verbose (bool, default: True ) –

    Set this to False in order to disable printouts.

Raises:
  • Error

    An error occurred while sending the command.