instrument-components — dual-native test-equipment control
High-level Rust and C# control for VISA instruments: auto-discovery, IVI-inspired typed classes, and mock fixtures for CI. Shared SCPI, dialect, and classifier tables keep the two native implementations aligned.
Rust: cargo add instrument-components then use instrument::prelude::* (the library name stays instrument).
C#: project-reference InstrumentComponents (and InstrumentComponents.Visa for hardware) — see dotnet/.
What you get
- Auto-discovery of USB, GPIB, and serial VISA resources
- Typed instrument classes with SI units (volts, amps, hertz, seconds): DMM, DC power supply, function generator, oscilloscope, switch, counter, power meter, spectrum analyzer
- Mock transport for hardware-free CI in both languages
- 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 · C# mock |
| Talk to real USB/GPIB gear | Hardware quick start · C# hardware |
| Build an app with device pickers | docs/discovery.md |
| Use async VISA I/O (opt-in) | docs/async.md · C# async |
Mock quick start
No VISA installation required. Rust:
[]
= { = "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!;
C# (same fixture, no VISA):
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; use git/`latest` until 0.2.0 is published)
= { = "0.1", = ["visa", "tokio"] }
= { = "1", = ["rt-multi-thread", "macros"] }
Async quick start
Same mock path as above, with .await and AsyncDeviceCatalog:
[]
= { = "0.1", = false, = ["tokio"] }
= { = "1", = ["rt-multi-thread", "macros"] }
use *;
async
crates.io 0.1.0 predates the async API and later instrument classes. Until 0.2.0 is published, take those features from git/latest.
Documentation
Published site (MkDocs): https://josh-hemphill.github.io/instrument-components/
- Getting started — Rust step-by-step setup (published dual-language walkthrough: docs-site)
- 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
- Roadmap — dual-native reliability plan
- Dual-native plan — CI, session honesty, shared contracts
- Parity checklist — Rust ↔ C# scenario matrix
- .NET getting started — C# quick start (first-class, not a port afterthought)
- OpenTAP / HardwareTest consumer — contributor planning for session injection. User guide: C# OpenTAP pack.
- Contributing
API reference on docs.rs (after first publish). Local docs site: docs-site/ (pip install -r requirements.txt && mkdocs serve).
.NET / NuGet
Native C# packages live under dotnet/ — first-class, same contracts as Rust. Install from NuGet:
See dotnet/README.md for mock and hardware quick starts.
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 or self-hosted, requires VISA + a DMM)
# One-resource DMM smoke (used by .github/workflows/hardware.yml)
INSTRUMENT_RESOURCE='USB0::0x0957::0x0607::SN::INSTR' \
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.