Tektronix2SeriesMSO#

class Tektronix2SeriesMSO(
visa_resource: str | VisaConfig,
)[source]#

Bases: ScopeDriverBase

SCPI driver for Tektronix 2 Series MSO oscilloscopes (MSO22, MSO24).

Methods

check_errors

Drain ALLEv? and raise on any event with code > 1.

clear_measurements

Delete every measurement slot on the scope and reset the local cache.

close

Close the underlying transport.

digitize

SEQuence``+``RUN, then *OPC? under a scoped VISA timeout.

fetch_waveform

Fetch the waveform from channel over RIBinary (signed 16-bit).

force_trigger

Force a trigger event immediately, regardless of the configured conditions.

get_acquisition_mode

Read back the current acquisition mode.

get_acquisition_state

Read back the acquisition run state (RUNNING / STOPPED).

get_average_count

Read back the waveforms-to-average count.

get_coupling

Read back input coupling on channel.

get_horizontal_scale

Read back the timebase (seconds/div).

get_probe_attenuation

Read back channel's probe attenuation ratio.

get_sample_rate

Read back the current sample rate (samples per second).

get_trigger_status

Read back the trigger status (ARMED / READY / TRIGGERED / …).

get_vertical_offset

Read back channel's vertical offset (volts).

get_vertical_scale

Read back channel's vertical scale (V/div).

load_settings

Recall a scope setup from name.

measure

Read a built-in measurement from a persistent slot; the vendor's invalid sentinel maps to NaN.

open

Open the underlying transport.

run

Start continuous (free-running) acquisition.

save_screenshot

Capture a screenshot.

save_settings

Save the current scope setup.

set_acquisition_mode

Set the acquisition mode.

set_average_count

Set the number of waveforms to average.

set_coupling

Set AC/DC input coupling on channel.

set_horizontal_scale

Set the timebase to seconds_per_div.

set_probe_attenuation

Set channel's probe attenuation ratio (e.g. 1, 10, 100, 1000).

set_trigger_level

Set the trigger threshold to level (volts).

set_trigger_mode

Set the trigger sweep mode (AUTO / NORMAL).

set_trigger_slope

Set the trigger edge slope (RISING / FALLING / EITHER).

set_trigger_source

Set the trigger source to analog channel.

set_trigger_type

Set the trigger type (EDGE, PULSE, …).

set_vertical_offset

Set channel's vertical offset to offset (volts).

set_vertical_scale

Set channel's vertical scale to volts_per_div (V/div).

setup_measurement

Ensure a persistent measurement slot exists for this type and channel.

single

Arm a single-shot acquisition.

stop

Stop acquisition.

open() → None[source]#

Open the underlying transport. Idempotent.

Concrete drivers also perform any one-shot instrument setup here (e.g. *CLS, remote-mode handshake).

close() → None[source]#

Close the underlying transport. Idempotent.

check_errors() → None[source]#

Drain ALLEv? and raise on any event with code > 1.

set_vertical_scale(
volts_per_div: float,
channel: int,
) → None[source]#

Set channel’s vertical scale to volts_per_div (V/div).

Drivers may snap to the nearest hardware-supported step. Callers that need the actual applied value should get_vertical_scale() afterward.

get_vertical_scale(channel: int) → float[source]#

Read back channel’s vertical scale (V/div).

set_vertical_offset(
offset: float,
channel: int,
) → None[source]#

Set channel’s vertical offset to offset (volts).

get_vertical_offset(channel: int) → float[source]#

Read back channel’s vertical offset (volts).

set_coupling(
coupling: Coupling,
channel: int,
) → None[source]#

Set AC/DC input coupling on channel.

get_coupling(
channel: int,
) → Coupling[source]#

Read back input coupling on channel.

set_probe_attenuation(
factor: float,
channel: int,
) → None[source]#

Set channel’s probe attenuation ratio (e.g. 1, 10, 100, 1000).

get_probe_attenuation(channel: int) → float[source]#

Read back channel’s probe attenuation ratio.

set_horizontal_scale(seconds_per_div: float) → None[source]#

Set the timebase to seconds_per_div. Applies globally to all channels.

get_horizontal_scale() → float[source]#

Read back the timebase (seconds/div).

get_sample_rate() → float[source]#

Read back the current sample rate (samples per second).

