Virtual instrument software architecture (VISA)
This is an unsafe wrapper around the native implementations of Visa from multiple vendors. This wrapper allows for dynamic switching between different visa implementaitons during runtime if needed. This library is kept as close as possible to native implementation so the user will need to use CTypes such as CString, and[u8;x] arrays, c_char, c_uchar, c_schar, c_void etc. This library can be use as is or if you prefer a safe simplified abstraction then you can use instrument_communication library which will be published before May 1st 2023.
How to use
To use this library you can load a visa Dynamically linked library .dll or .so etc. There are multiple options to load.
let visa = create
.unwrap_or
.unwrap_or
.unwrap_or?;
then you need to open a default session
let mut _session = 0;
let status = visa.viOpenDefaultRM;
once that's open, you can try connecting to an instrument using its address
let address = new?;
let mut vi = 0;
let status = visa.viOpen;
note a successfully connection will return a status of 0. You can then set the timeout and termination charachter
visa.viSetAttribute; // Set timeout
visa.viSetAttribute; // set termination byte to 10
visa.viSetAttribute; // enabled termination byte to stop reading when encountering this character.
define the command string as byte array.
let cmd = b"*IDN?\n";
initialize return character count
let mut ret_cnt = 0u32;
write command to instrument
let status=visa.viWrite;
status will be 0 if successfull.
Define read buffer size (50 bytes in this case)
let resp = vec!;
Then read the return message
let status = visa.viRead;
convert the bytes to a readable text.
let response = from_utf8?;
print it
println!;