VisaDriver
VisaDriver is the VISA transport that Nominal’s built-in SCPI instrument drivers sit on top of. It is available as a public part of the library so customers can build their own drivers for VISA-attached instruments without having to wrap pyvisa themselves.
It is intentionally narrow: it opens, closes, and locks a VISA resource and exposes text and raw byte I/O. The caller chooses the command strings.
VISA (Virtual Instrument Software Architecture) is the IVI Foundation standard for talking to instruments over GPIB, USB-TMC, TCP/IP (SOCKET, VXI-11, HiSLIP), and RS-232/RS-485.
VisaDriver uses pyvisa under the hood.VisaDriver addresses GPIB, USB-TMC, TCPIP (SOCKET, VXI-11, HiSLIP), and ASRL (serial) resources. For a comparison against the other transports, see Transports.
To author an instrument driver that composes VisaDriver, see the driver-development section of the instrument guide for that category: power supplies, electronic loads, multimeters, oscilloscopes, or DAQ. This page is the transport reference those guides link back to.
Quickstart
The most common use ofVisaDriver is as a transport inside an instrument driver. Here it is on its own, talking to a VISA instrument directly:
VisaDriver is configured with either a plain VISA resource string (defaults applied) or a full VisaConfig when you need to override the backend, terminators, timeouts, or serial settings.
Key concepts
Lifecycle
VisaDriver follows the standard transport lifecycle: construct, open(), I/O, close(), with both open() and close() idempotent. Two behaviors are specific to VISA:
open()applies the resource configuration. It opens the pyvisaResourceManagerand the resource, then applies terminators, timeouts, and (for ASRL resources) serial settings.- The
ResourceManageris shared process-wide. pyvisa caches one per backend across every driver in the process, soclose()closes this driver’s resource and leaves the manager open for other drivers. pyvisa closes it through its ownatexithandler.
VisaDriver as for any transport.
Terminators
VISA instruments are line-terminated.VisaDriver applies a configurable read terminator (stripped from incoming text) and write terminator (appended to outgoing text) when the resource is opened.
The defaults are read="\n" and write="\r\n", which works for most SCPI instruments. Override them through TerminatorConfig when an instrument’s programming manual specifies otherwise, as with USB-TMC devices that use "\n" for both directions, or older instruments that expect bare "\r".
Timeouts
Therecv timeout in TimeoutConfig is specified in seconds and is forwarded to pyvisa as the session timeout (converted to milliseconds internally). It controls how long a read or query waits for the instrument to respond before raising. The default is 15 seconds.
The connect and send fields are accepted by VisaConfig for forward compatibility but are not yet wired into per-operation overrides. Leave them at the defaults unless you have a reason to set them.
Serial settings
When the VISA resource is an ASRL (RS-232 / RS-485) interface,VisaDriver applies SerialConfig (baud rate, data bits, stop bits, parity, and flow control) on open(). For any other interface type (USB-TMC, GPIB, TCPIP, …) the serial config is silently ignored, so you can leave it at the defaults.
Text vs. raw I/O
VisaDriver exposes both a text path and a raw byte path:
query_raw is a convenience: it writes a text command (so the write terminator is still applied) and then reads the response as raw bytes. This matches the common SCPI pattern of asking for binary data with a text command like :WAV:DATA?.
Backends
VisaConfig.visa_backend selects which pyvisa backend handles the resource. Most callers should leave it unset. When unset (None), instro uses the system IVI VISA implementation ("@ivi", e.g. NI-VISA or Keysight IO Libraries) and automatically falls back to the pure-Python "@py" backend when no IVI implementation is installed. Setting visa_backend to any explicit value (such as "@ivi", "@py", or "@sim") uses that backend as-is, with no fallback.
Raw TCP sockets and Nagle’s algorithm
For rawTCPIP...::SOCKET resources, VisaDriver disables Nagle’s algorithm (TCP_NODELAY) on open(). IVI backends already do this by default, but the pure-Python "@py" backend does not, so on "@py" it would otherwise leave Nagle enabled. With Nagle on, several small back-to-back SCPI writes can be coalesced into one TCP segment, and some instruments’ lightweight LAN firmware resets the connection when that happens. Disabling it makes the "@py" SOCKET path behave like IVI. Set VisaConfig(tcp_nodelay=False) to opt out; it has no effect on non-socket transports.
Configuration
For terminators, timeouts, or serial settings, pass aVisaConfig instead of a plain resource string:
VisaConfig
Top-level connection parameters.
TerminatorConfig
TimeoutConfig
Operation timeouts in seconds.
SerialConfig
Serial-line settings, applied when the VISA resource is an ASRL (RS-232/RS-485) interface. Ignored for all other interface types.
VISA resource strings
VisaDriver does not invent its own addressing scheme. The visa_resource string is passed straight through to pyvisa’s ResourceManager.open_resource(). Some commonly used forms:
Method reference
Error handling
SYST:ERR? is a SCPI convention, not a VisaDriver feature. VisaDriver does not poll the instrument’s error queue for you. Whether and how to do so is a per-instrument decision. Most SCPI instruments implement SYST:ERR? and respond with 0,"No error" when nothing is wrong, but some use SYSTEM:ERROR? (TDK Lambda) or a different status mechanism entirely. Consult the programming manual.