# Building a PyVISA Plug for SCPI Instruments URL: /guides/pyvisa-plug Wrap a bench instrument in an OpenHTF plug with PyVISA — resource strings, *IDN? identification, SCPI query and write, timeouts, error checking, simulation mode and per-station configuration of the VISA address. Most bench instruments — multimeters, power supplies, oscilloscopes, electronic loads, signal generators — speak SCPI over USB-TMC, GPIB, LAN (VXI-11 / HiSLIP) or serial. PyVISA gives them one Python API; an OpenHTF plug gives that API a managed lifecycle and a place in the test record. `pyvisa-py` is the pure-Python backend. On a bench with NI-VISA or Keysight IO Libraries installed you can skip it and PyVISA uses the vendor library. The left column is the **resource string**. It includes the instrument's serial number for USB, or its IP for LAN, so it identifies one physical instrument. Hard-coding the resource string ties the script to one bench. Declare it as configuration and bind it to the constructor: A `simulate` flag lets the script run on a laptop and in CI. Bind it the same way (the tutorial does this end to end): **Timeouts**: set `inst.timeout` (ms) above the slowest measurement. A 10-PLC DMM reading at 50 Hz takes 200 ms; a long average can take seconds. A timeout raises `pyvisa.VisaIOError`, which ends the test as `ERROR` — list it in `failure_exceptions` (Test Options) only if it means the DUT is bad. **Terminations**: USB-TMC handles message boundaries itself; serial and raw-socket connections need `read_termination`/`write_termination` set or every query hangs until timeout. **One `ResourceManager` per plug** keeps teardown simple. Sharing one across plugs works too; close it once. **Several identical instruments**: two `bind_init_args` with different config keys — see Multiple plug configuration. **Error queue**: check `SYST:ERR?` after commands that can fail silently (out-of-range setpoints). Instruments accumulate errors otherwise and later readings become suspect. **`*OPC?`** after `*RST` or a long setup command blocks until the instrument is ready.