This is the effective hardware rate the scope is acquiring at; it depends on the timebase, memory depth, and interpolation settings.

set_acquisition_mode(
mode: AcquisitionMode,
) → None[source]#

Set the acquisition mode.

Drivers should raise NotImplementedError for AcquisitionMode values their scope doesn’t support (e.g. Keysight 1200X has no ENVELOPE mode).

get_acquisition_mode() → AcquisitionMode[source]#

Read back the current acquisition mode.

set_average_count(count: int) → None[source]#

Set the number of waveforms to average. Only takes effect in AcquisitionMode.AVERAGE.

get_average_count() → int[source]#

Read back the waveforms-to-average count.

run() → None[source]#

Start continuous (free-running) acquisition.

stop() → None[source]#

Stop acquisition. Leaves the captured data intact for fetch_waveform / measure.

single() → None[source]#

Arm a single-shot acquisition.

Non-blocking — use get_acquisition_state to poll for STOPPED, or prefer digitize() which combines arming and waiting.

digitize(timeout: float) → None[source]#

SEQuence``+``RUN, then *OPC? under a scoped VISA timeout. clear() on timeout to restore the session.

get_acquisition_state() → AcquisitionState[source]#

Read back the acquisition run state (RUNNING / STOPPED).

fetch_waveform(
channel: int,
) → WaveformData[source]#

Fetch the waveform from channel over RIBinary (signed 16-bit).

setup_measurement(
measurement_type: ScopeMeasurementType,
channel: int,
) → None[source]#

Ensure a persistent measurement slot exists for this type and channel.

Uses MEASUrement:ADDMEAS <type> to create the slot atomically with the target type — this avoids the race where ADDNew "MEAS<n>" + MEAS<n>:TYPe creates a slot that briefly computes under the scope’s default type (typically Period) before the type change takes effect, causing the first measure() call to return a stale, wrong-type value. ADDMEAS doesn’t take a name; the new slot’s name (the scope auto-assigns the next MEAS<n>) is recovered by diffing MEASUrement:LIST? before and after the add.

Tektronix computes measurements during acquisition, so the slot must exist before the scope triggers for results to be valid.

clear_measurements() → None[source]#

Delete every measurement slot on the scope and reset the local cache.

measure(
measurement_type: ScopeMeasurementType,
channel: int,
) → float[source]#

Read a built-in measurement from a persistent slot; the vendor’s invalid sentinel maps to NaN.

set_trigger_source(channel: int) → None[source]#

Set the trigger source to analog channel.

Drivers typically cache this value because the trigger-level SCPI on some scopes requires the source channel in the same command.

set_trigger_type(
trigger_type: TriggerType,
) → None[source]#

Set the trigger type (EDGE, PULSE, …).

set_trigger_level(level: float) → None[source]#

Set the trigger threshold to level (volts). Applies to the configured trigger source.

set_trigger_slope(
slope: TriggerSlope,
) → None[source]#

Set the trigger edge slope (RISING / FALLING / EITHER).

set_trigger_mode(
mode: TriggerMode,
) → None[source]#

Set the trigger sweep mode (AUTO / NORMAL).

AUTO forces an acquisition if no trigger fires within the timeout; NORMAL waits indefinitely for a real trigger.

force_trigger() → None[source]#

Force a trigger event immediately, regardless of the configured conditions.

get_trigger_status() → TriggerStatus[source]#

Read back the trigger status (ARMED / READY / TRIGGERED / …).

save_screenshot(
filepath: str,
to_instrument: bool = False,
) → bytes[source]#

Capture a screenshot.

Parameters:
  • filepath

    Output path. When to_instrument=False this is a host path; when True it is a path on the scope’s filesystem (USB stick, internal storage).

  • to_instrument

    When True, the scope writes the file itself and this returns b"". When False, the image is transferred to the host, written to filepath, and the raw bytes are returned for in-memory use.

save_settings(
name: str,
to_instrument: bool = False,
) → bytes[source]#

Save the current scope setup. Path semantics mirror save_screenshot().

load_settings(
name: str,
from_instrument: bool = False,
) → None[source]#

Recall a scope setup from name.

With from_instrument=True the scope reads from its own filesystem; otherwise the host reads name and pushes the bytes to the scope. After loading, the calling InstroScope should invalidate its tracked ScopeState and resync if a fresh view is needed.