diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 689b57f..9c11818 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f0449b..b8e662f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.lock b/Cargo.lock index 4ff6e72..c4c87a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -443,9 +443,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "instrument-repl" -version = "0.18.1" +version = "0.18.2" dependencies = [ "chrono", "clap", @@ -1169,7 +1169,7 @@ dependencies = [ [[package]] name = "kic" -version = "0.18.1" +version = "0.18.2" dependencies = [ "anyhow", "clap", @@ -1188,7 +1188,7 @@ dependencies = [ [[package]] name = "kic-discover" -version = "0.18.1" +version = "0.18.2" dependencies = [ "anyhow", "async-std", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "kic-discover-visa" -version = "0.18.1" +version = "0.18.2" dependencies = [ "anyhow", "async-std", @@ -1248,7 +1248,7 @@ dependencies = [ [[package]] name = "kic-visa" -version = "0.18.1" +version = "0.18.2" dependencies = [ "anyhow", "clap", @@ -1678,9 +1678,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polling" @@ -2051,9 +2051,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -2301,18 +2301,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index b10a1b2..60b8e55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/kic-discover-visa/src/visa.rs b/kic-discover-visa/src/visa.rs index 6f7c88f..4edc77d 100644 --- a/kic-discover-visa/src/visa.rs +++ b/kic-discover-visa/src/visa.rs @@ -1,7 +1,8 @@ use std::{collections::HashSet, ffi::CString, time::Duration}; +use async_std::fs::write; use serde::{Deserialize, Serialize}; -use tracing::trace; +use tracing::{error, trace}; use tsp_toolkit_kic_lib::{ instrument::info::{get_info, InstrumentInfo}, interface::connection_addr::ConnectionAddr, @@ -14,19 +15,38 @@ use crate::{insert_disc_device, model_check, IoType}; pub async fn visa_discover(timeout: Option) -> anyhow::Result> { let mut discovered_instruments: HashSet = HashSet::new(); - let rm = visa_rs::DefaultRM::new()?; - let instruments = rm.find_res_list(&CString::new("?*")?.into())?; + let Ok(rm) = visa_rs::DefaultRM::new() else { + error!("Unable to get VISA Default Resource Manager"); + return Ok(discovered_instruments); + }; + 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 { - let i = i?; - if i.to_string().contains("SOCKET") { + let Ok(i) = i else { + continue; + }; + if i.to_string().contains("SOCKET") || i.to_string().contains("INTFC") { continue; } trace!("Connecting to {i:?} to get info"); - let mut connected = rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE)?; + let Ok(mut connected) = rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE) else { + trace!("Resource {i} no longer available, skipping."); + continue; + }; + trace!("Getting info from {connected:?}"); - let mut info = get_info(&mut connected)?; + let Ok(mut info) = get_info(&mut connected) else { + 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());