instrument-components — Rust test-equipment control
High-level Rust control for VISA instruments: auto-discovery, IVI-inspired typed classes (DMM, PSU, function generator), and mock fixtures for CI — built on visa-rs.
Install: cargo add instrument-components
Import: use instrument::prelude::* (the library name stays instrument even though the package is instrument-components)
What you get
- Auto-discovery of USB, GPIB, and serial VISA resources
- Typed instrument classes with SI units (volts, amps, hertz)
- Mock transport for hardware-free CI
- Per-device comms health and optional push diagnostics
- Stable
DeviceIdfor instrument replacement workflows
Choose your path
| I want to… | Start here |
|---|---|
| Test in CI without hardware | Mock quick start |
| Talk to real USB/GPIB gear | Hardware quick start |
| Build an app with device pickers | docs/discovery.md |
| Use async VISA I/O (opt-in) | docs/async.md |
Mock quick start
No VISA installation required.
[]
= { = "0.1", = false }
use *;
let fixture = builder
.idn
.kinds
.on_query
.build;
let catalog = from_fixture?;
let dmm = catalog.open_dmm?;
let volts = dmm.measure_voltage_dc?;
println!;
Hardware quick start
- Install NI-VISA or Keysight IO Libraries.
- Add the dependency (VISA enabled by default):
[]
= "0.1"
- Discover and measure:
use *;
let catalog = visa?.scan?;
catalog.print_summary;
let dmm = catalog.open_dmm?;
let volts = dmm.measure_voltage_dc?;
println!;
TCPIP/LXI devices usually need a manual address:
let catalog = visa?
.manual_address
.scan?;
See docs/getting-started.md for the full walkthrough.
Feature flags
| Feature | Default | Description |
|---|---|---|
visa |
yes | VISA backend via instrument-visa |
record |
no | Record real I/O into mock scripts |
tokio |
no | Full async API: AsyncScpiSession, AsyncDiscovery, typed classes |
cross-compile |
no | Cross-compile enum repr for visa-rs |
default-features = false |
— | Mock/CI only; no native VISA link |
# CI / mock only
= { = "0.1", = false }
# Async VISA (opt-in)
= { = "0.2", = ["visa", "tokio"] }
= { = "1", = ["rt-multi-thread", "macros"] }
Async quick start
Same mock path as above, with .await and AsyncDeviceCatalog:
[]
= { = "0.2", = false, = ["tokio"] }
= { = "1", = ["rt-multi-thread", "macros"] }
use *;
async
See docs/async.md for hardware async discovery and the full type map.
Documentation
- Getting started — step-by-step setup
- Architecture — crate layout and mental model
- Discovery — probe policy, device assignment
- Diagnostics — health polling and observers
- Async I/O — tokio feature and async API
- API overview — main types reference
- Examples — runnable examples index
- Contributing
API reference on docs.rs (after first publish).
Workspace crates
| Crate | crates.io | Role |
|---|---|---|
instrument-components |
facade | Discovery, typed classes, re-exports |
instrument-core |
backend | Transport, SCPI, mocks — no VISA |
instrument-visa |
backend | NI-VISA / Keysight VISA via visa-rs |
Testing
# Mock path (no VISA) — runs in CI
# Async mock path
# Hardware (local, requires VISA + instruments)
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.