Skip to content

Commit

Permalink
Fix VISA issue (#21)
Browse files Browse the repository at this point in the history
When connecting to an instrument, don't search for the instrument first,
just open it.
  • Loading branch information
esarver authored Sep 5, 2024
1 parent 46ca0c9 commit 43dc13c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 55 deletions.
88 changes: 44 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/interface/connection_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::interface::usbtmc::UsbtmcAddr;
use visa_rs::VisaString;

/// A generic connection address that covers all the different connection types.
///
/// Each device interface type will also have a [`TryFrom`] impl that converts from
/// this enum to itself. [`From`] is **not** implemented because the conversion could
/// fail.
Expand Down
14 changes: 3 additions & 11 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,10 @@ impl Protocol {
unparsable_string: visa_string,
});
};
trace!("Finding resource");
let mut rsc = rm.find_res_list(&resource_string)?;
trace!("Resource List: {rsc:?}");
let Some(rsc) = rsc.find_next()? else {
warn!("No resource found");
return Err(InstrumentError::ConnectionError {
details: "unable to find requested resource".to_string(),
});
};
trace!("Resource: {rsc:?}");

trace!("Opening resource");
let instr: visa_rs::Instrument = rm.open(&rsc, AccessMode::NO_LOCK, TIMEOUT_INFINITE)?;
let instr: visa_rs::Instrument =
rm.open(&resource_string, AccessMode::NO_LOCK, TIMEOUT_INFINITE)?;
trace!("Opened instrument: {instr:?}");

Ok(Self::Visa { instr, rm })
Expand Down

0 comments on commit 43dc13c

Please sign in to comment.