tsuitoar / visa-rs Goto Github PK
View Code? Open in Web Editor NEWHigh-level Rust bindings to VISA(Virtual Instrument Software Architecture)
License: Apache License 2.0
High-level Rust bindings to VISA(Virtual Instrument Software Architecture)
License: Apache License 2.0
I've been looking for a visa-sys fill for ages! Thankyou!
I've read most of the "book" and would like to start contribute to projects.
How would I go about doing this?
There are some operations that are not covered by this crate currently, check NI-VISA API for the operations list.
Besides several variadic functions like viPrintf that is not compatible with Rust, most of them are used for memory operations such as viMemAlloc, viMove, viInx and viOutx.
To be honest, I'm not familiar with these low-level ops. Despite they are easy to wrap since they have simple function types, I'm not sure whether the environment in which these functions are used has Rust compiler and the wrapped version would look a lot like raw FFI functions.
Building in both versions 0.4.0 and 0.5.0 gives the following error on Ubuntu 22.04:
error[E0308]: mismatched types
--> /home/fbordwell/.cargo/git/checkouts/visa-rs-657bd5cc4c91eb01/a805029/src/flags.rs:12:25
|
12 | const NO_LOCK = vs::VI_NO_LOCK;
| ^^^^^^^^^^^^^^ expected `u64`, found `u32`
error[E0308]: mismatched types
--> /home/fbordwell/.cargo/git/checkouts/visa-rs-657bd5cc4c91eb01/a805029/src/flags.rs:13:32
|
13 | const EXCLUSIVE_LOCK = vs::VI_EXCLUSIVE_LOCK;
| ^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error[E0308]: mismatched types
--> /home/fbordwell/.cargo/git/checkouts/visa-rs-657bd5cc4c91eb01/a805029/src/flags.rs:14:29
|
14 | const SHARED_LOCK = vs::VI_SHARED_LOCK;
| ^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error[E0308]: mismatched types
--> /home/fbordwell/.cargo/git/checkouts/visa-rs-657bd5cc4c91eb01/a805029/src/flags.rs:15:29
|
15 | const LOAD_CONFIG = vs::VI_LOAD_CONFIG;
| ^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `visa-rs` due to 4 previous errors
When a device is not present in the system and I try to connect via TCP using DefaultRM::new()?.open()
, visa-rs panics with a 0xBFFF0011 error which should just be returned as an visa-rs::Error
because the function already returns a result contain that error type. The root cause of the panic is an unwrap
after a try_into
in the wrap_raw_error_in_unsafe
macro.
This crate wraps two async operations, async_read and async_write, they rely on Callback added to EventIoCompletion event that VISA is listening to.
There are several aspects that need to be aware of and should be improved:
The cause of the first problem is not clear, it might be related with running multiple VISA program synchronously, use cargo t --jobs 1
can usually pass all tests, without it, a function of the tests will not quit sometimes. Another is associated with the Waker mechanism of Rust future system.
They might be solved by adding another Waker that wakes the futures after some time no matter what.
I'm not familiar with low level async programing design and not sure if there are better solutions, any help would be grateful.
This is related to my comments on #19 but more specific to the functionality of this binding lib to the open source version of VISA.
While trying to run through the example code, I only get: Error: Insufficient location information or the device or resource is not present in the system.
when i try to send any resource string into find_res
.
I've tried explicit TCPIP0::192.168.0.100::inst0::INSTR
, which was used on pyVisa and worked, all way way down to simply ?*
. No matter what I type I get the error above. That error seems to come from the VISA library itself as I don't see that string in the code.
Curious if anyone else has had this issue or is it most people use the NI lib?
Thanks!
hi
I am now experiencing an error that says I did not find the relevant resource,
This occurs when only KS drivers exist in some PCS and when both drivers exist in some PCS:ErrorRsrcNfound: Insufficient location information or the device or resource is not present in the system.
This error occurred when I was trying to find the resource, and my code is as follows:
pub fn new(chn: String,instr_ip:String) -> Result<Self, String> {
let rm = RESOURCE_DEFAULTRM.lock().map_err(|e| format!("{:?}", e))?;
let ip_s = format!("TCPIP0::{}::inst0::INSTR", instr_ip);
let expr = CString::new(ip_s)
.map_err(|err| format!("{:?}", err))?
.into();
let rsc = rm.find_res(&expr).map_err(|op| format!("{:?}", op))?;
let instr = rm
.open(&rsc, AccessMode::NO_LOCK, TIMEOUT_IMMEDIATE)
.map_err(|op| format!("{:?}", op))?;
Ok(Self { instr, chn })
}
I wonder if visa_rs can specify drivers that use KS or Ni, such as python's visa.resourceManager method
The VISA library has lots of CompletionCode, currently this crate discards this information and treat them all the same.
This should be improved, but I don't know a Rust style to handle this kind of return value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.