VisaDriver#

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

Bases: TransportBase

Transport for VISA-attached instruments. Composed by concrete drivers, not extended.

Supports shared ownership: a device serving several categories holds one connection for all of them, passing each category view as the holder to open()/close(), and it closes only when the last owner closes it. Thread-safe at the I/O level via an internal lock; use lock() to keep a multi-step VISA sequence atomic.

Construct from a VISA resource string (uses defaults) or a full VisaConfig.

Attributes

is_open

Whether the underlying VISA resource is currently open.

Methods

clear

VISA device clear — aborts any pending operation.

close

Close and teardown; with a holder, remove it and tear down only when the last owner leaves.

lock

Return the reentrant resource lock for atomic multi-step sequences; the holder may write/query/read inside it.

open

Open the connection (idempotent); with a holder, admit it and return True only for the first owner.

query

Write command and read the response.

query_binary_values

Send command and decode the IEEE-488.2 definite-length binary block reply.

query_raw

Write command (with terminator) and read raw bytes — reply is not decoded or stripped.

read

Read a response, stripping the configured read terminator.

read_raw

Read raw bytes from the instrument.

temporary_timeout

Hold the lock and override the operation timeout to timeout_ms ms; restored on exit (even if raises).

write

Write command to the instrument; the configured write terminator is appended.

write_raw

Write raw bytes verbatim.