Skip to content

Commit

Permalink
Merge 9dbe2ed into b53fe3a
Browse files Browse the repository at this point in the history
  • Loading branch information
esarver authored Sep 24, 2024
2 parents b53fe3a + 9dbe2ed commit 666c27c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ jobs:
LIB_VISA_PATH: "${{github.workflow}}"
steps:
- name: Tool Setup
run: rustup update nightly && rustup default nightly
# rustc regression: https://github.com/rust-lang/rust/issues/130769
# Change to "update nightly" after resolved
run: rustup install nightly-2024-09-23 && rustup default nightly-2024-09-23
- name: Ensure Correct Target is Installed
run: rustup target add ${{matrix.triple}}
- name: Tool Versions
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Security -- in case of vulnerabilities.
-->

## [0.18.2]

### Fixed

- Fix issue in discovering instruments when VISA errors

## [0.18.1]

### Fixed
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.18.1"
version = "0.18.2"
authors = ["Keithley Instruments, LLC"]
edition = "2021"
repository = "https://github.com/tektronix/tsp-toolkit-kic-cli"
Expand Down
27 changes: 24 additions & 3 deletions kic-discover-visa/src/visa.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashSet, ffi::CString, time::Duration};

use async_std::fs::write;
use serde::{Deserialize, Serialize};
use tracing::trace;
use tsp_toolkit_kic_lib::{
Expand All @@ -15,7 +16,13 @@ pub async fn visa_discover(timeout: Option<Duration>) -> anyhow::Result<HashSet<
let mut discovered_instruments: HashSet<InstrumentInfo> = HashSet::new();

let rm = visa_rs::DefaultRM::new()?;
let instruments = rm.find_res_list(&CString::new("?*")?.into())?;
let instruments = match rm.find_res_list(&CString::new("?*")?.into()) {
Ok(x) => x,
Err(e) => {
trace!("No VISA instruments found: {e}");
return Ok(discovered_instruments);
}
};
trace!("discovered: {instruments:?}");

for i in instruments {
Expand All @@ -24,9 +31,23 @@ pub async fn visa_discover(timeout: Option<Duration>) -> anyhow::Result<HashSet<
continue;
}
trace!("Connecting to {i:?} to get info");
let mut connected = rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE)?;
let mut connected = match rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE) {
Ok(c) => c,
Err(_) => {
trace!("Resource {i} no longer available, skipping.");
continue;
}
};

trace!("Getting info from {connected:?}");
let mut info = get_info(&mut connected)?;
let mut info = match get_info(&mut connected) {
Ok(i) => i,
Err(_) => {
trace!("Unable to write to {i}, skipping");
drop(connected);
continue;
}
};
info.address = Some(ConnectionAddr::Visa(i.clone()));
trace!("Got info: {info:?}");
let res = model_check(info.clone().model.unwrap_or("".to_string()).as_str());
Expand Down

0 comments on commit 666c27c

Please sign in to comment.