Crates.io | visa-device-handler |
lib.rs | visa-device-handler |
version | 1.1.0 |
source | src |
created_at | 2024-07-30 15:17:36.755198 |
updated_at | 2024-10-21 11:14:40.743269 |
description | a crate to handle NI-VISA connections and simplify its use. |
homepage | |
repository | https://github.com/LiorBuch/VisaDeviceHandler |
max_upload_size | |
id | 1319952 |
size | 122,709 |
Based on the visa crate, this crate aims to provide a wrapper to allow multiple device connections and handling,
and make the usage of NI-VISA easier to use.
The crate have mutex safe and non mutex safe mode.
The crate supports Windows, and sould support Linux and MacOS. but is being tested mainly on Windows.
core
): The basic visa wrapper, simillar to the visa.h file.map
): Adds the functionality of DeviceMap
.mutex_map
): Adds the functionality of MutexDeviceMap
.all
): Enables all features. let lib =
let device_session = device.session;
let cmd: &[u8] = "*IDN?\n".as_bytes();
let mut ret_cnt = 0u32;
let mut status = self.lib.viWrite(
device_session,
cmd.as_ptr(),
u32::try_from(cmd.len()).map_err(|_| "u32 conversion error".to_string())?,
&mut ret_cnt,
);
let sdm_result:SafeDeviceMap = SafeDeviceMap::init(None);
match sdm_result {
Ok(mapper) => {
mapper.connect_device("address_01".to_string());
let data = mapper.query_from_device("name_01".to_string(),"cool funcation with args").unwrap();
println!("got {} from the device",data);
mapper.disconnect_device("name_01".to_string());
}
Err(e) => {/*print codes or anything */}
}
The next Tauri project utilizes the crate as a peripheral for NI-VISA. https://github.com/LiorBuch/showcaser. this project uses React and Mantine as the UI, it's not failproof as it's just a POC.
The next project creates an emulator of a visa device to be used with a TCP connection. As the project is not mine, i cant help much with its usage. One issue i spotted is that read operations always timeout, probably a missing termination character. Link to the project: https://github.com/bluehands/Open-SCPI-Protocol-Emulator/tree/main
get_first_device
now returns the device instead of printing.
get_first_device
and find_all_devices
now won't print unless debug
boolean is true.
Fixed the error where the CString parses null terminators.
Added key error map in some functions.
get_first_device
and find_all_devices
Fixed the problem where unable to use devices mapped since key include [\0
] chars and address not.
Validated usage of TCP deviecs and emulators.
Added the option to define if a program should terminate by the Verbosity
of the error, as some error codes can be warnings. defaults to Error level.