Expand description
Safe rust bindings for VISA(Virtual Instrument Software Architecture) library
Most documentation comes from NI-VISA Product Documentation
Requirements
This crate needs to link to an installed visa library, for example, NI-VISA.
You can specify path of visa64.lib
file (or visa32.lib
on 32-bit systems) by setting environment variable LIB_VISA_PATH
.
On Windows, the default installation path will be added if no path is specified.
Example
use std::ffi::CString;
use std::io::{BufRead, BufReader, Read, Write};
use visa_rs::{flags::AccessMode, DefaultRM, TIMEOUT_IMMEDIATE};
let rm = DefaultRM::new()?; //open default resource manager
let expr = CString::new("?*KEYSIGH?*INSTR").unwrap().into(); //expr used to match resource name
let rsc = rm.find_res(&expr)?; // find the first resource matched
let mut instr = rm.open(&rsc, AccessMode::NO_LOCK, TIMEOUT_IMMEDIATE)?; //open a session to resource
instr.write_all(b"*IDN?\n").unwrap(); //write message
let mut buf_reader = BufReader::new(instr);
let mut buf = String::new();
buf_reader.read_line(&mut buf).unwrap(); //read response
eprintln!("{}", buf);
Ok(())
Modules
Defines visa attributes, visa status and visa event as Rust enums
Defines AccessMode
and FlushMode
Defines Callback
trait used in Instrument::install_handler
,
which returns a Handler
to manage lifetime of data passed
Structs
Default Resource Manager for VISA
Session to a specified resource
Job ID of a asynchronous operation,
Returned by DefaultRM::find_res_list
, handler to iterator over matched resources
Simple wrapper of std::ffi::CString