Skip to content

Commit

Permalink
Release v0.18.2 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
esarver authored Sep 24, 2024
1 parent b53fe3a commit 45a98ae
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 28 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
34 changes: 27 additions & 7 deletions kic-discover-visa/src/visa.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -14,19 +15,38 @@ use crate::{insert_disc_device, model_check, IoType};
pub async fn visa_discover(timeout: Option<Duration>) -> anyhow::Result<HashSet<InstrumentInfo>> {
let mut discovered_instruments: HashSet<InstrumentInfo> = 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());
Expand Down

0 comments on commit 45a98ae

Please sign in to comment.